[RHEL7,COMMIT] fuse kio: Wait pending requests on final fput()

Submitted by Konstantin Khorenko on June 18, 2018, 3:55 p.m.

Details

Message ID 201806181555.w5IFtE0A022581@finist_ce7.work
State New
Series "fuse kio: Wait pending requests on final fput()"
Headers show

Commit Message

Konstantin Khorenko June 18, 2018, 3:55 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.13
------>
commit 18e53c4cd2ccb41b95fd18e01f8789a38ef03c33
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Mon Jun 18 18:55:14 2018 +0300

    fuse kio: Wait pending requests on final fput()
    
    FUSE_RELEASE makes pstorage-mount to drop lease of the file.
    If this happens, pending requests will never finish.
    So, this patch makes the requests to finish actually.
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/file.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a8badb889975..8b2c36292d75 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -460,6 +460,16 @@  static int fuse_release(struct inode *inode, struct file *file)
 		     &get_fuse_inode(inode)->state))
 		fuse_flush_mtime(file, ff, true);
 
+	if (ff->fc->kio.op) {
+		/*
+		 * Flush pending requests before FUSE_RELEASE makes userspace
+		 * to drop the lease of the file. Otherwise, they never finish.
+		 */
+		mutex_lock(&inode->i_mutex);
+		fuse_sync_writes(inode);
+		mutex_unlock(&inode->i_mutex);
+	}
+
 	fuse_release_common(file, FUSE_RELEASE);
 
 	/* return value is ignored by VFS */