Skip to content

Commit 12357f1

Browse files
trondmyJ. Bruce Fields
authored andcommitted
nfsd: minor 4.1 callback cleanup
Move all the cb_holds_slot management into helper functions. No change in behavior. Signed-off-by: Trond Myklebust <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 5866efa commit 12357f1

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

fs/nfsd/nfs4callback.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,12 @@ void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn)
975975
* If the slot is available, then mark it busy. Otherwise, set the
976976
* thread for sleeping on the callback RPC wait queue.
977977
*/
978-
static bool nfsd41_cb_get_slot(struct nfs4_client *clp, struct rpc_task *task)
978+
static bool nfsd41_cb_get_slot(struct nfsd4_callback *cb, struct rpc_task *task)
979979
{
980-
if (test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
980+
struct nfs4_client *clp = cb->cb_clp;
981+
982+
if (!cb->cb_holds_slot &&
983+
test_and_set_bit(0, &clp->cl_cb_slot_busy) != 0) {
981984
rpc_sleep_on(&clp->cl_cb_waitq, task, NULL);
982985
/* Race breaker */
983986
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)
986989
}
987990
rpc_wake_up_queued_task(&clp->cl_cb_waitq, task);
988991
}
992+
cb->cb_holds_slot = true;
989993
return true;
990994
}
991995

996+
static void nfsd41_cb_release_slot(struct nfsd4_callback *cb)
997+
{
998+
struct nfs4_client *clp = cb->cb_clp;
999+
1000+
if (cb->cb_holds_slot) {
1001+
cb->cb_holds_slot = false;
1002+
clear_bit(0, &clp->cl_cb_slot_busy);
1003+
rpc_wake_up_next(&clp->cl_cb_waitq);
1004+
}
1005+
}
1006+
9921007
/*
9931008
* TODO: cb_sequence should support referring call lists, cachethis, multiple
9941009
* slots, and mark callback channel down on communication errors.
@@ -1005,11 +1020,8 @@ static void nfsd4_cb_prepare(struct rpc_task *task, void *calldata)
10051020
*/
10061021
cb->cb_seq_status = 1;
10071022
cb->cb_status = 0;
1008-
if (minorversion) {
1009-
if (!cb->cb_holds_slot && !nfsd41_cb_get_slot(clp, task))
1010-
return;
1011-
cb->cb_holds_slot = true;
1012-
}
1023+
if (minorversion && !nfsd41_cb_get_slot(cb, task))
1024+
return;
10131025
rpc_call_start(task);
10141026
}
10151027

@@ -1076,9 +1088,7 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback
10761088
cb->cb_seq_status);
10771089
}
10781090

1079-
cb->cb_holds_slot = false;
1080-
clear_bit(0, &clp->cl_cb_slot_busy);
1081-
rpc_wake_up_next(&clp->cl_cb_waitq);
1091+
nfsd41_cb_release_slot(cb);
10821092
dprintk("%s: freed slot, new seqid=%d\n", __func__,
10831093
clp->cl_cb_session->se_cb_seq_nr);
10841094

0 commit comments

Comments
 (0)