From: Eric Sandeen <sandeen@redhat.com>
To: Andreas Dilger <adilger@dilger.ca>
Cc: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH V2] filefrag: count 0 extents properly when verbose
Date: Thu, 05 May 2011 13:21:08 -0500 [thread overview]
Message-ID: <4DC2EA94.8040100@redhat.com> (raw)
In-Reply-To: <569EBA4C-A6BB-4E64-88B9-F2F946891B56@dilger.ca>
# rm -f a; touch a; filefrag a
/boot/a: 0 extents found
works properly, but
# rm -f a; touch a; filefrag -v a
Filesystem type is: ef53
Filesystem cylinder groups is approximately 61
File size of a is 0 (0 blocks, blocksize 1024)
ext logical physical expected length flags
a: 1 extent found
yields 1 extent when it should be 0.
Fix this up by special-casing no extents returned in verbose
mode; skip printing the header for the columns too, since there
are no columns to print.
Also, in nonverbose mode we can set fm_extent_count to 0
so that FIEMAP will just query the extent count without gathering
details; clarify this with a comment.
Addresses-redhat-bugzilla: 653234
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
diff --git a/misc/filefrag.c b/misc/filefrag.c
index d604b6c..2795e15 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -180,6 +180,10 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents)
memset(fiemap, 0, sizeof(struct fiemap));
+ /*
+ * If count (and therefore fm_extent_count) == 0, FIEMAP
+ * returns count of extents found without filling in details.
+ */
if (!verbose)
count = 0;
@@ -204,6 +208,14 @@ static int filefrag_fiemap(int fd, int blk_shift, int *num_extents)
}
if (verbose && !fiemap_header_printed) {
+ /*
+ * No extents on first call?
+ * Skip header and show 0 extents.
+ */
+ if (fiemap->fm_mapped_extents == 0) {
+ *num_extents = 0;
+ goto out;
+ }
printf(" ext %*s %*s %*s length flags\n", logical_width,
"logical", physical_width, "physical",
physical_width, "expected");
next prev parent reply other threads:[~2011-05-05 18:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-23 23:21 [PATCH] filefrag: count optimize non-verbose mode; count 0 extents properly when verbose Eric Sandeen
2010-12-09 17:19 ` Eric Sandeen
2011-03-11 15:01 ` Eric Sandeen
2011-04-08 16:44 ` Eric Sandeen
2011-04-08 23:40 ` Andreas Dilger
2011-05-05 18:21 ` Eric Sandeen [this message]
2011-05-07 22:45 ` [PATCH V2] filefrag: " Ted Ts'o
2011-05-08 3:35 ` Andreas Dilger
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=4DC2EA94.8040100@redhat.com \
--to=sandeen@redhat.com \
--cc=adilger@dilger.ca \
--cc=linux-ext4@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).