Skip to content

Commit e6abc8c

Browse files
trondmyJ. Bruce Fields
authored andcommitted
nfsd: Don't release the callback slot unless it was actually held
If there are multiple callbacks queued, waiting for the callback slot when the callback gets shut down, then they all currently end up acting as if they hold the slot, and call nfsd4_cb_sequence_done() resulting in interesting side-effects. In addition, the 'retry_nowait' path in nfsd4_cb_sequence_done() causes a loop back to nfsd4_cb_prepare() without first freeing the slot, which causes a deadlock when nfsd41_cb_get_slot() gets called a second time. This patch therefore adds a boolean to track whether or not the callback did pick up the slot, so that it can do the right thing in these 2 cases. Cc: stable@vger.kernel.org Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 3c86794 commit e6abc8c

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎fs/nfsd/nfs4callback.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,9 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata)
10101010
cb->cb_seq_status = 1;
10111011
cb->cb_status = 0;
10121012
if (minorversion) {
1013-
if (!nfsd41_cb_get_slot(clp, task))
1013+
if (!cb->cb_holds_slot && !nfsd41_cb_get_slot(clp, task))
10141014
return;
1015+
cb->cb_holds_slot = true;
10151016
}
10161017
rpc_call_start(task);
10171018
}
@@ -1038,6 +1039,9 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback
10381039
return true;
10391040
}
10401041

1042+
if (!cb->cb_holds_slot)
1043+
goto need_restart;
1044+
10411045
switch (cb->cb_seq_status) {
10421046
case 0:
10431047
/*
@@ -1076,6 +1080,7 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback
10761080
cb->cb_seq_status);
10771081
}
10781082

1083+
cb->cb_holds_slot = false;
10791084
clear_bit(0, &clp->cl_cb_slot_busy);
10801085
rpc_wake_up_next(&clp->cl_cb_waitq);
10811086
dprintk("%s: freed slot, new seqid=%d\n", __func__,
@@ -1283,6 +1288,7 @@ void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
12831288
cb->cb_seq_status = 1;
12841289
cb->cb_status = 0;
12851290
cb->cb_need_restart = false;
1291+
cb->cb_holds_slot = false;
12861292
}
12871293

12881294
void nfsd4_run_cb(struct nfsd4_callback *cb)

‎fs/nfsd/state.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ struct nfsd4_callback {
7070
int cb_seq_status;
7171
int cb_status;
7272
bool cb_need_restart;
73+
bool cb_holds_slot;
7374
};
7475

7576
struct nfsd4_callback_ops {

0 commit comments

Comments
 (0)