All of lore.kernel.org
 help / color / mirror / Atom feed
* create_session bugfix
@ 2009-10-27 23:07 J. Bruce Fields
  2009-10-27 23:07 ` [PATCH 1/2] nfsd4.1: fix session memory use calculation J. Bruce Fields
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: J. Bruce Fields @ 2009-10-27 23:07 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: pnfs, Andy Adamson


I'm queueing this up for 2.6.33 if there's no objections.

--b.

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

* [PATCH 1/2] nfsd4.1: fix session memory use calculation
  2009-10-27 23:07 create_session bugfix J. Bruce Fields
@ 2009-10-27 23:07 ` J. Bruce Fields
  2009-10-27 23:07   ` [PATCH 2/2] nfsd4.1: common slot allocation size calculation J. Bruce Fields
  2009-10-27 23:10 ` [pnfs] create_session bugfix J. Bruce Fields
  2009-11-03  6:25 ` Benny Halevy
  2 siblings, 1 reply; 5+ messages in thread
From: J. Bruce Fields @ 2009-10-27 23:07 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: pnfs, Andy Adamson, J. Bruce Fields

Unbalanced calculations on creation and destruction of sessions could
cause our estimate of cache memory used to become negative, sometimes
resulting in spurious SERVERFAULT returns to client CREATE_SESSION
requests.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
 fs/nfsd/nfs4state.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index fcb9817..c171371 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -629,10 +629,13 @@ void
 free_session(struct kref *kref)
 {
 	struct nfsd4_session *ses;
+	int mem;
 
 	ses = container_of(kref, struct nfsd4_session, se_ref);
 	spin_lock(&nfsd_drc_lock);
-	nfsd_drc_mem_used -= ses->se_fchannel.maxreqs * NFSD_SLOT_CACHE_SIZE;
+	mem = ses->se_fchannel.maxreqs
+		* (ses->se_fchannel.maxresp_cached - NFSD_MIN_HDR_SEQ_SZ);
+	nfsd_drc_mem_used -= mem;
 	spin_unlock(&nfsd_drc_lock);
 	free_session_slots(ses);
 	kfree(ses);
-- 
1.6.3.3


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

* [PATCH 2/2] nfsd4.1: common slot allocation size calculation
  2009-10-27 23:07 ` [PATCH 1/2] nfsd4.1: fix session memory use calculation J. Bruce Fields
@ 2009-10-27 23:07   ` J. Bruce Fields
  0 siblings, 0 replies; 5+ messages in thread
From: J. Bruce Fields @ 2009-10-27 23:07 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: pnfs, Andy Adamson, J. Bruce Fields

We do the same calculation in a couple places; use a helper function,
and add a little documentation, in the hopes of preventing bugs like
that fixed in the last patch.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
 fs/nfsd/nfs4state.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index c171371..42dab95 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -524,6 +524,15 @@ free_session_slots(struct nfsd4_session *ses)
 		kfree(ses->se_slots[i]);
 }
 
+/*
+ * We don't actually need to cache the rpc and session headers, so we
+ * can allocate a little less for each slot:
+ */
+static inline int slot_bytes(struct nfsd4_channel_attrs *ca)
+{
+	return ca->maxresp_cached - NFSD_MIN_HDR_SEQ_SZ;
+}
+
 static int
 alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp,
 		   struct nfsd4_create_session *cses)
@@ -555,7 +564,7 @@ alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp,
 	memcpy(new, &tmp, sizeof(*new));
 
 	/* allocate each struct nfsd4_slot and data cache in one piece */
-	cachesize = new->se_fchannel.maxresp_cached - NFSD_MIN_HDR_SEQ_SZ;
+	cachesize = slot_bytes(&new->se_fchannel);
 	for (i = 0; i < new->se_fchannel.maxreqs; i++) {
 		sp = kzalloc(sizeof(*sp) + cachesize, GFP_KERNEL);
 		if (!sp)
@@ -633,8 +642,7 @@ free_session(struct kref *kref)
 
 	ses = container_of(kref, struct nfsd4_session, se_ref);
 	spin_lock(&nfsd_drc_lock);
-	mem = ses->se_fchannel.maxreqs
-		* (ses->se_fchannel.maxresp_cached - NFSD_MIN_HDR_SEQ_SZ);
+	mem = ses->se_fchannel.maxreqs * slot_bytes(&ses->se_fchannel);
 	nfsd_drc_mem_used -= mem;
 	spin_unlock(&nfsd_drc_lock);
 	free_session_slots(ses);
-- 
1.6.3.3


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

* Re: [pnfs] create_session bugfix
  2009-10-27 23:07 create_session bugfix J. Bruce Fields
  2009-10-27 23:07 ` [PATCH 1/2] nfsd4.1: fix session memory use calculation J. Bruce Fields
@ 2009-10-27 23:10 ` J. Bruce Fields
  2009-11-03  6:25 ` Benny Halevy
  2 siblings, 0 replies; 5+ messages in thread
From: J. Bruce Fields @ 2009-10-27 23:10 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: pnfs

On Tue, Oct 27, 2009 at 07:07:40PM -0400, J. Bruce Fields wrote:
> 
> I'm queueing this up for 2.6.33 if there's no objections.

Err.  I meant to send that to linux-nfs, not linux-fsdevel, apologies.
Oh well, pnfs@linux-nfs.org should have anyone that would care anyway.

Perhaps I need more coffee.  And fewer mailing lists.

--b.

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

* Re: [pnfs] create_session bugfix
  2009-10-27 23:07 create_session bugfix J. Bruce Fields
  2009-10-27 23:07 ` [PATCH 1/2] nfsd4.1: fix session memory use calculation J. Bruce Fields
  2009-10-27 23:10 ` [pnfs] create_session bugfix J. Bruce Fields
@ 2009-11-03  6:25 ` Benny Halevy
  2 siblings, 0 replies; 5+ messages in thread
From: Benny Halevy @ 2009-11-03  6:25 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: linux-fsdevel, pnfs

On Oct. 28, 2009, 1:07 +0200, "J. Bruce Fields" <bfields@citi.umich.edu> wrote:
> I'm queueing this up for 2.6.33 if there's no objections.

I've merged both patches also into the pnfs tree so they
get more soak time.

Thanks!

Benny

> 
> --b.
> _______________________________________________
> pNFS mailing list
> pNFS@linux-nfs.org
> http://linux-nfs.org/cgi-bin/mailman/listinfo/pnfs

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

end of thread, other threads:[~2009-11-03  6:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-27 23:07 create_session bugfix J. Bruce Fields
2009-10-27 23:07 ` [PATCH 1/2] nfsd4.1: fix session memory use calculation J. Bruce Fields
2009-10-27 23:07   ` [PATCH 2/2] nfsd4.1: common slot allocation size calculation J. Bruce Fields
2009-10-27 23:10 ` [pnfs] create_session bugfix J. Bruce Fields
2009-11-03  6:25 ` Benny Halevy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.