fs/compat_ioctl.c: add missing FS_IOC_FIEMAP support

Submitted by Mark Lord on Aug. 1, 2009, 2:59 p.m.

Details

Message ID 4A74584D.2010300@rtr.ca
State Superseded, archived
Headers show

Commit Message

Mark Lord Aug. 1, 2009, 2:59 p.m.
Add support for the FIEMAP ioctl for 32-bit user on 64-bit kernel.

When using a 32-bit runtime on top of a 64-bit kernel,
programs like "filefrag" and "hdparm --fibmap" do not work correctly.

This is because there's no compat ioctl entry for the FIEMAP call.
FIEMAP returns file extent info, similar to FIBMAP (but better).

Since FIBMAP itself is b0rked on ext4, this leaves no way for a 32-bit
program to reliably get detailed block information for a file
when run on top of a 64-bit kernel.  This patch addresses the issue.

Once upstream, this patch could also be a candidate for -stable.

Signed-off-by: Mark Lord <mlord@pobox.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Mark Lord Aug. 1, 2009, 3:17 p.m.
Mark Lord wrote:
..
> Since FIBMAP itself is b0rked on ext4, this leaves no way for a 32-bit
..

To stave off the inevitable question, FIBMAP doesn't appear to cope well
with allocated/uncommitted blocks.  Creating a file with fallocate(),
and then immediately running FIBMAP, will not give any allocation data.

Doing a sync() after the fallocate() allows FIBMAP to work again.

FIEMAP doesn't require the sync().

Cheers
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch hide | download patch | download mbox

--- old/fs/compat_ioctl.c	2009-08-01 10:47:16.601066905 -0400
+++ linux/fs/compat_ioctl.c	2009-08-01 10:49:23.054387926 -0400
@@ -35,6 +35,7 @@ 
 #include <linux/falloc.h>
 #include <linux/fs.h>
 #include <linux/file.h>
+#include <linux/fiemap.h>
 #include <linux/ppp_defs.h>
 #include <linux/if_ppp.h>
 #include <linux/if_pppox.h>
@@ -1907,6 +1908,7 @@ 
 COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
 /* 0x00 */
 COMPATIBLE_IOCTL(FIBMAP)
+COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
 COMPATIBLE_IOCTL(FIGETBSZ)
 /* 'X' - originally XFS but some now in the VFS */
 COMPATIBLE_IOCTL(FIFREEZE)
@@ -2805,6 +2807,7 @@ 
 		goto out_fput;
 #endif
 
+	case FS_IOC_FIEMAP:
 	case FIBMAP:
 	case FIGETBSZ:
 	case FIONREAD: