[PATCH 2/2] nfs41: fix race on session reset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andy Adamson <andros@xxxxxxxxxx>

Do not clear the NFS4CLNT_SESSION_SETUP bit until after the session and/or the
clientid has been established.

Clear the bit in nfs4_proc_create_session on a successful CREATE_SESSION to
make the new session available for the nfs4_get_lease_time call in the
session initialization case.

In the session reset case, this prevents a race with RPC's wating on the
slot_tbl_waitq where nfs41_setup_sequence would assign a slot on a partially
reset session.

Clear the bit on session init/reset failure other than NFS4ERR_STALE_CLIENTID
in the state manager.

Signed-off-by: Andy Adamson <andros@xxxxxxxxxx>
---
 fs/nfs/nfs4proc.c  |    3 +++
 fs/nfs/nfs4state.c |   10 ++++++++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 3ec6406..0f1afde 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -4782,6 +4782,9 @@ int nfs4_proc_create_session(struct nfs_client *clp, int reset)
 	if (status)
 		goto out;
 
+	/* Signal nfs41_setup_sequence that the session is ready for use */
+	clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state);
+
 	ptr = (unsigned *)&session->sess_id.data[0];
 	dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__,
 		clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 2ef4fec..50a1b04 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1249,8 +1249,12 @@ static void nfs4_state_manager(struct nfs_client *clp)
 			if (status != 0)
 				continue;
 		}
-		/* Initialize or reset the session */
-		if (test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)
+		/*
+		 * Initialize or reset the session. Wait to clear the bit
+		 * (in nfs4_proc_create_session) until session and /or
+		 * clientid is established.
+		 */
+		if (test_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)
 		   && nfs4_has_session(clp)) {
 			if (clp->cl_cons_state == NFS_CS_SESSION_INITING)
 				status = nfs4_initialize_session(clp);
@@ -1259,6 +1263,8 @@ static void nfs4_state_manager(struct nfs_client *clp)
 			if (status) {
 				if (status == -NFS4ERR_STALE_CLIENTID)
 					continue;
+				clear_bit(NFS4CLNT_SESSION_SETUP,
+					  &clp->cl_state);
 				goto out_error;
 			}
 		}
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux