From patchwork Tue Aug 25 15:33:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 7071671 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 77617C05AC for ; Tue, 25 Aug 2015 15:35:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6A8620896 for ; Tue, 25 Aug 2015 15:35:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C45D7204EA for ; Tue, 25 Aug 2015 15:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932665AbbHYPfh (ORCPT ); Tue, 25 Aug 2015 11:35:37 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:34718 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932416AbbHYPfg (ORCPT ); Tue, 25 Aug 2015 11:35:36 -0400 Received: by pabzx8 with SMTP id zx8so36956829pab.1 for ; Tue, 25 Aug 2015 08:35:36 -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=83j6mUFhsKXZdjCqDSeJdvDqMc7EKOpugC75x68HzQA=; b=HvQq/uz8P7fnDbRNs1Umoh6tmBhpiYW59fHK7uXVckhFS9Gvfp2RlYhNA/o8t2+cXt AZoxiI3p4oan1sGC1aNz48Jrv1jHVWAg6sqDvdakpkZW+CBeuqOzH5YAyEWFvC6Gixm/ MxtMRHldNGt1hZlm+KXcrDp89/QYPNy1P/Zt+IVcCXK7stxtWiS5kUZl7nw8qQvXSJB/ JJLfErO4KgQzjyPaXIlEyKt5EBtehSuGPzrejlHMLE4SqM6z2LFdn/6e5DHo/k5cWLXP uYJd2ii3n6JsT0pJ0Mgz9d6015X5pc07xD1MJWSgDNdQXGDEpRtt92CQddjAZ75ZMJ5p dFNw== X-Gm-Message-State: ALoCoQmuHA8cs1TVG9WFYQPSgFCgjvPOyJt7ylAC2mhJxvICrpFwB6kjB58PozxqGpTeFPzOIrW8 X-Received: by 10.66.100.193 with SMTP id fa1mr2418724pab.3.1440516936167; Tue, 25 Aug 2015 08:35:36 -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 hu13sm21462120pdb.72.2015.08.25.08.35.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Aug 2015 08:35:35 -0700 (PDT) From: Peng Tao To: linux-nfs@vger.kernel.org Cc: Trond Myklebust , Anna Schumaker , Christoph Hellwig , Zach Brown , Darren Hart , bfields@fieldses.org, Jeff Layton , Peng Tao Subject: [PATCH RFC 09/11] nfs42: respect clone_blksize Date: Tue, 25 Aug 2015 23:33:47 +0800 Message-Id: <1440516829-116041-10-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1440516829-116041-1-git-send-email-tao.peng@primarydata.com> References: <1440516829-116041-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.2 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 draft-ietf-nfsv4-minorversion2-38.txt says: Both cl_src_offset and cl_dst_offset must be aligned to the clone block size Section 12.2.1. The number of bytes to be cloned must be a multiple of the clone block size, except in the case in which cl_src_offset plus the number of bytes to be cloned is equal to the source file size. Signed-off-by: Peng Tao --- fs/nfs/nfs4file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index c335cb0..ee8c014 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -174,12 +174,20 @@ nfs42_file_clone_range(struct file *src_file, struct file *dst_file, { struct inode *dst_inode = file_inode(dst_file); struct inode *src_inode = file_inode(src_file); + struct nfs_server *server = NFS_SERVER(dst_inode); + unsigned int bs = server->clone_blksize; int ret; /* src and dst must be different files */ if (src_inode == dst_inode) return -EINVAL; + /* check alignment w.r.t. clone_blksize */ + if (bs) + if (!IS_ALIGNED(src_off, bs) || !IS_ALIGNED(dst_off, bs) || + (!IS_ALIGNED(count, bs) && i_size_read(src_inode) != (src_off + count))) + return -EINVAL; + /* XXX: do we lock at all? what if server needs CB_RECALL_LAYOUT? */ if (dst_inode < src_inode) { mutex_lock_nested(&dst_inode->i_mutex, I_MUTEX_PARENT);