All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Tao <tao.peng@primarydata.com>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: linux-nfs@vger.kernel.org,
	Anna Schumaker <anna.schumaker@netapp.com>,
	Christoph Hellwig <hch@infradead.org>,
	Peng Tao <tao.peng@primarydata.com>
Subject: [PATCH 6/6] nfs42: add NFS_IOC_CLONE_RANGE ioctl
Date: Sat, 26 Sep 2015 02:24:39 +0800	[thread overview]
Message-ID: <1443205479-13563-7-git-send-email-tao.peng@primarydata.com> (raw)
In-Reply-To: <1443205479-13563-1-git-send-email-tao.peng@primarydata.com>

It follows btrfs BTRFS_IOC_CLONE_RANGE lead on ioctl number and
arguments.

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
---
 fs/nfs/nfs4file.c        | 14 ++++++++++++++
 include/uapi/linux/nfs.h |  9 ++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index 4f463dd..4384a1d 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -288,14 +288,28 @@ out_drop_write:
 	mnt_drop_write_file(dst_file);
 	return ret;
 }
+
+static long nfs42_ioctl_clone_range(struct file *dst_file, void __user *argp)
+{
+	struct nfs_ioctl_clone_range_args args;
+
+	if (copy_from_user(&args, argp, sizeof(args)))
+		return -EFAULT;
+
+	return nfs42_ioctl_clone(dst_file, args.src_fd, args.src_off, args.dst_off, args.count);
+}
 #endif /* CONFIG_NFS_V4_2 */
 
 long nfs4_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
+	void __user *argp = (void __user *)arg;
+
 	switch (cmd) {
 #ifdef CONFIG_NFS_V4_2
 	case NFS_IOC_CLONE:
 		return nfs42_ioctl_clone(file, arg, 0, 0, 0);
+	case NFS_IOC_CLONE_RANGE:
+		return nfs42_ioctl_clone_range(file, argp);
 #endif
 	}
 
diff --git a/include/uapi/linux/nfs.h b/include/uapi/linux/nfs.h
index d85748d..c6b86cc 100644
--- a/include/uapi/linux/nfs.h
+++ b/include/uapi/linux/nfs.h
@@ -33,7 +33,14 @@
 
 /* NFS ioctls */
 /* Let's follow btrfs lead on CLONE to avoid messing userspace */
-#define NFS_IOC_CLONE	_IOW(0x94, 9, int)
+#define NFS_IOC_CLONE		_IOW(0x94, 9, int)
+#define NFS_IOC_CLONE_RANGE	_IOW(0x94, 13, int)
+
+struct nfs_ioctl_clone_range_args {
+	__s64 src_fd;
+	__u64 src_off, count;
+	__u64 dst_off;
+};
 
 /*
  * NFS stats. The good thing with these values is that NFSv3 errors are
-- 
1.8.3.1


  parent reply	other threads:[~2015-09-25 10:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-25 18:24 [PATCH 0/6] nfs: add NFSv42 CLONE support Peng Tao
2015-09-25 18:24 ` [PATCH 1/6] nfs42: add CLONE xdr functions Peng Tao
2015-09-25 18:24 ` [PATCH 2/6] nfs42: add CLONE proc functions Peng Tao
2015-09-25 18:24 ` [PATCH 3/6] nfs42: add NFS_IOC_CLONE ioctl Peng Tao
2015-09-25 18:24 ` [PATCH 4/6] nfs: get clone_blksize when probing fsinfo Peng Tao
2015-09-25 18:24 ` [PATCH 5/6] nfs42: respect clone_blksize Peng Tao
2015-09-25 18:24 ` Peng Tao [this message]
2015-09-28  6:07   ` [PATCH 6/6] nfs42: add NFS_IOC_CLONE_RANGE ioctl kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443205479-13563-7-git-send-email-tao.peng@primarydata.com \
    --to=tao.peng@primarydata.com \
    --cc=anna.schumaker@netapp.com \
    --cc=hch@infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@primarydata.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.