[RHEL7,COMMIT] fs/fuse: set FATTR_FH flag on mtime file flush

Submitted by Konstantin Khorenko on June 4, 2018, 8:26 p.m.

Details

Message ID 201806042026.w54KQFUJ005836@finist_ce7.work
State New
Series "fs/fuse: set FATTR_FH flag on mtime file flush"
Headers show

Commit Message

Konstantin Khorenko June 4, 2018, 8:26 p.m.
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.4
------>
commit 6e5c2cf88453446fee1320c7c1af3d35364fb694
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Mon Jun 4 23:26:15 2018 +0300

    fs/fuse: set FATTR_FH flag on mtime file flush
    
    If setattr request is for a file, FATTR_FH flag should be set.
    In fuse_flush_mtime() that is clearly missed.
    
    This fix is present in ms commit 1e18bda86e2d ("fuse: add .write_inode"), but
    it wasn't backported because the commit has a lot of unrelated changes. So this
    patch can be safely dropped in case of moving to a newer kernel.
    
    https://pmc.acronis.com/browse/VSTOR-10676
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 fs/fuse/dir.c    | 6 +++++-
 fs/fuse/file.c   | 4 ++--
 fs/fuse/fuse_i.h | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0ae0344be3c5..b04023bf230a 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1690,7 +1690,7 @@  static void fuse_setattr_fill(struct fuse_conn *fc, struct fuse_req *req,
 /*
  * Flush inode->i_mtime to the server
  */
-int fuse_flush_mtime(struct file *file, bool nofail)
+int fuse_flush_mtime(struct file *file, struct fuse_file *ff, bool nofail)
 {
 	struct inode *inode = file->f_mapping->host;
 	struct fuse_inode *fi = get_fuse_inode(inode);
@@ -1715,6 +1715,10 @@  int fuse_flush_mtime(struct file *file, bool nofail)
 	inarg.mtime = inode->i_mtime.tv_sec;
 	inarg.mtimensec = inode->i_mtime.tv_nsec;
 
+	if (ff) {
+		inarg.valid |= FATTR_FH;
+		inarg.fh = ff->fh;
+	}
 	fuse_setattr_fill(fc, req, inode, &inarg, &outarg);
 	fuse_request_send(fc, req);
 	err = req->out.h.error;
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index d84dd402c83c..f9a0da25a9df 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -458,7 +458,7 @@  static int fuse_release(struct inode *inode, struct file *file)
 
 	if (test_bit(FUSE_I_MTIME_UPDATED,
 		     &get_fuse_inode(inode)->state))
-		fuse_flush_mtime(file, true);
+		fuse_flush_mtime(file, ff, true);
 
 	fuse_release_common(file, FUSE_RELEASE);
 
@@ -731,7 +731,7 @@  int fuse_fsync_common(struct file *file, loff_t start, loff_t end,
 
 	if (!datasync && test_bit(FUSE_I_MTIME_UPDATED,
 				  &get_fuse_inode(inode)->state)) {
-		err = fuse_flush_mtime(file, false);
+		err = fuse_flush_mtime(file, isdir ? NULL : ff, false);
 		if (err)
 			goto out;
 	}
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index f704fd17905b..939835f585b1 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1074,7 +1074,7 @@  int fuse_dev_release(struct inode *inode, struct file *file);
 
 bool fuse_write_update_size(struct inode *inode, loff_t pos);
 
-int fuse_flush_mtime(struct file *file, bool nofail);
+int fuse_flush_mtime(struct file *file, struct fuse_file *ff, bool nofail);
 
 int fuse_do_setattr(struct inode *inode, struct iattr *attr,
 		    struct file *file);