linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Trond Myklebust <trondmy@gmail.com>,
	Dave Chinner <david@fromorbit.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	"J . Bruce Fields" <bfields@redhat.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-nfs@vger.kernel.org
Subject: [PATCH AUTOSEL 5.5 238/542] nfsd: Clone should commit src file metadata too
Date: Fri, 14 Feb 2020 10:43:50 -0500	[thread overview]
Message-ID: <20200214154854.6746-238-sashal@kernel.org> (raw)
In-Reply-To: <20200214154854.6746-1-sashal@kernel.org>

From: Trond Myklebust <trondmy@gmail.com>

[ Upstream commit 57f64034966fb945fc958f95f0c51e47af590344 ]

vfs_clone_file_range() can modify the metadata on the source file too,
so we need to commit that to stable storage as well.

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Acked-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/nfsd/vfs.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index f0bca0e87d0c4..82cf80dde5c71 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -280,19 +280,25 @@ nfsd_lookup(struct svc_rqst *rqstp, struct svc_fh *fhp, const char *name,
  * Commit metadata changes to stable storage.
  */
 static int
-commit_metadata(struct svc_fh *fhp)
+commit_inode_metadata(struct inode *inode)
 {
-	struct inode *inode = d_inode(fhp->fh_dentry);
 	const struct export_operations *export_ops = inode->i_sb->s_export_op;
 
-	if (!EX_ISSYNC(fhp->fh_export))
-		return 0;
-
 	if (export_ops->commit_metadata)
 		return export_ops->commit_metadata(inode);
 	return sync_inode_metadata(inode, 1);
 }
 
+static int
+commit_metadata(struct svc_fh *fhp)
+{
+	struct inode *inode = d_inode(fhp->fh_dentry);
+
+	if (!EX_ISSYNC(fhp->fh_export))
+		return 0;
+	return commit_inode_metadata(inode);
+}
+
 /*
  * Go over the attributes and take care of the small differences between
  * NFS semantics and what Linux expects.
@@ -537,6 +543,9 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst,
 	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)
+			status = commit_inode_metadata(file_inode(src));
 		if (status < 0)
 			return nfserrno(status);
 	}
-- 
2.20.1


  parent reply	other threads:[~2020-02-14 18:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200214154854.6746-1-sashal@kernel.org>
2020-02-14 15:40 ` [PATCH AUTOSEL 5.5 009/542] nfsd4: avoid NULL deference on strange COPY compounds Sasha Levin
2020-02-14 15:41 ` [PATCH AUTOSEL 5.5 077/542] nfs: NFS_SWAP should depend on SWAP Sasha Levin
2020-02-14 15:43 ` [PATCH AUTOSEL 5.5 223/542] nfs: fix timstamp debug prints Sasha Levin
2020-02-14 15:43 ` Sasha Levin [this message]
2020-02-14 15:45 ` [PATCH AUTOSEL 5.5 366/542] NFS: Revalidate the file size on a fatal write error Sasha Levin
2020-02-14 15:45 ` [PATCH AUTOSEL 5.5 367/542] NFS/pnfs: Fix pnfs_generic_prepare_to_resend_writes() Sasha Levin
2020-02-14 15:46 ` [PATCH AUTOSEL 5.5 368/542] NFS: Fix fix of show_nfs_errors Sasha Levin
2020-02-14 15:46 ` [PATCH AUTOSEL 5.5 369/542] NFSv4.x recover from pre-mature loss of openstateid Sasha Levin
2020-02-14 15:47 ` [PATCH AUTOSEL 5.5 440/542] sunrpc: Fix potential leaks in sunrpc_cache_unhash() Sasha Levin
2020-02-14 15:48 ` [PATCH AUTOSEL 5.5 520/542] NFSv4: pnfs_roc() must use cred_fscmp() to compare creds Sasha Levin
2020-02-14 15:48 ` [PATCH AUTOSEL 5.5 531/542] NFS: Fix memory leaks Sasha Levin
2020-02-14 15:48 ` [PATCH AUTOSEL 5.5 532/542] NFSv4: try lease recovery on NFS4ERR_EXPIRED Sasha Levin
2020-02-14 15:48 ` [PATCH AUTOSEL 5.5 533/542] NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals Sasha Levin

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=20200214154854.6746-238-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=bfields@redhat.com \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    --cc=trondmy@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).