]> git.ipfire.org Git - thirdparty/util-linux.git/commit
libblkid: Set BLKID_BID_FL_VERIFIED in case revalidation is not needed
authorNikolay Borisov <nborisov@suse.com>
Mon, 13 May 2019 12:44:18 +0000 (15:44 +0300)
committerKarel Zak <kzak@redhat.com>
Tue, 14 May 2019 11:35:58 +0000 (13:35 +0200)
commit99878f5dc49c7a8bf110a355ec9e84a1daa767f9
tree47708a4c85b9def7540d6576172584e6d382e81a
parent5de879b0f28574a1395e36a2b15b8fc6fd88ce35
libblkid: Set BLKID_BID_FL_VERIFIED in case revalidation is not needed

If blkid_verify deems that device revalidation is not needed since BLKID_PROBE_MIN
seconds haven't elapsed since the last revalidation of the device it returns
a blkid_dev. However, if this device has been read from the cache file on disk then
it wont' have BLKID_BID_FL_VERIFIED bit set. This in turn could lead to a later
call to blkid_dev_get free this device in case its part of a multi device
configuration. This is particularly relevant to btrfs raid configurations.

Namely this  was exhibited by btrfs-progs which use blkid for device enumeration.
In case of a multi-device filesystem (i.e raid10) running xfstest btrfs/011
would fail sporadically since cached devices read from cache were not revalidated
due to being recently validated (according to timestamp in the cache file) at
the same time their in-memory blkid_dev structures didn't have BLKID_BID_FL_VERIFIED
set. This lead to their untimely removal from the cache from blkid_get_dev.

Fix this by setting the BLKID_BID_FL_VERIFIED when returning from blkid_verify
with a valid device irrespective of whether full revalidation was performed or
the device is deemed valid due to being recently validated.

[kzak@redhat.com: - remove also check for BLKID_BID_FL_VERIFIED, the
                    function needs to check for elapsed time only]

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/verify.c