Linux-NFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] nfsd: Clone should commit src file metadata too
@ 2019-12-18 19:57 Trond Myklebust
  2019-12-18 21:12 ` Dave Chinner
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2019-12-18 19:57 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Dave Chinner, linux-nfs

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>
---

 v2: Reverse order of vfs_fsync_range()/commit_inode_metadata() for
     efficiency as suggested by Dave Chinner.

 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 f0bca0e87d0c..82cf80dde5c7 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.23.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] nfsd: Clone should commit src file metadata too
  2019-12-18 19:57 [PATCH v2] nfsd: Clone should commit src file metadata too Trond Myklebust
@ 2019-12-18 21:12 ` Dave Chinner
  2019-12-19 22:44   ` bfields
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2019-12-18 21:12 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: J. Bruce Fields, linux-nfs

On Wed, Dec 18, 2019 at 02:57:23PM -0500, Trond Myklebust wrote:
> 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>

Looks ok to me now.

Acked-by: Dave Chinner <dchinner@redhat.com>

-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] nfsd: Clone should commit src file metadata too
  2019-12-18 21:12 ` Dave Chinner
@ 2019-12-19 22:44   ` bfields
  0 siblings, 0 replies; 3+ messages in thread
From: bfields @ 2019-12-19 22:44 UTC (permalink / raw)
  To: Dave Chinner; +Cc: Trond Myklebust, J. Bruce Fields, linux-nfs

On Thu, Dec 19, 2019 at 08:12:51AM +1100, Dave Chinner wrote:
> On Wed, Dec 18, 2019 at 02:57:23PM -0500, Trond Myklebust wrote:
> > 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>
> 
> Looks ok to me now.
> 
> Acked-by: Dave Chinner <dchinner@redhat.com>

Thanks!  Applying for 5.6, with Dave's ACK.--b.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 19:57 [PATCH v2] nfsd: Clone should commit src file metadata too Trond Myklebust
2019-12-18 21:12 ` Dave Chinner
2019-12-19 22:44   ` bfields

Linux-NFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-nfs/0 linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ https://lore.kernel.org/linux-nfs \
		linux-nfs@vger.kernel.org
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-nfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git