aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2009-05-02 19:05:37 -0400
committerTheodore Ts'o <tytso@mit.edu>2009-05-02 19:05:37 -0400
commiteefd7f03b86b8a319890e7fac5a6fcc7f8694b76 (patch)
treed8dd02626d522926b828042f87c0850d42f86d2e /fs/ext4
parentc9877b205f6ce7943bb95281342f4001cc1c00ec (diff)
ext4: fix the length returned by fiemap for an unallocated extent
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>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/extents.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 5f7295287de1..4fec6b746382 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3244,8 +3244,15 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
3244 * XXX this might miss a single-block extent at EXT_MAX_BLOCK 3244 * XXX this might miss a single-block extent at EXT_MAX_BLOCK
3245 */ 3245 */
3246 if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK || 3246 if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK ||
3247 newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK) 3247 newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK) {
3248 loff_t size = i_size_read(inode);
3249 loff_t bs = EXT4_BLOCK_SIZE(inode->i_sb);
3250
3248 flags |= FIEMAP_EXTENT_LAST; 3251 flags |= FIEMAP_EXTENT_LAST;
3252 if ((flags & FIEMAP_EXTENT_DELALLOC) &&
3253 logical+length > size)
3254 length = (size - logical + bs - 1) & ~(bs-1);
3255 }
3249 3256
3250 error = fiemap_fill_next_extent(fieinfo, logical, physical, 3257 error = fiemap_fill_next_extent(fieinfo, logical, physical,
3251 length, flags); 3258 length, flags);