[lvm-devel] [QUESTION] lvmcache_label_scan: checksum error at offset xxx

Zdenek Kabelac zkabelac at redhat.com
Wed Jun 9 11:09:31 UTC 2021


Dne 09. 06. 21 v 11:32 Wu Guanghao napsal(a):
> Hi,
>
> lvcreate and lvremove execute lvmcache_label_scan() to read the metadata on the lvm device,
> but no lock is added for protection. if other processes are currently executing vg_commit() to submit metadata,
> then it will go wrong.



Hi

The initial scan is going 'lockless' to avoid holding VG locks for too long 
when it's not strictly necessary.

The purpose of this scan is to quickly collect & cache all the info which is 
needed to know. The we take the lock and essentially do another 'rescan' 
however in this case we only need to 'check' if the cache data corresponds to 
the current disk state by checking only PV small header information.

Another 'side' efffect  (probably not very used) is that user may specify VG 
via  VG UUID, but for the VG lock we need to use VG name - so we need to be 
able to 'translate' UUID to vgname - and for this we need to know lvm2 
metadata with this info.

Now when the parallel processe manages to change some data (while holding its 
lock), such internal disk cache will be thrown away (PV header will mismatch) 
and this particular PV is rereaded while the command now holds the correct 
lock. But this is really very occasional situation and the benefit of lockless 
asynchronous scanning outweighs this.


Regards


Zdenek





More information about the lvm-devel mailing list