Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9877b20 authored by Eric Sandeen's avatar Eric Sandeen Committed by Theodore Ts'o
Browse files

ext4: fix for fiemap last-block test



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: default avatarEric Sandeen <sandeen@redhat.com>
Reported-by: default avatarCarl Henrik Lunde <chlunde@ping.uio.no>
Tested-by: default avatarCarl Henrik Lunde <chlunde@ping.uio.no>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent 19ba0559
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -3196,7 +3196,7 @@ static int ext4_ext_fiemap_cb(struct inode *inode, struct ext4_ext_path *path,
		       void *data)
		       void *data)
{
{
	struct fiemap_extent_info *fieinfo = 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	logical;
	__u64	physical;
	__u64	physical;
	__u64	length;
	__u64	length;
@@ -3243,8 +3243,8 @@ 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
	 * XXX this might miss a single-block extent at EXT_MAX_BLOCK
	 */
	 */
	if (logical + length - 1 == EXT_MAX_BLOCK ||
	if (ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK ||
	    ext4_ext_next_allocated_block(path) == EXT_MAX_BLOCK)
	    newex->ec_block + newex->ec_len - 1 == EXT_MAX_BLOCK)
		flags |= FIEMAP_EXTENT_LAST;
		flags |= FIEMAP_EXTENT_LAST;


	error = fiemap_fill_next_extent(fieinfo, logical, physical,
	error = fiemap_fill_next_extent(fieinfo, logical, physical,