util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Borisov <nborisov@suse.com>
To: kzak@redhat.com
Cc: util-linux@vger.kernel.org, Nikolay Borisov <nborisov@suse.com>
Subject: [PATCH 2/2] libblkid: Set BLKID_BID_FL_VERIFIED in case revalidation is not needed
Date: Mon, 13 May 2019 15:32:42 +0300	[thread overview]
Message-ID: <20190513123242.23673-2-nborisov@suse.com> (raw)
In-Reply-To: <20190513123242.23673-1-nborisov@suse.com>

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. 

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 libblkid/src/verify.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libblkid/src/verify.c b/libblkid/src/verify.c
index 49fc11d228b8..58b347751e73 100644
--- a/libblkid/src/verify.c
+++ b/libblkid/src/verify.c
@@ -97,7 +97,9 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
 #endif
 	    (diff < BLKID_PROBE_MIN ||
 		dev->bid_flags & BLKID_BID_FL_VERIFIED)) {
+		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"
-- 
2.7.4


      reply	other threads:[~2019-05-13 12:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13 12:32 [PATCH 1/2] libblkid: Don't check BLKID_PROBE_INTERVAL in blkid_verify Nikolay Borisov
2019-05-13 12:32 ` Nikolay Borisov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190513123242.23673-2-nborisov@suse.com \
    --to=nborisov@suse.com \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).