NFS: Lock the slot table from a single place during setup sequence
Rather than implementing this twice for NFS v4.0 and v4.1
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index dcb2f73..681cb5e 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -629,7 +629,6 @@
{
struct nfs4_slot *slot;
- spin_lock(&tbl->slot_tbl_lock);
if (nfs4_slot_tbl_draining(tbl) && !args->sa_privileged)
goto out_sleep;
@@ -639,13 +638,10 @@
task->tk_timeout = HZ >> 2;
goto out_sleep;
}
- spin_unlock(&tbl->slot_tbl_lock);
slot->privileged = args->sa_privileged ? 1 : 0;
args->sa_slot = slot;
res->sr_slot = slot;
-
- rpc_call_start(task);
return 0;
out_sleep:
@@ -654,7 +650,6 @@
NULL, RPC_PRIORITY_PRIVILEGED);
else
rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
- spin_unlock(&tbl->slot_tbl_lock);
return -EAGAIN;
}
@@ -889,7 +884,6 @@
task->tk_timeout = 0;
- spin_lock(&tbl->slot_tbl_lock);
if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state) &&
!args->sa_privileged) {
/* The state manager will wait until the slot table is empty */
@@ -905,7 +899,6 @@
dprintk("<-- %s: no free slots\n", __func__);
goto out_sleep;
}
- spin_unlock(&tbl->slot_tbl_lock);
slot->privileged = args->sa_privileged ? 1 : 0;
args->sa_slot = slot;
@@ -922,7 +915,6 @@
*/
res->sr_status = 1;
trace_nfs4_setup_sequence(session, args);
- rpc_call_start(task);
return 0;
out_sleep:
/* Privileged tasks are queued with top priority */
@@ -931,7 +923,6 @@
NULL, RPC_PRIORITY_PRIVILEGED);
else
rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
- spin_unlock(&tbl->slot_tbl_lock);
return -EAGAIN;
}
@@ -984,19 +975,27 @@
struct nfs4_sequence_res *res,
struct rpc_task *task)
{
-#if defined(CONFIG_NFS_V4_1)
struct nfs4_session *session = nfs4_get_session(client);
-#endif /* CONFIG_NFS_V4_1 */
+ struct nfs4_slot_table *tbl = session ? &session->fc_slot_table :
+ client->cl_slot_tbl;
+ int ret;
/* slot already allocated? */
if (res->sr_slot != NULL)
goto out_start;
+ spin_lock(&tbl->slot_tbl_lock);
+
#if defined(CONFIG_NFS_V4_1)
if (session)
- return nfs41_setup_sequence(session, args, res, task);
+ ret = nfs41_setup_sequence(session, args, res, task);
+ else
#endif /* CONFIG_NFS_V4_1 */
- return nfs40_setup_sequence(client->cl_slot_tbl, args, res, task);
+ ret = nfs40_setup_sequence(client->cl_slot_tbl, args, res, task);
+
+ spin_unlock(&tbl->slot_tbl_lock);
+ if (ret < 0)
+ return ret;
out_start:
rpc_call_start(task);