linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ext4_fiemap gives 0 extents for files smaller than a block (patch included)
@ 2009-11-04 18:42 Leonard Michlmayr
  2009-11-04 19:44 ` Andreas Dilger
  0 siblings, 1 reply; 11+ messages in thread
From: Leonard Michlmayr @ 2009-11-04 18:42 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: Theodore Ts'o, linux-ext4, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 356 bytes --]

Fiemap (ioctl) does not return any extents for small files on ext4.
(fm_start=0, fm_length=filesize)

File affected: fs/ext4/extents.c

I found the reason of the bug: wrong rounding. It will not only affect
small files, but any request that overlaps an extent boundary by less
that blocksize.

The attached patch is against 2.6.32-rc5.

Leonard Michlmayr


[-- Attachment #2: ext4_fiemap_fix.patch --]
[-- Type: text/x-patch, Size: 745 bytes --]

diff -Naur linux-2.6.32-rc5/fs/ext4/extents.c linux-2.6.32-rc5.patched/fs/ext4/extents.c
--- linux-2.6.32-rc5/fs/ext4/extents.c	2009-10-16 02:41:50.000000000 +0200
+++ linux-2.6.32-rc5.patched/fs/ext4/extents.c	2009-11-04 19:35:44.000000000 +0100
@@ -3685,6 +3685,7 @@
 		__u64 start, __u64 len)
 {
 	ext4_lblk_t start_blk;
+	ext4_lblk_t end_blk;
 	ext4_lblk_t len_blks;
 	int error = 0;
 
@@ -3700,7 +3701,8 @@
 		error = ext4_xattr_fiemap(inode, fieinfo);
 	} else {
 		start_blk = start >> inode->i_sb->s_blocksize_bits;
-		len_blks = len >> inode->i_sb->s_blocksize_bits;
+		end_blk = (start + len - 1) >> inode->i_sb->s_blocksize_bits;
+		len_blks = end_blk - start_blk + 1;
 
 		/*
 		 * Walk the extent tree gathering extent information.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-02-15 22:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-04 18:42 ext4_fiemap gives 0 extents for files smaller than a block (patch included) Leonard Michlmayr
2009-11-04 19:44 ` Andreas Dilger
2009-11-04 21:44   ` Leonard Michlmayr
2010-02-08 13:54     ` Surbhi Palande
2010-02-12 18:42       ` [PATCH 2.6.32.7] ext4: number of blocks for fiemap Leonard Michlmayr
2010-02-12 21:49         ` Andreas Dilger
2010-02-12 23:20           ` Leonard Michlmayr
2010-02-15 19:50             ` tytso
2010-02-15 20:33               ` Eric Sandeen
2010-02-15 22:01                 ` tytso
2010-01-25 19:04   ` ext4_fiemap gives 0 extents for files smaller than a block (patch included) Leonard Michlmayr

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).