mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
lockd: server should unlock lock if client rejects the grant
Currently lockd just dequeues the block and ignores it if the client sends a GRANT_RES with a status of nlm_lck_denied. That status is an indicator that the client has rejected the lock, so the right thing to do is to unlock the lock we were trying to grant. Reported-by: Yongcheng Yang <yoyang@redhat.com> Link: https://bugzilla.redhat.com/show_bug.cgi?id=2063818 Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
parent
2005f5b9c3
commit
244cc19196
1 changed files with 17 additions and 4 deletions
|
@ -954,19 +954,32 @@ void
|
||||||
nlmsvc_grant_reply(struct nlm_cookie *cookie, __be32 status)
|
nlmsvc_grant_reply(struct nlm_cookie *cookie, __be32 status)
|
||||||
{
|
{
|
||||||
struct nlm_block *block;
|
struct nlm_block *block;
|
||||||
|
struct file_lock *fl;
|
||||||
|
int error;
|
||||||
|
|
||||||
dprintk("grant_reply: looking for cookie %x, s=%d \n",
|
dprintk("grant_reply: looking for cookie %x, s=%d \n",
|
||||||
*(unsigned int *)(cookie->data), status);
|
*(unsigned int *)(cookie->data), status);
|
||||||
if (!(block = nlmsvc_find_block(cookie)))
|
if (!(block = nlmsvc_find_block(cookie)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (status == nlm_lck_denied_grace_period) {
|
switch (status) {
|
||||||
|
case nlm_lck_denied_grace_period:
|
||||||
/* Try again in a couple of seconds */
|
/* Try again in a couple of seconds */
|
||||||
nlmsvc_insert_block(block, 10 * HZ);
|
nlmsvc_insert_block(block, 10 * HZ);
|
||||||
} else {
|
break;
|
||||||
|
case nlm_lck_denied:
|
||||||
|
/* Client doesn't want it, just unlock it */
|
||||||
|
nlmsvc_unlink_block(block);
|
||||||
|
fl = &block->b_call->a_args.lock.fl;
|
||||||
|
fl->fl_type = F_UNLCK;
|
||||||
|
error = vfs_lock_file(fl->fl_file, F_SETLK, fl, NULL);
|
||||||
|
if (error)
|
||||||
|
pr_warn("lockd: unable to unlock lock rejected by client!\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
/*
|
/*
|
||||||
* Lock is now held by client, or has been rejected.
|
* Either it was accepted or the status makes no sense
|
||||||
* In both cases, the block should be removed.
|
* just unlink it either way.
|
||||||
*/
|
*/
|
||||||
nlmsvc_unlink_block(block);
|
nlmsvc_unlink_block(block);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue