diff mbox series

cifs: handle async processing of F_SETLK with FL_SLEEP flag

Message ID a71b8e8d-5393-25f2-1d63-991e903c262c@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series cifs: handle async processing of F_SETLK with FL_SLEEP flag | expand

Commit Message

Vasily Averin Dec. 23, 2021, 6 p.m. UTC
kernel export thread (nfsd/lockd/ksmbd) uses F_SETLK cmd with the
FL_SLEEP flag set to request asynchronous processing of blocking locks.

Currently cifs does not support such requests, it ignores F_SETLK cmd
and handles the FL_SLEEP flag as an usual blocking lock request.

To work around the problem let's detect such request, drop FL_SLEEP and
wait_flag flags before cifs_setlk() execution.

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/cifs/file.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 9fee3af83a73..6835458ee845 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1847,6 +1847,7 @@  int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
 	int lock = 0, unlock = 0;
 	bool wait_flag = false;
 	bool posix_lck = false;
+	bool async = false;
 	struct cifs_sb_info *cifs_sb;
 	struct cifs_tcon *tcon;
 	struct cifsFileInfo *cfile;
@@ -1890,8 +1891,17 @@  int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
 		return -EOPNOTSUPP;
 	}
 
+	async = (flock->fl_flags & FL_SLEEP) && IS_SETLK(cmd);
+	if (async) {
+		flock->fl_flags &= ~FL_SLEEP;
+		wait_flag = false;
+	}
+
 	rc = cifs_setlk(file, flock, type, wait_flag, posix_lck, lock, unlock,
 			xid);
+	if (async)
+		flock->fl_flags |= FL_SLEEP;
+
 	free_xid(xid);
 	return rc;
 }