Skip to content

Commit 6ea76bf

Browse files
author
Trond Myklebust
committed
NFSv4: Fix _nfs4_do_setlk()
The patch to fix the case where a lock request was interrupted ended up changing default handling of errors such as NFS4ERR_DENIED and caused the client to immediately resend the lock request. Let's do a partial revert of that request so that the default is now to exit, but change the way we handle resends to take into account the fact that the user may have interrupted the request. Reported-by: Kenneth Johansson <ken@kenjo.org> Fixes: a3cf9bc ("NFSv4: Don't add a new lock on an interrupted wait..") Cc: Benjamin Coddington <bcodding@redhat.com> Cc: Jeff Layton <jlayton@kernel.org> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Reviewed-by: Jeff Layton <jlayton@kernel.org>
1 parent 9a97ebf commit 6ea76bf

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

fs/nfs/nfs4proc.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6466,34 +6466,34 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
64666466
if (data->arg.new_lock && !data->cancelled) {
64676467
data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS);
64686468
if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0)
6469-
break;
6469+
goto out_restart;
64706470
}
6471-
64726471
if (data->arg.new_lock_owner != 0) {
64736472
nfs_confirm_seqid(&lsp->ls_seqid, 0);
64746473
nfs4_stateid_copy(&lsp->ls_stateid, &data->res.stateid);
64756474
set_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags);
6476-
goto out_done;
6477-
} else if (nfs4_update_lock_stateid(lsp, &data->res.stateid))
6478-
goto out_done;
6479-
6475+
} else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
6476+
goto out_restart;
64806477
break;
64816478
case -NFS4ERR_BAD_STATEID:
64826479
case -NFS4ERR_OLD_STATEID:
64836480
case -NFS4ERR_STALE_STATEID:
64846481
case -NFS4ERR_EXPIRED:
64856482
if (data->arg.new_lock_owner != 0) {
6486-
if (nfs4_stateid_match(&data->arg.open_stateid,
6483+
if (!nfs4_stateid_match(&data->arg.open_stateid,
64876484
&lsp->ls_state->open_stateid))
6488-
goto out_done;
6489-
} else if (nfs4_stateid_match(&data->arg.lock_stateid,
6485+
goto out_restart;
6486+
} else if (!nfs4_stateid_match(&data->arg.lock_stateid,
64906487
&lsp->ls_stateid))
6491-
goto out_done;
6488+
goto out_restart;
64926489
}
6493-
if (!data->cancelled)
6494-
rpc_restart_call_prepare(task);
64956490
out_done:
64966491
dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
6492+
return;
6493+
out_restart:
6494+
if (!data->cancelled)
6495+
rpc_restart_call_prepare(task);
6496+
goto out_done;
64976497
}
64986498

64996499
static void nfs4_lock_release(void *calldata)
@@ -6502,7 +6502,7 @@ static void nfs4_lock_release(void *calldata)
65026502

65036503
dprintk("%s: begin!\n", __func__);
65046504
nfs_free_seqid(data->arg.open_seqid);
6505-
if (data->cancelled) {
6505+
if (data->cancelled && data->rpc_status == 0) {
65066506
struct rpc_task *task;
65076507
task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp,
65086508
data->arg.lock_seqid);

0 commit comments

Comments
 (0)