From: Theodore Tso <tytso@mit.edu>
To: Erez Zadok <ezk-EX0cT3Az47bauI2f2gSDlQ@public.gmane.org>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
Trond Myklebust <Trond.Myklebust@netapp.com>,
Kevin Coffman <kwc@umich.edu>,
nfs@lists.sourceforge.net, linux-nfs@vger.kernel.org,
Himanshu Kanda <hkanda-EX0cT3Az47bauI2f2gSDlQ@public.gmane.org>
Subject: [PATCH, E2FSPROGS] blkid: If the device mtime is newer that the cache time, force a revalidation
Date: Wed, 21 May 2008 11:58:20 -0400 [thread overview]
Message-ID: <20080521155820.GJ8581@mit.edu> (raw)
In-Reply-To: <200805202232.m4KMWD11020355-zop+azHP2WsZjdeEBZXbMidm6ipF23ct@public.gmane.org>
This fixes problems turned up by a test case written by Erez Zadok's
group which constantly reformats filesystems.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
lib/blkid/probe.c | 48 +++++++++++++++++++++++++++---------------------
1 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index 4964209..62ab392 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -1214,33 +1214,39 @@ blkid_dev blkid_verify(blkid_cache cache, blkid_dev dev)
now = time(0);
diff = now - dev->bid_time;
- if ((now > dev->bid_time) && (diff > 0) &&
+ if (stat(dev->bid_name, &st) < 0) {
+ DBG(DEBUG_PROBE,
+ printf("blkid_verify: error %s (%d) while "
+ "trying to stat %s\n", strerror(errno), errno,
+ dev->bid_name));
+ open_err:
+ if ((errno == EPERM) || (errno == EACCES) || (errno == ENOENT)) {
+ /* We don't have read permission, just return cache data. */
+ DBG(DEBUG_PROBE, printf("returning unverified data for %s\n",
+ dev->bid_name));
+ return dev;
+ }
+ blkid_free_dev(dev);
+ return NULL;
+ }
+
+ if ((now >= dev->bid_time) &&
+ (st.st_mtime <= dev->bid_time) &&
((diff < BLKID_PROBE_MIN) ||
(dev->bid_flags & BLKID_BID_FL_VERIFIED &&
diff < BLKID_PROBE_INTERVAL)))
return dev;
DBG(DEBUG_PROBE,
- printf("need to revalidate %s (time since last check %llu)\n",
- dev->bid_name, (unsigned long long)diff));
-
- if (((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) ||
- (fstat(probe.fd, &st) < 0)) {
- if (probe.fd >= 0) close(probe.fd);
- if ((errno != EPERM) && (errno != EACCES) &&
- (errno != ENOENT)) {
- DBG(DEBUG_PROBE,
- printf("blkid_verify: error %s (%d) while "
- "opening %s\n", strerror(errno), errno,
- dev->bid_name));
- blkid_free_dev(dev);
- return NULL;
- }
- /* We don't have read permission, just return cache data. */
- DBG(DEBUG_PROBE,
- printf("returning unverified data for %s\n",
- dev->bid_name));
- return dev;
+ printf("need to revalidate %s (cache time %d, stat time %d,\n\t"
+ "time since last check %lu)\n",
+ dev->bid_name, dev->bid_time, st.st_mtime, (unsigned long)diff));
+
+ if ((probe.fd = open(dev->bid_name, O_RDONLY)) < 0) {
+ DBG(DEBUG_PROBE, printf("blkid_verify: error %s (%d) while "
+ "opening %s\n", strerror(errno), errno,
+ dev->bid_name));
+ goto open_err;
}
probe.cache = cache;
--
1.5.4.1.144.gdfee-dirty
prev parent reply other threads:[~2008-05-21 15:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-17 22:04 [NFS] [PATCH] nfs2/3 ESTALE bug (libblkid uses stale cache/uuid values) Erez Zadok
[not found] ` <200805172204.m4HM424o003970-zop+azHP2WsZjdeEBZXbMidm6ipF23ct@public.gmane.org>
2008-05-19 16:04 ` J. Bruce Fields
2008-05-19 19:03 ` Theodore Tso
2008-05-20 22:32 ` [NFS] " Erez Zadok
[not found] ` <200805202232.m4KMWD11020355-zop+azHP2WsZjdeEBZXbMidm6ipF23ct@public.gmane.org>
2008-05-21 15:58 ` Theodore Tso [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=20080521155820.GJ8581@mit.edu \
--to=tytso@mit.edu \
--cc=Trond.Myklebust@netapp.com \
--cc=bfields@fieldses.org \
--cc=ezk-EX0cT3Az47bauI2f2gSDlQ@public.gmane.org \
--cc=hkanda-EX0cT3Az47bauI2f2gSDlQ@public.gmane.org \
--cc=kwc@umich.edu \
--cc=linux-nfs@vger.kernel.org \
--cc=nfs@lists.sourceforge.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.