aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4proc.c
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2009-12-04 15:55:38 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-12-04 15:55:38 -0500
commitea028ac92541ac30bf202ed94cb53eec2ea0c9d6 (patch)
treef9b807cf0f870db922f96e72dab68ed37ba18cf0 /fs/nfs/nfs4proc.c
parent05f0d2364726c92f6b870db654967088349379fe (diff)
nfs41: nfs41: fix state manager deadlock in session reset
If the session is reset during state recovery, the state manager thread can sleep on the slot_tbl_waitq causing a deadlock. Add a completion framework to the session. Have the state manager thread set a new session state (NFS4CLNT_SESSION_DRAINING) and wait for the session slot table to drain. Signal the state manager thread in nfs41_sequence_free_slot when the NFS4CLNT_SESSION_DRAINING bit is set and the session is drained. Reported-by: Trond Myklebust <trond@netapp.com> Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r--fs/nfs/nfs4proc.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index fb62919f7f2c..c1bc9cad5e85 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -361,6 +361,16 @@ void nfs41_sequence_free_slot(const struct nfs_client *clp,
361 } 361 }
362 nfs4_free_slot(tbl, res->sr_slotid); 362 nfs4_free_slot(tbl, res->sr_slotid);
363 res->sr_slotid = NFS4_MAX_SLOT_TABLE; 363 res->sr_slotid = NFS4_MAX_SLOT_TABLE;
364
365 /* Signal state manager thread if session is drained */
366 if (test_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) {
367 spin_lock(&tbl->slot_tbl_lock);
368 if (tbl->highest_used_slotid == -1) {
369 dprintk("%s COMPLETE: Session Drained\n", __func__);
370 complete(&clp->cl_session->complete);
371 }
372 spin_unlock(&tbl->slot_tbl_lock);
373 }
364} 374}
365 375
366static void nfs41_sequence_done(struct nfs_client *clp, 376static void nfs41_sequence_done(struct nfs_client *clp,
@@ -457,15 +467,11 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
457 467
458 spin_lock(&tbl->slot_tbl_lock); 468 spin_lock(&tbl->slot_tbl_lock);
459 if (test_bit(NFS4CLNT_SESSION_RESET, &session->clp->cl_state)) { 469 if (test_bit(NFS4CLNT_SESSION_RESET, &session->clp->cl_state)) {
460 if (tbl->highest_used_slotid != -1) { 470 /*
461 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); 471 * The state manager will wait until the slot table is empty.
462 spin_unlock(&tbl->slot_tbl_lock); 472 * Schedule the reset thread
463 dprintk("<-- %s: Session reset: draining\n", __func__); 473 */
464 return -EAGAIN; 474 dprintk("%s Schedule Session Reset\n", __func__);
465 }
466
467 /* The slot table is empty; start the reset thread */
468 dprintk("%s Session Reset\n", __func__);
469 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL); 475 rpc_sleep_on(&tbl->slot_tbl_waitq, task, NULL);
470 nfs4_schedule_state_manager(session->clp); 476 nfs4_schedule_state_manager(session->clp);
471 spin_unlock(&tbl->slot_tbl_lock); 477 spin_unlock(&tbl->slot_tbl_lock);
@@ -4506,6 +4512,7 @@ static int nfs4_reset_slot_tables(struct nfs4_session *session)
4506 1); 4512 1);
4507 if (status) 4513 if (status)
4508 return status; 4514 return status;
4515 init_completion(&session->complete);
4509 4516
4510 status = nfs4_reset_slot_table(&session->bc_slot_table, 4517 status = nfs4_reset_slot_table(&session->bc_slot_table,
4511 session->bc_attrs.max_reqs, 4518 session->bc_attrs.max_reqs,
@@ -4608,6 +4615,7 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
4608 * nfs_client struct 4615 * nfs_client struct
4609 */ 4616 */
4610 clp->cl_cons_state = NFS_CS_SESSION_INITING; 4617 clp->cl_cons_state = NFS_CS_SESSION_INITING;
4618 init_completion(&session->complete);
4611 4619
4612 tbl = &session->fc_slot_table; 4620 tbl = &session->fc_slot_table;
4613 spin_lock_init(&tbl->slot_tbl_lock); 4621 spin_lock_init(&tbl->slot_tbl_lock);