diff options
author | Nikolay Borisov | 2019-05-13 14:44:18 +0200 |
---|---|---|
committer | Karel Zak | 2019-05-14 13:35:58 +0200 |
commit | 99878f5dc49c7a8bf110a355ec9e84a1daa767f9 (patch) | |
tree | 47708a4c85b9def7540d6576172584e6d382e81a /libblkid | |
parent | libblkid: Don't check BLKID_PROBE_INTERVAL in blkid_verify (diff) | |
download | kernel-qcow2-util-linux-99878f5dc49c7a8bf110a355ec9e84a1daa767f9.tar.gz kernel-qcow2-util-linux-99878f5dc49c7a8bf110a355ec9e84a1daa767f9.tar.xz kernel-qcow2-util-linux-99878f5dc49c7a8bf110a355ec9e84a1daa767f9.zip |
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>
Diffstat (limited to 'libblkid')
-rw-r--r-- | libblkid/src/verify.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c index e630ab1a3..dbc10f254 100644 --- a/libblkid/src/verify.c +++ b/libblkid/src/verify.c @@ -95,9 +95,10 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev) #else st.st_mtime <= dev->bid_time && #endif - (diff < BLKID_PROBE_MIN || - dev->bid_flags & BLKID_BID_FL_VERIFIED)) + diff < BLKID_PROBE_MIN) { + dev->bid_flags |= BLKID_BID_FL_VERIFIED; return dev; + } #ifndef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC DBG(PROBE, ul_debug("need to revalidate %s (cache time %lu, stat time %lu,\t" |