nfsd: Clone should commit src file metadata too
Subsystems (2)
PATCH v2 1/1 nfsd: Clone should commit src file metadata too
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 <[email protected]>
Signed-off-by Trond Myklebust <[email protected]>
---
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(-)
fs/nfsd/vfs.c +14 -5
@@ -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); }
Signature · 1 line
2.23.0
Quoted 5 lines · Trond Myklebust
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 <[email protected]>Signed-off-by Trond Myklebust <[email protected]>
Looks ok to me now.
Acked-by Dave Chinner <[email protected]>
Signature · 2 lines
Dave Chinner [email protected]
Quoted 10 lines · Dave Chinner
Quoted 5 lines · Trond Myklebust
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 <[email protected]>Signed-off-by Trond Myklebust <[email protected]>Looks ok to me now.
Acked-by Dave Chinner <[email protected]>
Thanks! Applying for 5.6, with Dave's ACK.--b.