[PATCH Version 7 1/3] NFS4.1 clean up nfs4_alloc_session

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

 



From: Andy Adamson <andros@xxxxxxxxxx>

Signed-off-by: Andy Adamson <andros@xxxxxxxxxx>
---
 fs/nfs/nfs4proc.c |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index d202e04..18b095a 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5061,9 +5061,9 @@ static void nfs4_destroy_slot_tables(struct nfs4_session *session)
 }
 
 /*
- * Initialize slot table
+ * Set the initial slot table slots with CREATE_SESSION negotiated values
  */
-static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
+static int nfs4_set_slot_table(struct nfs4_slot_table *tbl,
 		int max_slots, int ivalue)
 {
 	struct nfs4_slot *slot;
@@ -5091,7 +5091,7 @@ out:
 }
 
 /*
- * Initialize or reset the forechannel and backchannel tables
+ * Set or reset the forechannel and backchannel tables
  */
 static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
 {
@@ -5102,7 +5102,7 @@ static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
 	/* Fore channel */
 	tbl = &ses->fc_slot_table;
 	if (tbl->slots == NULL) {
-		status = nfs4_init_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
+		status = nfs4_set_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
 		if (status) /* -ENOMEM */
 			return status;
 	} else {
@@ -5113,7 +5113,7 @@ static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
 	/* Back channel */
 	tbl = &ses->bc_slot_table;
 	if (tbl->slots == NULL) {
-		status = nfs4_init_slot_table(tbl, ses->bc_attrs.max_reqs, 0);
+		status = nfs4_set_slot_table(tbl, ses->bc_attrs.max_reqs, 0);
 		if (status)
 			/* Fore and back channel share a connection so get
 			 * both slot tables or neither */
@@ -5123,29 +5123,30 @@ static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
 	return status;
 }
 
+void nfs4_init_slot_table(struct nfs4_slot_table *tbl, bool forechannel)
+{
+	spin_lock_init(&tbl->slot_tbl_lock);
+	if (forechannel)
+		rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq,
+					     "ForeChannel Slot table");
+	else
+		rpc_init_wait_queue(&tbl->slot_tbl_waitq,
+				    "BackChannel Slot table");
+	tbl->highest_used_slotid = -1;	/* for drain session to work */
+	init_completion(&tbl->complete);
+}
+
 struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
 {
 	struct nfs4_session *session;
-	struct nfs4_slot_table *tbl;
 
 	session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS);
 	if (!session)
 		return NULL;
 
-	tbl = &session->fc_slot_table;
-	tbl->highest_used_slotid = -1;
-	spin_lock_init(&tbl->slot_tbl_lock);
-	rpc_init_priority_wait_queue(&tbl->slot_tbl_waitq, "ForeChannel Slot table");
-	init_completion(&tbl->complete);
-
-	tbl = &session->bc_slot_table;
-	tbl->highest_used_slotid = -1;
-	spin_lock_init(&tbl->slot_tbl_lock);
-	rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table");
-	init_completion(&tbl->complete);
-
+	nfs4_init_slot_table(&session->fc_slot_table, true);
+	nfs4_init_slot_table(&session->bc_slot_table, false);
 	session->session_state = 1<<NFS4_SESSION_INITING;
-
 	session->clp = clp;
 	return session;
 }
-- 
1.7.6.4

--
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