[Devel] [PATCH RHEL9 COMMIT] ms/fuse: async processing of F_SETLK with FL_SLEEP flag

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jan 12 18:36:41 MSK 2022


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.38
------>
commit aa5848de913953ca930809c3ea0f6559e06d0515
Author: Vasily Averin <vvs at virtuozzo.com>
Date:   Wed Jan 12 18:36:41 2022 +0300

    ms/fuse: async processing of F_SETLK with FL_SLEEP flag
    
    kernel export thread (nfsd/lockd/ksmbd) use F_SETLK cmd with set FL_SLEEP
    flag to request asynchronous processing of blocking locks.
    Fuse does not support async processing and should drop FL_SLEEP flag
    to avoid execution of blocking FUSE_SETLKW request.
    Dropped FL_SLEEP flag should be restored back, because it can be used
    in caller, at least in nfsd4_lock() does it actually.
    
    https://bugzilla.kernel.org/show_bug.cgi?id=215383
    (patch was submitted upstream but was not merged yet)
    
    https://jira.sw.ru/browse/PSBM-136851
    Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
    
    Feature: fix ms/fuse
---
 fs/fuse/file.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 2cefa342b2b8..d183caeaaea6 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2510,8 +2510,17 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
 	} else {
 		if (fc->no_lock)
 			err = posix_lock_file(file, fl, NULL);
-		else
+		else {
+			bool async = (fl->fl_flags & FL_SLEEP) && IS_SETLK(cmd);
+
+			if (async)
+				fl->fl_flags &= ~FL_SLEEP;
+
 			err = fuse_setlk(file, fl, 0);
+
+			if (async)
+				fl->fl_flags |= FL_SLEEP;
+		}
 	}
 	return err;
 }


More information about the Devel mailing list