diff mbox series

[v2] nfs: local_lock: handle async processing of F_SETLK with FL_SLEEP

Message ID 3e5d6777-9365-c853-071f-3e9fc4df922c@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series [v2] nfs: local_lock: handle async processing of F_SETLK with FL_SLEEP | expand

Commit Message

Vasily Averin Dec. 27, 2021, 3:50 p.m. UTC
nfsd and lockd use F_SETLK cmd with the FL_SLEEP flag set to request
asynchronous processing of blocking locks.

Currently nfs mounted with 'local_lock' option use locks_lock_file_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>
---
v2: fixed 'fl_flags && FL_SLEEP' => 'fl_flags & FL_SLEEP'
---
 fs/nfs/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Vasily Averin Dec. 28, 2021, 1 a.m. UTC | #1
Patch is wrong,
I missed that FL_FLOCK are handled here too.

On 27.12.2021 18:50, Vasily Averin wrote:
> nfsd and lockd use F_SETLK cmd with the FL_SLEEP flag set to request
> asynchronous processing of blocking locks.
> 
> Currently nfs mounted with 'local_lock' option use locks_lock_file_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>
> ---
> v2: fixed 'fl_flags && FL_SLEEP' => 'fl_flags & FL_SLEEP'
> ---
>  fs/nfs/file.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/file.c b/fs/nfs/file.c
> index 24e7dccce355..38e1821cff5d 100644
> --- a/fs/nfs/file.c
> +++ b/fs/nfs/file.c
> @@ -769,9 +769,11 @@ do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
>  	 */
>  	if (!is_local)
>  		status = NFS_PROTO(inode)->lock(filp, cmd, fl);
> +	else if ((fl->fl_flags & FL_SLEEP) && IS_SETLK(cmd))
> +		status = posix_lock_file(filp, fl, NULL);
>  	else
>  		status = locks_lock_file_wait(filp, fl);
> -	if (status < 0)
> +	if (status)
>  		goto out;
>  
>  	/*
>
diff mbox series

Patch

diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 24e7dccce355..38e1821cff5d 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -769,9 +769,11 @@  do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local)
 	 */
 	if (!is_local)
 		status = NFS_PROTO(inode)->lock(filp, cmd, fl);
+	else if ((fl->fl_flags & FL_SLEEP) && IS_SETLK(cmd))
+		status = posix_lock_file(filp, fl, NULL);
 	else
 		status = locks_lock_file_wait(filp, fl);
-	if (status < 0)
+	if (status)
 		goto out;
 
 	/*