From: Vasily Averin <vvs@virtuozzo.com>
To: Steve French <sfrench@samba.org>
Cc: kernel@openvz.org, linux-cifs@vger.kernel.org,
samba-technical@lists.samba.org, linux-kernel@vger.kernel.org
Subject: [PATCH] cifs: handle async processing of F_SETLK with FL_SLEEP flag
Date: Thu, 23 Dec 2021 21:00:28 +0300 [thread overview]
Message-ID: <a71b8e8d-5393-25f2-1d63-991e903c262c@virtuozzo.com> (raw)
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
reply other threads:[~2021-12-23 18:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a71b8e8d-5393-25f2-1d63-991e903c262c@virtuozzo.com \
--to=vvs@virtuozzo.com \
--cc=kernel@openvz.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®