aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2009-10-24 20:52:16 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-10-27 19:34:43 -0400
commitefe0cb6d5a1f20ad4df045a055048afed4c5e660 (patch)
tree850a3205944995a78f321cac0ed04cb260055d14 /fs/nfsd
parentdd829c45640ff14d7a039af40b3b3975f1b2e484 (diff)
nfsd4.1: common slot allocation size calculation
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>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index c17137110412..42dab9587afe 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -524,6 +524,15 @@ free_session_slots(struct nfsd4_session *ses)
524 kfree(ses->se_slots[i]); 524 kfree(ses->se_slots[i]);
525} 525}
526 526
527/*
528 * We don't actually need to cache the rpc and session headers, so we
529 * can allocate a little less for each slot:
530 */
531static inline int slot_bytes(struct nfsd4_channel_attrs *ca)
532{
533 return ca->maxresp_cached - NFSD_MIN_HDR_SEQ_SZ;
534}
535
527static int 536static int
528alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp, 537alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp,
529 struct nfsd4_create_session *cses) 538 struct nfsd4_create_session *cses)
@@ -555,7 +564,7 @@ alloc_init_session(struct svc_rqst *rqstp, struct nfs4_client *clp,
555 memcpy(new, &tmp, sizeof(*new)); 564 memcpy(new, &tmp, sizeof(*new));
556 565
557 /* allocate each struct nfsd4_slot and data cache in one piece */ 566 /* allocate each struct nfsd4_slot and data cache in one piece */
558 cachesize = new->se_fchannel.maxresp_cached - NFSD_MIN_HDR_SEQ_SZ; 567 cachesize = slot_bytes(&new->se_fchannel);
559 for (i = 0; i < new->se_fchannel.maxreqs; i++) { 568 for (i = 0; i < new->se_fchannel.maxreqs; i++) {
560 sp = kzalloc(sizeof(*sp) + cachesize, GFP_KERNEL); 569 sp = kzalloc(sizeof(*sp) + cachesize, GFP_KERNEL);
561 if (!sp) 570 if (!sp)
@@ -633,8 +642,7 @@ free_session(struct kref *kref)
633 642
634 ses = container_of(kref, struct nfsd4_session, se_ref); 643 ses = container_of(kref, struct nfsd4_session, se_ref);
635 spin_lock(&nfsd_drc_lock); 644 spin_lock(&nfsd_drc_lock);
636 mem = ses->se_fchannel.maxreqs 645 mem = ses->se_fchannel.maxreqs * slot_bytes(&ses->se_fchannel);
637 * (ses->se_fchannel.maxresp_cached - NFSD_MIN_HDR_SEQ_SZ);
638 nfsd_drc_mem_used -= mem; 646 nfsd_drc_mem_used -= mem;
639 spin_unlock(&nfsd_drc_lock); 647 spin_unlock(&nfsd_drc_lock);
640 free_session_slots(ses); 648 free_session_slots(ses);