Skip to content

Commit

Permalink
lockd: fix regression in lockd's handling of blocked locks
Browse files Browse the repository at this point in the history
If a client requests a blocking lock, is denied, then requests it again,
then here in nlmsvc_lock() we will call vfs_lock_file() without FL_SLEEP
set, because we've already queued a block and don't need the locks code
to do it again.

But that means vfs_lock_file() will return -EAGAIN instead of
FILE_LOCK_DENIED.  So we still need to translate that -EAGAIN return
into a nlm_lck_blocked error in this case, and put ourselves back on
lockd's block list.

The bug was introduced by bde74e4 "locks: add special return
value for asynchronous locks".

Thanks to Frank van Maarseveen for the report; his original test
case was essentially

	for i in `seq 30`; do flock /nfsmount/foo sleep 10 & done

Tested-by: Frank van Maarseveen <[email protected]>
Reported-by: Frank van Maarseveen <[email protected]>
Cc: Miklos Szeredi <[email protected]>
Signed-off-by: J. Bruce Fields <[email protected]>
  • Loading branch information
J. Bruce Fields committed Feb 9, 2009
1 parent eda58a8 commit 9d9b87c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/lockd/svclock.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
goto out;
case -EAGAIN:
ret = nlm_lck_denied;
goto out;
break;
case FILE_LOCK_DEFERRED:
if (wait)
break;
Expand All @@ -443,6 +443,10 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file,
goto out;
}

ret = nlm_lck_denied;
if (!wait)
goto out;

ret = nlm_lck_blocked;

/* Append to list of blocked */
Expand Down

0 comments on commit 9d9b87c

Please sign in to comment.