All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Vasily Averin <vvs@virtuozzo.com>
To: Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>
Cc: kernel@openvz.org, linux-nfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] nfs4: handle async processing of F_SETLK with FL_SLEEP
Date: Mon, 27 Dec 2021 13:45:45 +0300	[thread overview]
Message-ID: <3a2c6cb9-abe7-ab32-b11c-d78621361555@virtuozzo.com> (raw)

nfsd and lockd use F_SETLK cmd with the FL_SLEEP flag set to request
asynchronous processing of blocking locks.

Currently nfs4 use locks_lock_inode_wait() function blocked on such requests.
To handle such requests properly, non-blocking posix_file_lock()
function should be used instead.

https://bugzilla.kernel.org/show_bug.cgi?id=215383
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
VvS: I'm not sure that request->fl_file points to the same state->inode
used in locks_lock_inode_wait(). If it is not, posix_lock_inode() can be
used here, but this function is static currently and should be exported first.
---
 fs/nfs/nfs4proc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ee3bc79f6ca3..54431b296c85 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7200,8 +7200,11 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock
 	int status;
 
 	request->fl_flags |= FL_ACCESS;
-	status = locks_lock_inode_wait(state->inode, request);
-	if (status < 0)
+	if ((request->fl_flags && FL_SLEEP) && IS_SETLK(cmd))
+		status = posix_lock_file(request->fl_file, request, NULL);
+	else
+		status = locks_lock_inode_wait(state->inode, request);
+	if (status)
 		goto out;
 	mutex_lock(&sp->so_delegreturn_mutex);
 	down_read(&nfsi->rwsem);
-- 
2.25.1


             reply	other threads:[~2021-12-27 10:45 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 10:45 Vasily Averin [this message]
2021-12-27 15:51 ` [PATCH v2] nfs4: handle async processing of F_SETLK with FL_SLEEP Vasily Averin
2021-12-28  1:04   ` Vasily Averin
2021-12-29  8:24     ` [PATCH v3 1/3] nfs: local_lock: " Vasily Averin
2021-12-29  8:24     ` [PATCH v3 2/3] nfs4: " Vasily Averin
2022-01-03 19:40       ` J. Bruce Fields
2022-01-16 12:25         ` Vasily Averin
2022-01-03 19:53       ` J. Bruce Fields
2022-01-16 12:44         ` Vasily Averin
2022-01-16 18:28           ` Vasily Averin
2022-01-18 22:35           ` J. Bruce Fields
2021-12-29  8:24     ` [PATCH v3 3/3] nfs v2/3: nlmclnt_lock: " Vasily Averin
2021-12-27 17:58 ` [PATCH] nfs4: " kernel test robot
2021-12-27 17:58   ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2021-12-28  8:43 kernel test robot
2022-01-06 10:37 ` Dan Carpenter
2022-01-06 10:37 ` Dan Carpenter

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=3a2c6cb9-abe7-ab32-b11c-d78621361555@virtuozzo.com \
    --to=vvs@virtuozzo.com \
    --cc=anna.schumaker@netapp.com \
    --cc=kernel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    /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 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.