Skip to content

Commit

Permalink
fs: make block fiemap mapping length at least blocksize long
Browse files Browse the repository at this point in the history
Some filesystems don't deal well with being asked to map less than
blocksize blocks (GFS2 for example).  Since we are always mapping at least
blocksize sections anyway, just make sure len is at least as big as a
blocksize so we don't trip up any filesystems.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Cc: Steven Whitehouse <swhiteho@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Josef Bacik authored and Linus Torvalds committed Feb 3, 2011
1 parent 3cd90ea commit d54cdc8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,13 @@ int __generic_block_fiemap(struct inode *inode,
len = isize;
}

/*
* Some filesystems can't deal with being asked to map less than
* blocksize, so make sure our len is at least block length.
*/
if (logical_to_blk(inode, len) == 0)
len = blk_to_logical(inode, 1);

start_blk = logical_to_blk(inode, start);
last_blk = logical_to_blk(inode, start + len - 1);

Expand Down

0 comments on commit d54cdc8

Please sign in to comment.