From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Eric Sandeen <sandeen@redhat.com>,
Carl Henrik Lunde <chlunde@ping.uio.no>,
Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH] ext4: fix the length returned by fiemap for an unallocated extent
Date: Sat, 2 May 2009 19:10:46 -0400 [thread overview]
Message-ID: <1241305846-12972-1-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <20090502230813.GC22191@mit.edu>
If the file's blocks have not yet been allocated because of delayed
allocation, the length of the extent returned by fiemap is incorrect.
This commit fixes this bug.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
fs/ext4/extents.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 86c64ea..e963870 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3234,8 +3234,15 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
* XXX this might miss a single-block extent at EXT_MAX_BLOCK
*/
if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK ||
- newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK)
+ newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK) {
+ loff_t size = i_size_read(inode);
+ loff_t bs = EXT4_BLOCK_SIZE(inode->i_sb);
+
flags |= FIEMAP_EXTENT_LAST;
+ if ((flags & FIEMAP_EXTENT_DELALLOC) &&
+ logical+length > size)
+ length = (size - logical + bs - 1) & ~(bs-1);
+ }
error = fiemap_fill_next_extent(fieinfo, logical, physical,
length, flags);
--
1.6.0.4
prev parent reply other threads:[~2009-05-02 23:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-28 15:58 [PATCH] ext4: fix for fiemap last-block test Eric Sandeen
2009-05-02 23:08 ` Theodore Tso
2009-05-02 23:10 ` Theodore Ts'o [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=1241305846-12972-1-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=chlunde@ping.uio.no \
--cc=linux-ext4@vger.kernel.org \
--cc=sandeen@redhat.com \
/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).