From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: Karel Zak <kzak@redhat.com>
Cc: <util-linux@vger.kernel.org>
Subject: Re: libblkid: Idea to force given cached entry to be invalidated?
Date: Thu, 17 Apr 2014 09:17:03 +0800 [thread overview]
Message-ID: <534F2B8F.5010906@cn.fujitsu.com> (raw)
In-Reply-To: <20140416090359.GF5786@x2.net.home>
-------- Original Message --------
Subject: Re: libblkid: Idea to force given cached entry to be invalidated?
From: Karel Zak <kzak@redhat.com>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2014年04月16日 17:03
> On Wed, Apr 16, 2014 at 08:53:27AM +0800, Qu Wenruo wrote:
>>> So the problem is not that btrfs is fast enough ;-)
>> According to your explaination, it seems that if there is any modification
>> to the block device, libblkid will rescan it and not
>> to use the old cache, do I understand it right?
> Yes, blkid_verify():
>
> if (now >= dev->bid_time &&
> #ifdef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
> (st.st_mtime < dev->bid_time ||
> (st.st_mtime == dev->bid_time &&
> st.st_mtim.tv_nsec / 1000 <= dev->bid_utime)) &&
> #else
> st.st_mtime <= dev->bid_time &&
> #endif
> (diff < BLKID_PROBE_MIN ||
> (dev->bid_flags & BLKID_BID_FL_VERIFIED &&
> diff < BLKID_PROBE_INTERVAL)))
> return dev;
>
>
> It checks two basic things:
>
> a) compare device st_mtime with cache entry time (bid_time and bid_utime),
> the valid cache entry has not to be older than device mtime.
>
> b) valid cache entry has not to be older than BLKID_PROBE_MIN (2 sec)
> and previous blkid_verify() validation remaining in memory has not
> to be older than BLKID_PROBE_INTERVAL (200s).
>
>>> BTW, it would be nice to have --verbose option for btrfs-scan, now it
>>> seems like black box.
>> I'd like to add it, but as you know, 'btrfs dev scan' just calls a btrfs
>> ioctl, so even '--verbose' is added,
>> nothing useful will be printed out. :(
> Well, I mean at least info about for what devices it calls the ioctls.
>
> Karel
>
Thanks for all your explaination.
Now I think I am somewhat clear of the libblkid cache now.
But after some tests, it seems that the ctime/mtime based cache seems
not perfect due to the fact that multiple
device file can be created in different fs with same major/minor number.
especially each of them has individual ctime/mtime timestamp.
So if someone (maybe insane) use mknod to create as block device file
and use 'btrfs dev del' on the newly created
block device file, libblkid will still be unable to detect the change
since the ctime/mtime of block device file in /dev/
does not change.
Will libblkid be able to deal with it in later versions? (Although not
related to my original problem now)
Thanks,
Qu
next prev parent reply other threads:[~2014-04-17 1:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 2:15 libblkid: Idea to force given cached entry to be invalidated? Qu Wenruo
2014-04-15 4:27 ` Theodore Ts'o
2014-04-15 4:52 ` Qu Wenruo
2014-04-15 11:21 ` Karel Zak
2014-04-16 0:53 ` Qu Wenruo
2014-04-16 9:03 ` Karel Zak
2014-04-17 1:17 ` Qu Wenruo [this message]
2014-04-17 8:21 ` Karel Zak
2014-04-17 8:29 ` Qu Wenruo
2014-04-18 11:02 ` Karel Zak
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=534F2B8F.5010906@cn.fujitsu.com \
--to=quwenruo@cn.fujitsu.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