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>,
	"J. Bruce Fields" <bfields@fieldses.org>
Cc: kernel@openvz.org, linux-nfs@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v3 3/3] nfs v2/3: nlmclnt_lock: handle async processing of F_SETLK with FL_SLEEP
Date: Wed, 29 Dec 2021 11:24:53 +0300	[thread overview]
Message-ID: <dc99ce3c-d73f-b21b-b92f-d0b1025c4567@virtuozzo.com> (raw)
In-Reply-To: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com>

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

Currently nfs v2/3 handles such requests by using nlmclnt_lock() ->
do_vfs_lock() -> locks_lock_inode_wait() function which is blocked
if request have FL_SLEEP flag set.

To handle them correctly FL_SLEEP flag should be temporarily reset
before executing the locks_lock_inode_wait() function.

Additionally block flag is forced to set, to translate blocking lock to
remote nfs server, expecting it supports async processing of the blocking
locks too.

https://bugzilla.kernel.org/show_bug.cgi?id=215383
Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 fs/lockd/clntproc.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index 99fffc9cb958..5941aa7c9cc9 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -519,11 +519,18 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
 	unsigned char fl_flags = fl->fl_flags;
 	unsigned char fl_type;
 	int status = -ENOLCK;
+	bool async = false;
 
 	if (nsm_monitor(host) < 0)
 		goto out;
 	req->a_args.state = nsm_local_state;
 
+	async = !req->a_args.block &&
+		((fl_flags & FL_SLEEP_POSIX) == FL_SLEEP_POSIX);
+	if (async) {
+		fl->fl_flags &= ~FL_SLEEP;
+		req->a_args.block = 1;
+	}
 	fl->fl_flags |= FL_ACCESS;
 	status = do_vfs_lock(fl);
 	fl->fl_flags = fl_flags;
@@ -573,8 +580,11 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
 			up_read(&host->h_rwsem);
 			goto again;
 		}
-		/* Ensure the resulting lock will get added to granted list */
-		fl->fl_flags |= FL_SLEEP;
+		if (async)
+			fl->fl_flags &= ~FL_SLEEP;
+		else
+			/* Ensure the resulting lock will get added to granted list */
+			fl->fl_flags |= FL_SLEEP;
 		if (do_vfs_lock(fl) < 0)
 			printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __func__);
 		up_read(&host->h_rwsem);
-- 
2.25.1


  parent reply	other threads:[~2021-12-29  8:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 10:45 [PATCH] nfs4: handle async processing of F_SETLK with FL_SLEEP Vasily Averin
2021-12-27 15:51 ` [PATCH v2] " 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     ` Vasily Averin [this message]
2021-12-27 17:58 ` [PATCH] " 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=dc99ce3c-d73f-b21b-b92f-d0b1025c4567@virtuozzo.com \
    --to=vvs@virtuozzo.com \
    --cc=anna.schumaker@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.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.