linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2]  NFSv4.1: Fix a NFSv4.1 session initialisation regression
@ 2012-02-17 18:05 andros
  2012-02-17 18:05 ` [PATCH 1/2] " andros
  2012-02-17 18:05 ` [PATCH 2/2] NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT andros
  0 siblings, 2 replies; 4+ messages in thread
From: andros @ 2012-02-17 18:05 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, Andy Adamson

From: Andy Adamson <andros@netapp.com>

Tronds patch to fix the regression with one change - the slot table 
highest_used_slotid needs to be initialized in nfs4_alloc_session so that
nfs41_init_clientid doesn't wait forever in nfs4_wait_on_slot_tbl  (called
by nfs4_begin_drain_session).

Also a patch to use NFS4_NO_SLOT in nfs4_wait_on_slot_tbl.

Tested CB_RECALL_SLOT and session reset using pynfs. Passed Cthon tests
against Linux NFSv4.1 server.

Compiled against Trond's 3.3-rc2 nfs-for-next tree.

Andy Adamson (1):
  NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT

Trond Myklebust (1):
  NFSv4.1: Fix a NFSv4.1 session initialisation regression

 fs/nfs/nfs4proc.c  |  111 ++++++++++++++++++++-------------------------------
 fs/nfs/nfs4state.c |    2 +-
 2 files changed, 45 insertions(+), 68 deletions(-)

-- 
1.7.6.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] NFSv4.1: Fix a NFSv4.1 session initialisation regression
  2012-02-17 18:05 [PATCH 0/2] NFSv4.1: Fix a NFSv4.1 session initialisation regression andros
@ 2012-02-17 18:05 ` andros
  2012-02-17 18:05 ` [PATCH 2/2] NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT andros
  1 sibling, 0 replies; 4+ messages in thread
From: andros @ 2012-02-17 18:05 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, Trond Myklebust

From: Trond Myklebust <Trond.Myklebust@netapp.com>

Commit aacd553 (NFSv4.1: cleanup init and reset of session slot tables)
introduces a regression in the session initialisation code. New tables
now find their sequence ids initialised to 0, rather than the mandated
value of 1 (see RFC5661).

Fix the problem by merging nfs4_reset_slot_table() and nfs4_init_slot_table().
Since the tbl->max_slots is initialised to 0, the test in
nfs4_reset_slot_table for max_reqs != tbl->max_slots will automatically
pass for an empty table.

Reported-by: Vitaliy Gusev <gusev.vitaliy@nexenta.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 fs/nfs/nfs4proc.c |  111 +++++++++++++++++++++--------------------------------
 1 files changed, 44 insertions(+), 67 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 87c584d..8bf4181 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -5071,37 +5071,53 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo)
 	return status;
 }
 
+static struct nfs4_slot *nfs4_alloc_slots(u32 max_slots, gfp_t gfp_flags)
+{
+	return kcalloc(max_slots, sizeof(struct nfs4_slot), gfp_flags);
+}
+
+static void nfs4_add_and_init_slots(struct nfs4_slot_table *tbl,
+		struct nfs4_slot *new,
+		u32 max_slots,
+		u32 ivalue)
+{
+	struct nfs4_slot *old = NULL;
+	u32 i;
+
+	spin_lock(&tbl->slot_tbl_lock);
+	if (new) {
+		old = tbl->slots;
+		tbl->slots = new;
+		tbl->max_slots = max_slots;
+	}
+	tbl->highest_used_slotid = NFS4_NO_SLOT; /* no slot is currently used */
+	for (i = 0; i < tbl->max_slots; i++)
+		tbl->slots[i].seq_nr = ivalue;
+	spin_unlock(&tbl->slot_tbl_lock);
+	kfree(old);
+}
+
 /*
- * Reset a slot table
+ * (re)Initialise a slot table
  */
-static int nfs4_reset_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs,
-				 int ivalue)
+static int nfs4_realloc_slot_table(struct nfs4_slot_table *tbl, u32 max_reqs,
+				u32 ivalue)
 {
 	struct nfs4_slot *new = NULL;
-	int i;
-	int ret = 0;
+	int ret = -ENOMEM;
 
 	dprintk("--> %s: max_reqs=%u, tbl->max_slots %d\n", __func__,
 		max_reqs, tbl->max_slots);
 
 	/* Does the newly negotiated max_reqs match the existing slot table? */
 	if (max_reqs != tbl->max_slots) {
-		ret = -ENOMEM;
-		new = kmalloc(max_reqs * sizeof(struct nfs4_slot),
-			      GFP_NOFS);
+		new = nfs4_alloc_slots(max_reqs, GFP_NOFS);
 		if (!new)
 			goto out;
-		ret = 0;
-		kfree(tbl->slots);
-	}
-	spin_lock(&tbl->slot_tbl_lock);
-	if (new) {
-		tbl->slots = new;
-		tbl->max_slots = max_reqs;
 	}
-	for (i = 0; i < tbl->max_slots; ++i)
-		tbl->slots[i].seq_nr = ivalue;
-	spin_unlock(&tbl->slot_tbl_lock);
+	ret = 0;
+
+	nfs4_add_and_init_slots(tbl, new, max_reqs, ivalue);
 	dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
 		tbl, tbl->slots, tbl->max_slots);
 out:
@@ -5124,36 +5140,6 @@ static void nfs4_destroy_slot_tables(struct nfs4_session *session)
 }
 
 /*
- * Initialize slot table
- */
-static int nfs4_init_slot_table(struct nfs4_slot_table *tbl,
-		int max_slots, int ivalue)
-{
-	struct nfs4_slot *slot;
-	int ret = -ENOMEM;
-
-	BUG_ON(max_slots > NFS4_MAX_SLOT_TABLE);
-
-	dprintk("--> %s: max_reqs=%u\n", __func__, max_slots);
-
-	slot = kcalloc(max_slots, sizeof(struct nfs4_slot), GFP_NOFS);
-	if (!slot)
-		goto out;
-	ret = 0;
-
-	spin_lock(&tbl->slot_tbl_lock);
-	tbl->max_slots = max_slots;
-	tbl->slots = slot;
-	tbl->highest_used_slotid = NFS4_NO_SLOT;  /* no slot is currently used */
-	spin_unlock(&tbl->slot_tbl_lock);
-	dprintk("%s: tbl=%p slots=%p max_slots=%d\n", __func__,
-		tbl, tbl->slots, tbl->max_slots);
-out:
-	dprintk("<-- %s: return %d\n", __func__, ret);
-	return ret;
-}
-
-/*
  * Initialize or reset the forechannel and backchannel tables
  */
 static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
@@ -5164,25 +5150,16 @@ static int nfs4_setup_session_slot_tables(struct nfs4_session *ses)
 	dprintk("--> %s\n", __func__);
 	/* Fore channel */
 	tbl = &ses->fc_slot_table;
-	if (tbl->slots == NULL) {
-		status = nfs4_init_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
-		if (status) /* -ENOMEM */
-			return status;
-	} else {
-		status = nfs4_reset_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
-		if (status)
-			return status;
-	}
+	status = nfs4_realloc_slot_table(tbl, ses->fc_attrs.max_reqs, 1);
+	if (status) /* -ENOMEM */
+		return status;
 	/* Back channel */
 	tbl = &ses->bc_slot_table;
-	if (tbl->slots == NULL) {
-		status = nfs4_init_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 */
-			nfs4_destroy_slot_tables(ses);
-	} else
-		status = nfs4_reset_slot_table(tbl, ses->bc_attrs.max_reqs, 0);
+	status = nfs4_realloc_slot_table(tbl, ses->bc_attrs.max_reqs, 0);
+	if (status && tbl->slots == NULL)
+		/* Fore and back channel share a connection so get
+		* both slot tables or neither */
+		nfs4_destroy_slot_tables(ses);
 	return status;
 }
 
@@ -5196,13 +5173,13 @@ struct nfs4_session *nfs4_alloc_session(struct nfs_client *clp)
 		return NULL;
 
 	tbl = &session->fc_slot_table;
-	tbl->highest_used_slotid = NFS4_NO_SLOT;
+	tbl->highest_used_slotid = NFS4_NO_SLOT; /* signal slot table drained */
 	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 = NFS4_NO_SLOT;
+	tbl->highest_used_slotid = NFS4_NO_SLOT; /* signal slot table drained */
 	spin_lock_init(&tbl->slot_tbl_lock);
 	rpc_init_wait_queue(&tbl->slot_tbl_waitq, "BackChannel Slot table");
 	init_completion(&tbl->complete);
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT
  2012-02-17 18:05 [PATCH 0/2] NFSv4.1: Fix a NFSv4.1 session initialisation regression andros
  2012-02-17 18:05 ` [PATCH 1/2] " andros
@ 2012-02-17 18:05 ` andros
  2012-02-17 18:40   ` Myklebust, Trond
  1 sibling, 1 reply; 4+ messages in thread
From: andros @ 2012-02-17 18:05 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs, Andy Adamson

From: Andy Adamson <andros@netapp.com>

Signed-off-by: Andy Adamson <andros@netapp.com>
---
 fs/nfs/nfs4state.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 4e37818..c1111a3 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -212,7 +212,7 @@ static void nfs4_end_drain_session(struct nfs_client *clp)
 static int nfs4_wait_on_slot_tbl(struct nfs4_slot_table *tbl)
 {
 	spin_lock(&tbl->slot_tbl_lock);
-	if (tbl->highest_used_slotid != -1) {
+	if (tbl->highest_used_slotid != NFS4_NO_SLOT) {
 		INIT_COMPLETION(tbl->complete);
 		spin_unlock(&tbl->slot_tbl_lock);
 		return wait_for_completion_interruptible(&tbl->complete);
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT
  2012-02-17 18:05 ` [PATCH 2/2] NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT andros
@ 2012-02-17 18:40   ` Myklebust, Trond
  0 siblings, 0 replies; 4+ messages in thread
From: Myklebust, Trond @ 2012-02-17 18:40 UTC (permalink / raw)
  To: Adamson, Andy; +Cc: lin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PiAgCQlyZXR1cm4gd2FpdF9mb3JfY29tcGxldGlvbl9p
bnRlcnJ1cHRpYmxlKCZ0YmwtPmNvbXBsZXRlKTsNCg0KR29vZCBjYXRjaCEgQXBwbGllZC4uLg0K
DQotLSANClRyb25kIE15a2xlYnVzdA0KTGludXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5l
dEFwcA0KVHJvbmQuTXlrbGVidXN0QG5ldGFwcC5jb20NCnd3dy5uZXRhcHAuY29tDQoNCg==

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-17 18:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17 18:05 [PATCH 0/2] NFSv4.1: Fix a NFSv4.1 session initialisation regression andros
2012-02-17 18:05 ` [PATCH 1/2] " andros
2012-02-17 18:05 ` [PATCH 2/2] NFSv4.1 set highest_used_slotid to NFS4_NO_SLOT andros
2012-02-17 18:40   ` Myklebust, Trond

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).