Commit 12357f1b authored by Trond Myklebust's avatar Trond Myklebust Committed by J. Bruce Fields

nfsd: minor 4.1 callback cleanup

Move all the cb_holds_slot management into helper functions.  No change
in behavior.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent 5866efa8
...@@ -975,9 +975,12 @@ void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn) ...@@ -975,9 +975,12 @@ void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn)
* If the slot is available, then mark it busy. Otherwise, set the * If the slot is available, then mark it busy. Otherwise, set the
* thread for sleeping on the callback RPC wait queue. * thread for sleeping on the callback RPC wait queue.
*/ */
static bool nfsd41_cb_get_slot(struct nfs4_client *clp, struct rpc_task *task) static bool nfsd41_cb_get_slot(struct nfsd4_callback *cb, struct rpc_task *task)
{ {
if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) { struct nfs4_client *clp = cb->cb_clp;
if (!cb->cb_holds_slot &&
test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
rpc_sleep_on(&clp->cl_cb_waitq, task, NULL); rpc_sleep_on(&clp->cl_cb_waitq, task, NULL);
/* Race breaker */ /* Race breaker */
if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) { if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
...@@ -986,9 +989,21 @@ static bool nfsd41_cb_get_slot(struct nfs4_client *clp, struct rpc_task *task) ...@@ -986,9 +989,21 @@ static bool nfsd41_cb_get_slot(struct nfs4_client *clp, struct rpc_task *task)
} }
rpc_wake_up_queued_task(&clp->cl_cb_waitq, task); rpc_wake_up_queued_task(&clp->cl_cb_waitq, task);
} }
cb->cb_holds_slot = true;
return true; return true;
} }
static void nfsd41_cb_release_slot(struct nfsd4_callback *cb)
{
struct nfs4_client *clp = cb->cb_clp;
if (cb->cb_holds_slot) {
cb->cb_holds_slot = false;
clear_bit(0, &clp->cl_cb_slot_busy);
rpc_wake_up_next(&clp->cl_cb_waitq);
}
}
/* /*
* TODO: cb_sequence should support referring call lists, cachethis, multiple * TODO: cb_sequence should support referring call lists, cachethis, multiple
* slots, and mark callback channel down on communication errors. * slots, and mark callback channel down on communication errors.
...@@ -1005,11 +1020,8 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata) ...@@ -1005,11 +1020,8 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata)
*/ */
cb->cb_seq_status = 1; cb->cb_seq_status = 1;
cb->cb_status = 0; cb->cb_status = 0;
if (minorversion) { if (minorversion && !nfsd41_cb_get_slot(cb, task))
if (!cb->cb_holds_slot && !nfsd41_cb_get_slot(clp, task)) return;
return;
cb->cb_holds_slot = true;
}
rpc_call_start(task); rpc_call_start(task);
} }
...@@ -1076,9 +1088,7 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback ...@@ -1076,9 +1088,7 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback
cb->cb_seq_status); cb->cb_seq_status);
} }
cb->cb_holds_slot = false; nfsd41_cb_release_slot(cb);
clear_bit(0, &clp->cl_cb_slot_busy);
rpc_wake_up_next(&clp->cl_cb_waitq);
dprintk("%s: freed slot, new seqid=%d\n", __func__, dprintk("%s: freed slot, new seqid=%d\n", __func__,
clp->cl_cb_session->se_cb_seq_nr); clp->cl_cb_session->se_cb_seq_nr);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment