Add metadata readahead ioctl in vfs. Filesystem can hook to
super_operations.metadata_readahead to handle filesystem specific task.
Next patch will give an example how btrfs implements it.
Signed-off-by: Shaohua Li <shaohua.li@intel.com>
---
fs/compat_ioctl.c | 1 +
fs/ioctl.c | 21 +++++++++++++++++++++
include/linux/fs.h | 8 ++++++++
3 files changed, 30 insertions(+)
Index: linux/fs/ioctl.c
===================================================================
--- linux.orig/fs/ioctl.c 2011-01-03 21:15:48.000000000 +0800
+++ linux/fs/ioctl.c 2011-01-03 21:16:06.000000000 +0800
@@ -601,6 +601,24 @@ static int ioctl_metadata_incore(struct
return entries;
}
+static int ioctl_metadata_readahead(struct file *filp, void __user *argp)
+{
+ struct super_block *sb = filp->f_path.dentry->d_inode->i_sb;
+ struct metadata_readahead_args args;
+
+ if (!sb->s_op->metadata_readahead)
+ return -EINVAL;
+
+ if (copy_from_user(&args, argp, sizeof(args)))
+ return -EFAULT;
+
+ /* readahead in page unit */
+ if ((args.offset & ~PAGE_CACHE_MASK) || (args.size & ~PAGE_CACHE_MASK))
+ return -EINVAL;
+
+ return sb->s_op->metadata_readahead(sb, args.offset, args.size);
+}
+
/*
* When you add any new common ioctls to the switches above and below
* please update compat_sys_ioctl() too.
@@ -664,6 +682,9 @@ int do_vfs_ioctl(struct file *filp, unsi
case FIMETADATA_INCORE:
return ioctl_metadata_incore(filp, argp);
+ case FIMETADATA_READAHEAD:
+ return ioctl_metadata_readahead(filp, argp);
+
default:
if (S_ISREG(filp->f_path.dentry->d_inode->i_mode))
error = file_ioctl(filp, cmd, arg);
Index: linux/include/linux/fs.h
===================================================================
--- linux.orig/include/linux/fs.h 2011-01-03 21:15:48.000000000 +0800
+++ linux/include/linux/fs.h 2011-01-03 21:16:06.000000000 +0800
@@ -65,6 +65,11 @@ struct metadata_incore_args {
__u32 unused;
};
+struct metadata_readahead_args {
+ __u64 ...