lkml.org 
[lkml]   [2021]   [Dec]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] cifs: handle async processing of F_SETLK with FL_SLEEP flag
Date
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 --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;
}
--
2.25.1
\
 
 \ /
  Last update: 2021-12-23 19:06    [W:0.058 / U:2.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site