[PATCH v2] v9fs: handle async processing of F_SETLK with FL_SLEEP flag

Vasily Averin posted 1 patch 4 years, 6 months ago
fs/9p/vfs_file.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
[PATCH v2] v9fs: handle async processing of F_SETLK with FL_SLEEP flag
Posted by Vasily Averin 4 years, 6 months ago
kernel export thread (nfsd/lockd/ksmbd) uses F_SETLK cmd with the FL_SLEEP
flag set to request asynchronous processing of blocking locks.

Currently v9fs does not support such requests and calls blocking
locks_lock_file_wait() function.

To work around the problem let's detect such request and call
non-blocking posix_file_lock() instead of locks_lock_file_wait().

https://bugzilla.kernel.org/show_bug.cgi?id=215383
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 fs/9p/vfs_file.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 612e297f3763..27ede4a4a6f4 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -142,10 +142,15 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
 		BUG();
 
-	res = locks_lock_file_wait(filp, fl);
-	if (res < 0)
-		goto out;
-
+	if ((fl->fl_flags & FL_SLEEP) && IS_SETLK(cmd)) {
+		res = posix_lock_file(filp, fl, NULL);
+		if (res)
+			goto out;
+	} else {
+		res = locks_lock_file_wait(filp, fl);
+		if (res < 0)
+			goto out;
+	}
 	/* convert posix lock to p9 tlock args */
 	memset(&flock, 0, sizeof(flock));
 	/* map the lock type */
-- 
2.25.1