All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] v9fs: handle async processing of F_SETLK with FL_SLEEP flag
@ 2021-12-23 18:21 Vasily Averin
  2021-12-23 23:14 ` Dominique Martinet
  0 siblings, 1 reply; 11+ messages in thread
From: Vasily Averin @ 2021-12-23 18:21 UTC (permalink / raw)
  To: Eric Van Hensbergen, Latchesar Ionkov, Dominique Martinet
  Cc: kernel, v9fs-developer, linux-kernel

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, drop FL_SLEEP
before execution of potentially blocking functions.

Dropped FL_SLEEP flag should be restored back because some calling
function (nfsd4_lock) require it.

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

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 612e297f3763..81c98afdbb32 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -135,6 +135,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	int res = 0;
 	unsigned char fl_type;
 	struct v9fs_session_info *v9ses;
+	bool async = false;
 
 	fid = filp->private_data;
 	BUG_ON(fid == NULL);
@@ -142,6 +143,10 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
 		BUG();
 
+	async = (fl->fl_flags & FL_SLEEP) && IS_SETLK(cmd);
+	if (async)
+		fl->fl_flags &= ~FL_SLEEP;
+
 	res = locks_lock_file_wait(filp, fl);
 	if (res < 0)
 		goto out;
@@ -230,6 +235,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
 	if (flock.client_id != fid->clnt->name)
 		kfree(flock.client_id);
 out:
+	if (async)
+		fl->fl_flags |= FL_SLEEP;
 	return res;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-12-27  9:18 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23 18:21 [PATCH] v9fs: handle async processing of F_SETLK with FL_SLEEP flag Vasily Averin
2021-12-23 23:14 ` Dominique Martinet
2021-12-24  7:08   ` Vasily Averin
2021-12-24  7:31     ` Dominique Martinet
2021-12-24  8:24       ` Vasily Averin
2021-12-24 10:18       ` Vasily Averin
2021-12-24 10:21         ` [PATCH v2] " Vasily Averin
2021-12-24 14:56         ` [PATCH] " Dominique Martinet
2021-12-27  7:42           ` Vasily Averin
2021-12-27  9:17             ` Dominique Martinet
2021-12-24 12:07       ` Vasily Averin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.