From patchwork Mon Jul 13 09:06:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 6776371 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 33072C05AC for ; Mon, 13 Jul 2015 09:07:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5404220678 for ; Mon, 13 Jul 2015 09:07:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 655A62063C for ; Mon, 13 Jul 2015 09:07:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752400AbbGMJHg (ORCPT ); Mon, 13 Jul 2015 05:07:36 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33551 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751451AbbGMJHf (ORCPT ); Mon, 13 Jul 2015 05:07:35 -0400 Received: by padck2 with SMTP id ck2so39614322pad.0 for ; Mon, 13 Jul 2015 02:07:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OQDaL1KP7zhS8vfgWfM7W6avX/2oyR1ngV13AzxrHew=; b=K0rXoufzJTXRVj8cJtKKKjtg0PncpwTYPhmbWN86Xqo++I3EI+zLuuWl1rjY9fAphK lwE2d18AWPfKY6XCOW07hC8MTpkwqdYIWX8Zlfn4/HKZzmcObN5quPRFRQftRjU9SLoU oYFvOcYF29psdygw8s26DVubiZmcUHmpArU+VBtzcJWYOS5087whxYE/+8wAdup4VWZF 4ZOi8RKf6vlX34J+pY7lesYaeg5U9Rp4Nx60ccSXoz0+9MqQceElQAJCY81CiA3yxs3H GXS9WCsa5bYm1PnBYaWbdw2tvZbKlWiK5kVaaNDgfG2mQ0dU6xtIP0tFjaFyNOJAmbtA eNNg== X-Gm-Message-State: ALoCoQm362amuPsMTiuJAU4KLI+9qTqSkBCyyjcJ8ceot0b3rMhS3DfKCbm8MSymY5eqkJEzxSuS X-Received: by 10.68.211.33 with SMTP id mz1mr36345238pbc.41.1436778454467; Mon, 13 Jul 2015 02:07:34 -0700 (PDT) Received: from lear.localdomain (ec2-54-65-164-9.ap-northeast-1.compute.amazonaws.com. [54.65.164.9]) by smtp.gmail.com with ESMTPSA id dp1sm17692664pbb.53.2015.07.13.02.07.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jul 2015 02:07:33 -0700 (PDT) From: Peng Tao To: linux-nfs@vger.kernel.org Cc: Trond Myklebust , Anna Schumaker , Peng Tao Subject: [PATCH v2 8/8] nfs42: add NFS_IOC_CLONE_RANGE ioctl Date: Mon, 13 Jul 2015 17:06:08 +0800 Message-Id: <1436778368-65447-9-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1436778368-65447-1-git-send-email-tao.peng@primarydata.com> References: <1436778368-65447-1-git-send-email-tao.peng@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It follows btrfs BTRFS_IOC_CLONE_RANGE lead on ioctl number and arguments. Signed-off-by: Peng Tao --- 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 e450a5f..f37b74c 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -262,14 +262,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