[Devel] [PATCH RHEL8 COMMIT] fuse: relax i_mutex coverage in fuse_fsync

Konstantin Khorenko khorenko at virtuozzo.com
Fri Apr 23 11:54:55 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.19
------>
commit 2b8c1efd632c636eea2f0f75eeb0f4d7a8b3910c
Author: Maxim Patlasov <mpatlasov at virtuozzo.com>
Date:   Fri Apr 23 11:54:54 2021 +0300

    fuse: relax i_mutex coverage in fuse_fsync
    
    fuse_fsync_common() does need i_mutex for fuse_sync_writes() and
    fuse_flush_mtime(). But when those operations are done, it's actually
    doesn't matter whether to hold the lock over fuse_request_send(FUSE_FSYNC)
    or not: we ensured that all relevant data were already seen by
    userspace fuse daemon, and so it will sync them (by handling FUSE_FSYNC)
    anyway; if the user screws up by leaking new data updates in-between, it
    is up to the user and doesn't violate fsync(2) semantics.
    
    https://jira.sw.ru/browse/PSBM-55919
    
    Signed-off-by: Maxim Patlasov <mpatlasov at virtuozzo.com>
---
 fs/fuse/dir.c  | 2 --
 fs/fuse/file.c | 3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0e206d796c86..198dabdf32aa 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1335,13 +1335,11 @@ static int fuse_dir_fsync(struct file *file, loff_t start, loff_t end,
 	if (fc->no_fsyncdir)
 		return 0;
 
-	inode_lock(inode);
 	err = fuse_fsync_common(file, start, end, datasync, FUSE_FSYNCDIR);
 	if (err == -ENOSYS) {
 		fc->no_fsyncdir = 1;
 		err = 0;
 	}
-	inode_unlock(inode);
 
 	return err;
 }
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 925cf5fc55ba..8e1754319b97 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -723,11 +723,14 @@ static int fuse_fsync(struct file *file, loff_t start, loff_t end,
 	if (fc->no_fsync)
 		goto out;
 
+	inode_unlock(inode);
+
 	err = fuse_fsync_common(file, start, end, datasync, FUSE_FSYNC);
 	if (err == -ENOSYS) {
 		fc->no_fsync = 1;
 		err = 0;
 	}
+	return err;
 out:
 	inode_unlock(inode);
 


More information about the Devel mailing list