Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp822486ybl; Wed, 11 Dec 2019 08:03:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzH3gOssUuTV6R/GRtjsBX7K30s1WaLE9AWWRO3BeeaBJz9yFlli1i4Woo4w/sc2agzwSFy X-Received: by 2002:a05:6830:20d3:: with SMTP id z19mr2591143otq.330.1576080190055; Wed, 11 Dec 2019 08:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576080190; cv=none; d=google.com; s=arc-20160816; b=Hp0T6xKtg14YzehNSdtiuZn+RrowR7P+KFaqvwLhQxzZPpCA5pfR69VP571u1ANHNC +y2losXH48c8yyeqxPXgrD8AFwoAN6Mc8w3rHh18Y90F6ETWCSjx2/aZVtgUA7KxpaVz R2e7QTXXBQV8yWV/a+nGo1bTnXiHVc69feBKPK6mue9xOt5S2nYkCjhNbfbfGceR66z1 3RgGmjQwXJdKsi9B9bUOGlyAxHBot/MLdHQFH0FpkORBTEngZ9H26+rGDdJWv6u3Ze9i S+IpIhkp60ip7MjgKuYqg+vTtjLD16cYaUttc4T2Cl1MfQAFVYMrbMzVLbuQZdAvAqa0 ApVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qb8cpNlYIVhL7ZRZoFU3QOBMu82rv5lQpBYv0Y+ciVw=; b=vdzn3t3b+8d2cEZ6LFwjhR8oPvDLmUzIbhd8WpXuOcWdcOYSZ46pSdzcb+wKqam+Fh 2yVQe/+VqS47eXut5z3DnboKjpQW8wjQnRavjytovoAM04NhfJbE0muvJ2RBltAjCYmy EuGz/a5BIgSYH1NOAWoEO5TvMnhv/85em3GDNw4VbxrxNHRSFW8um9n73NZcQLiKUnhZ pN9rnZHt+GyTSnSJ4sed6lYSM0PQ10Z1ikTzofcWt4j+ZXa+wXTq7Z6C8Mxy8+tXr4gf CHxeEv4vlj92L/swj/GkVyre0c6S+xXmpFquxfzctwA5D1dIa1hkhyMwgIZXZu0duzpc yNVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZKpPVzOo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si1232472ote.187.2019.12.11.08.02.54; Wed, 11 Dec 2019 08:03:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZKpPVzOo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731721AbfLKQAA (ORCPT + 99 others); Wed, 11 Dec 2019 11:00:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:38356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731536AbfLKPN5 (ORCPT ); Wed, 11 Dec 2019 10:13:57 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E948C24654; Wed, 11 Dec 2019 15:13:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077237; bh=LGW7v87sNgdj7lp4cac8DXf/BuQaHXMOQQGoLFkmpZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZKpPVzOo9XpfVsE460KoARdwU5mpvXWOcrRDZSEVflB3doKmuUBSj8lkcFxMHXrXg cVzdxDW+8TRRgR+9godw0ZQWy+7PUV/9VT77+Dg5gTgZdfoGP32z161OCReL1ipU9b od0hKycPVJUMrG7p8bH+L2aUqocWzeMh6sfTDdnc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , "J. Bruce Fields" Subject: [PATCH 5.3 068/105] nfsd: Ensure CLONE persists data and metadata changes to the target file Date: Wed, 11 Dec 2019 16:05:57 +0100 Message-Id: <20191211150249.287893236@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust commit a25e3726b32c746c0098125d4c7463bb84df72bb upstream. The NFSv4.2 CLONE operation has implicit persistence requirements on the target file, since there is no protocol requirement that the client issue a separate operation to persist data. For that reason, we should call vfs_fsync_range() on the destination file after a successful call to vfs_clone_file_range(). Fixes: ffa0160a1039 ("nfsd: implement the NFSv4.2 CLONE operation") Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.5+ Signed-off-by: J. Bruce Fields Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4proc.c | 3 ++- fs/nfsd/vfs.c | 8 +++++++- fs/nfsd/vfs.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1083,7 +1083,8 @@ nfsd4_clone(struct svc_rqst *rqstp, stru goto out; status = nfsd4_clone_file_range(src, clone->cl_src_pos, - dst, clone->cl_dst_pos, clone->cl_count); + dst, clone->cl_dst_pos, clone->cl_count, + EX_ISSYNC(cstate->current_fh.fh_export)); fput(dst); fput(src); --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -552,7 +552,7 @@ __be32 nfsd4_set_nfs4_label(struct svc_r #endif __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, - u64 dst_pos, u64 count) + u64 dst_pos, u64 count, bool sync) { loff_t cloned; @@ -561,6 +561,12 @@ __be32 nfsd4_clone_file_range(struct fil return nfserrno(cloned); if (count && cloned != count) return nfserrno(-EINVAL); + if (sync) { + loff_t dst_end = count ? dst_pos + count - 1 : LLONG_MAX; + int status = vfs_fsync_range(dst, dst_pos, dst_end, 0); + if (status < 0) + return nfserrno(status); + } return 0; } --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -58,7 +58,7 @@ __be32 nfsd4_set_nfs4_label(str __be32 nfsd4_vfs_fallocate(struct svc_rqst *, struct svc_fh *, struct file *, loff_t, loff_t, int); __be32 nfsd4_clone_file_range(struct file *, u64, struct file *, - u64, u64); + u64, u64, bool); #endif /* CONFIG_NFSD_V4 */ __be32 nfsd_create_locked(struct svc_rqst *, struct svc_fh *, char *name, int len, struct iattr *attrs,