Re: [PATCH 2/2] FIEMAP ioctl for ext4

Previous thread: [rfc][patches] remove ->prepare_write by Nick Piggin on Monday, November 12, 2007 - 3:12 am. (18 messages)

Next thread: [PATCH 1/2] Add FIEMAP header file by Kalpak Shah on Monday, November 12, 2007 - 5:00 pm. (2 messages)
To: linux-ext4 <linux-ext4@...>
Cc: linux-fsdevel <linux-fsdevel@...>, Andreas Dilger <adilger@...>, Eric Sandeen <sandeen@...>, <mark.fasheh@...>, <dgc@...>
Date: Monday, November 12, 2007 - 5:00 pm

Recently there was discussion about an "FIle Extent MAP"(FIEMAP) ioctl for efficiently mapping the extents and holes of a file. This will be many times more efficient than FIBMAP by cutting down the number of ioctls.

This patch adds the FIEMAP ioctl for ext4. The spec for the FIEMAP ioctl was posted earlier by Andreas Dilger and can be found at:
http://www.mail-archive.com/linux-ext4@vger.kernel.org/msg03944.html

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>

Index: linux-2.6.23.1/fs/ext4/ioctl.c
===================================================================
--- linux-2.6.23.1.orig/fs/ext4/ioctl.c
+++ linux-2.6.23.1/fs/ext4/ioctl.c
@@ -16,6 +16,7 @@
#include <linux/compat.h>
#include <linux/smp_lock.h>
#include <asm/uaccess.h>
+#include <linux/fiemap.h>

int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd,
unsigned long arg)
@@ -248,6 +249,9 @@ flags_err:

return err;
}
+ case EXT4_IOC_FIEMAP: {
+ return ext4_fiemap(inode, filp, cmd, arg);
+ }

default:
return -ENOTTY;
Index: linux-2.6.23.1/include/linux/ext4_fs.h
===================================================================
--- linux-2.6.23.1.orig/include/linux/ext4_fs.h
+++ linux-2.6.23.1/include/linux/ext4_fs.h
@@ -228,15 +228,20 @@ struct ext4_new_group_data {
#define EXT4_IOC_SETFLAGS FS_IOC_SETFLAGS
#define EXT4_IOC_GETVERSION _IOR('f', 3, long)
#define EXT4_IOC_SETVERSION _IOW('f', 4, long)
+#define EXT4_IOC_GETRSVSZ _IOR('f', 5, long)
+#define EXT4_IOC_SETRSVSZ _IOW('f', 6, long)
#define EXT4_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
#define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input)
+#define EXT4_IOC_FIEMAP _IOWR('f', 10, struct fiemap)
#define EXT4_IOC_GETVERSION_OLD FS_IOC_GETVERSION
#define EXT4_IOC_SETVERSION_OLD FS_IOC_SETVERSION
#ifdef CONFIG_JBD2_DEBUG
#define EXT4_IOC_WAIT_FOR_READONLY _IOR('f', 99, long)
#endif
-#de...

To: Kalpak Shah <Kalpak.Shah@...>
Cc: linux-ext4 <linux-ext4@...>, linux-fsdevel <linux-fsdevel@...>, Andreas Dilger <adilger@...>, Eric Sandeen <sandeen@...>, <mark.fasheh@...>, <dgc@...>
Date: Monday, November 12, 2007 - 11:54 pm

Please make this common - we dont want a new ioctl for every

Most of this function will be common to all IOC_FIEMAP

struct address_space *mapping = filp->f_mapping;

if (!mapping->a_ops->fiemap)

The common form is:

if (fiemap_s->fm_flags & FIEMAP_FLAG_SYNC)

This becomes:

error = mapping->a_ops->fiemap(inode, ....);

and the lock, extent walk, etc becomes ext4_fiemap() which is set up
in the a_ops for the filesystem. Any filesystems specific checks go

That's common, too.

I don't want to see this implemented over and over again with minute
variations and bugs. The common implementation should be called from
in do_file_ioctl() like FIBMAP....

Cheers,

Dave.
--
Dave Chinner
Principal Engineer
SGI Australian Software Group
-

Previous thread: [rfc][patches] remove ->prepare_write by Nick Piggin on Monday, November 12, 2007 - 3:12 am. (18 messages)

Next thread: [PATCH 1/2] Add FIEMAP header file by Kalpak Shah on Monday, November 12, 2007 - 5:00 pm. (2 messages)