* [PATCH] ext4: fix for fiemap last-block test
@ 2009-04-28 15:58 Eric Sandeen
2009-05-02 23:08 ` Theodore Tso
0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2009-04-28 15:58 UTC (permalink / raw)
To: ext4 development; +Cc: Carl Henrik Lunde
Carl Henrik Lunde reported and debugged this; the test for the
last allocated block was comparing bytes to blocks in this test:
if (logical + length - 1 == EXT_MAX_BLOCK ||
ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
flags |= FIEMAP_EXTENT_LAST;
so any extent which ended right at 4G was stopping the extent
walk. Just replacing these values with the extent block &
length should fix it.
Also give blksize_bits a saner type, and reverse the order
of the tests to make the more likely case tested first.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reported-by: Carl Henrik Lunde <chlunde@ping.uio.no>
Tested-by: Carl Henrik Lunde <chlunde@ping.uio.no>
---
Index: linux-2.6.29.x86_64/fs/ext4/extents.c
===================================================================
--- linux-2.6.29.x86_64.orig/fs/ext4/extents.c
+++ linux-2.6.29.x86_64/fs/ext4/extents.c
@@ -3087,7 +3087,7 @@ static int ext4_ext_fiemap_cb(struct ino
void *data)
{
struct fiemap_extent_info *fieinfo = data;
- unsigned long blksize_bits = inode->i_sb->s_blocksize_bits;
+ unsigned char blksize_bits = inode->i_sb->s_blocksize_bits;
__u64 logical;
__u64 physical;
__u64 length;
@@ -3134,8 +3134,8 @@ static int ext4_ext_fiemap_cb(struct ino
*
* XXX this might miss a single-block extent at EXT_MAX_BLOCK
*/
- if (logical + length - 1 == EXT_MAX_BLOCK ||
- ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
+ if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK ||
+ newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK)
flags |= FIEMAP_EXTENT_LAST;
error = fiemap_fill_next_extent(fieinfo, logical, physical,
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ext4: fix for fiemap last-block test
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 ` [PATCH] ext4: fix the length returned by fiemap for an unallocated extent Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Theodore Tso @ 2009-05-02 23:08 UTC (permalink / raw)
To: Eric Sandeen; +Cc: ext4 development, Carl Henrik Lunde
Thanks, I've pulled this into the ext4 patch queue. While I was
testing this, I found an additional bug in ext4's fiemap handling.
I'll post that fix as a reply to this message.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] ext4: fix the length returned by fiemap for an unallocated extent
2009-05-02 23:08 ` Theodore Tso
@ 2009-05-02 23:10 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2009-05-02 23:10 UTC (permalink / raw)
To: Ext4 Developers List; +Cc: Eric Sandeen, Carl Henrik Lunde, Theodore Ts'o
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-02 23:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH] ext4: fix the length returned by fiemap for an unallocated extent Theodore Ts'o
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).