@@ -975,9 +975,12 @@ void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *conn)
975
975
* If the slot is available, then mark it busy. Otherwise, set the
976
976
* thread for sleeping on the callback RPC wait queue.
977
977
*/
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 )
979
979
{
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 ) {
981
984
rpc_sleep_on (& clp -> cl_cb_waitq , task , NULL );
982
985
/* Race breaker */
983
986
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
989
}
987
990
rpc_wake_up_queued_task (& clp -> cl_cb_waitq , task );
988
991
}
992
+ cb -> cb_holds_slot = true;
989
993
return true;
990
994
}
991
995
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
+
992
1007
/*
993
1008
* TODO: cb_sequence should support referring call lists, cachethis, multiple
994
1009
* 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
1020
*/
1006
1021
cb -> cb_seq_status = 1 ;
1007
1022
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 ;
1013
1025
rpc_call_start (task );
1014
1026
}
1015
1027
@@ -1076,9 +1088,7 @@ static bool nfsd4_cb_sequence_done(struct rpc_task *task, struct nfsd4_callback
1076
1088
cb -> cb_seq_status );
1077
1089
}
1078
1090
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 );
1082
1092
dprintk ("%s: freed slot, new seqid=%d\n" , __func__ ,
1083
1093
clp -> cl_cb_session -> se_cb_seq_nr );
1084
1094
0 commit comments