aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Tao <tao.peng@primarydata.com>2015-09-25 14:24:39 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-10-15 16:08:33 -0400
commita340abcf4173461f688292a6879b4d5bc781c2b1 (patch)
tree30dc469f9535e3bd5c1882119212f1c06036cef8
parent811b7b85d6641df580a6c43184cf13d6fcc7498d (diff)
nfs42: add NFS_IOC_CLONE_RANGE ioctl
It follows btrfs BTRFS_IOC_CLONE_RANGE lead on ioctl number and arguments. Signed-off-by: Peng Tao <tao.peng@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/nfs4file.c14
-rw-r--r--include/uapi/linux/nfs.h9
2 files changed, 22 insertions, 1 deletions
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 4f463dd8bae3..4384a1d00ceb 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -288,14 +288,28 @@ out_drop_write:
288 mnt_drop_write_file(dst_file); 288 mnt_drop_write_file(dst_file);
289 return ret; 289 return ret;
290} 290}
291
292static long nfs42_ioctl_clone_range(struct file *dst_file, void __user *argp)
293{
294 struct nfs_ioctl_clone_range_args args;
295
296 if (copy_from_user(&args, argp, sizeof(args)))
297 return -EFAULT;
298
299 return nfs42_ioctl_clone(dst_file, args.src_fd, args.src_off, args.dst_off, args.count);
300}
291#endif /* CONFIG_NFS_V4_2 */ 301#endif /* CONFIG_NFS_V4_2 */
292 302
293long nfs4_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 303long nfs4_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
294{ 304{
305 void __user *argp = (void __user *)arg;
306
295 switch (cmd) { 307 switch (cmd) {
296#ifdef CONFIG_NFS_V4_2 308#ifdef CONFIG_NFS_V4_2
297 case NFS_IOC_CLONE: 309 case NFS_IOC_CLONE:
298 return nfs42_ioctl_clone(file, arg, 0, 0, 0); 310 return nfs42_ioctl_clone(file, arg, 0, 0, 0);
311 case NFS_IOC_CLONE_RANGE:
312 return nfs42_ioctl_clone_range(file, argp);
299#endif 313#endif
300 } 314 }
301 315
diff --git a/include/uapi/linux/nfs.h b/include/uapi/linux/nfs.h
index d85748d3564d..c6b86cc404f8 100644
--- a/include/uapi/linux/nfs.h
+++ b/include/uapi/linux/nfs.h
@@ -33,7 +33,14 @@
33 33
34/* NFS ioctls */ 34/* NFS ioctls */
35/* Let's follow btrfs lead on CLONE to avoid messing userspace */ 35/* Let's follow btrfs lead on CLONE to avoid messing userspace */
36#define NFS_IOC_CLONE _IOW(0x94, 9, int) 36#define NFS_IOC_CLONE _IOW(0x94, 9, int)
37#define NFS_IOC_CLONE_RANGE _IOW(0x94, 13, int)
38
39struct nfs_ioctl_clone_range_args {
40 __s64 src_fd;
41 __u64 src_off, count;
42 __u64 dst_off;
43};
37 44
38/* 45/*
39 * NFS stats. The good thing with these values is that NFSv3 errors are 46 * NFS stats. The good thing with these values is that NFSv3 errors are