Skip to content

Commit c6c15e1

Browse files
trondmypdJ. Bruce Fields
authored and
J. Bruce Fields
committed
nfsd: Fix slot wake up race in the nfsv4.1 callback code
The currect code for nfsd41_cb_get_slot() and nfsd4_cb_done() has no locking in order to guarantee atomicity, and so allows for races of the form. Task 1 Task 2 ====== ====== if (test_and_set_bit(0) != 0) { clear_bit(0) rpc_wake_up_next(queue) rpc_sleep_on(queue) return false; } This patch breaks the race condition by adding a retest of the bit after the call to rpc_sleep_on(). Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Cc: stable@vger.kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 093a146 commit c6c15e1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/nfsd/nfs4callback.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,12 @@ static bool nfsd41_cb_get_slot(struct nfs4_client *clp, struct rpc_task *task)
774774
{
775775
if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
776776
rpc_sleep_on(&clp->cl_cb_waitq, task, NULL);
777-
dprintk("%s slot is busy\n", __func__);
778-
return false;
777+
/* Race breaker */
778+
if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
779+
dprintk("%s slot is busy\n", __func__);
780+
return false;
781+
}
782+
rpc_wake_up_queued_task(&clp->cl_cb_waitq, task);
779783
}
780784
return true;
781785
}

0 commit comments

Comments
 (0)