aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNeilBrown <neilb@cse.unsw.edu.au>2005-06-24 01:03:03 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-24 03:06:29 -0400
commit5ac049ac66416bbe84923f7c2384f23f6ee4aa88 (patch)
tree060a781f1f246078c9e8c0c0096be7155771c46d /fs
parente60d4398a7c20fbe9c4a6cc39d7188ef9f65d2f1 (diff)
[PATCH] nfsd4: slabify stateids
Allocate stateid's from a slab cache. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/nfs4state.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 260c1cbe25c4..c5fce309d87e 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -90,6 +90,7 @@ static DECLARE_MUTEX(client_sema);
90 90
91kmem_cache_t *stateowner_slab = NULL; 91kmem_cache_t *stateowner_slab = NULL;
92kmem_cache_t *file_slab = NULL; 92kmem_cache_t *file_slab = NULL;
93kmem_cache_t *stateid_slab = NULL;
93 94
94void 95void
95nfs4_lock_state(void) 96nfs4_lock_state(void)
@@ -1010,6 +1011,7 @@ nfsd4_free_slabs(void)
1010{ 1011{
1011 nfsd4_free_slab(&stateowner_slab); 1012 nfsd4_free_slab(&stateowner_slab);
1012 nfsd4_free_slab(&file_slab); 1013 nfsd4_free_slab(&file_slab);
1014 nfsd4_free_slab(&stateid_slab);
1013} 1015}
1014 1016
1015static int 1017static int
@@ -1023,6 +1025,10 @@ nfsd4_init_slabs(void)
1023 sizeof(struct nfs4_file), 0, 0, NULL, NULL); 1025 sizeof(struct nfs4_file), 0, 0, NULL, NULL);
1024 if (file_slab == NULL) 1026 if (file_slab == NULL)
1025 goto out_nomem; 1027 goto out_nomem;
1028 stateid_slab = kmem_cache_create("nfsd4_stateids",
1029 sizeof(struct nfs4_stateid), 0, 0, NULL, NULL);
1030 if (stateid_slab == NULL)
1031 goto out_nomem;
1026 return 0; 1032 return 0;
1027out_nomem: 1033out_nomem:
1028 nfsd4_free_slabs(); 1034 nfsd4_free_slabs();
@@ -1173,7 +1179,7 @@ release_stateid(struct nfs4_stateid *stp, int flags)
1173 vfsclose++; 1179 vfsclose++;
1174 } else if (flags & LOCK_STATE) 1180 } else if (flags & LOCK_STATE)
1175 locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner); 1181 locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner);
1176 kfree(stp); 1182 kmem_cache_free(stateid_slab, stp);
1177 stp = NULL; 1183 stp = NULL;
1178} 1184}
1179 1185
@@ -1606,6 +1612,12 @@ out:
1606 return status; 1612 return status;
1607} 1613}
1608 1614
1615static inline struct nfs4_stateid *
1616nfs4_alloc_stateid(void)
1617{
1618 return kmem_cache_alloc(stateid_slab, GFP_KERNEL);
1619}
1620
1609static int 1621static int
1610nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp, 1622nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
1611 struct nfs4_delegation *dp, 1623 struct nfs4_delegation *dp,
@@ -1613,7 +1625,7 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
1613{ 1625{
1614 struct nfs4_stateid *stp; 1626 struct nfs4_stateid *stp;
1615 1627
1616 stp = kmalloc(sizeof(struct nfs4_stateid), GFP_KERNEL); 1628 stp = nfs4_alloc_stateid();
1617 if (stp == NULL) 1629 if (stp == NULL)
1618 return nfserr_resource; 1630 return nfserr_resource;
1619 1631
@@ -1627,7 +1639,7 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
1627 if (status) { 1639 if (status) {
1628 if (status == nfserr_dropit) 1640 if (status == nfserr_dropit)
1629 status = nfserr_jukebox; 1641 status = nfserr_jukebox;
1630 kfree(stp); 1642 kmem_cache_free(stateid_slab, stp);
1631 return status; 1643 return status;
1632 } 1644 }
1633 } 1645 }
@@ -2627,8 +2639,8 @@ alloc_init_lock_stateid(struct nfs4_stateowner *sop, struct nfs4_file *fp, struc
2627 struct nfs4_stateid *stp; 2639 struct nfs4_stateid *stp;
2628 unsigned int hashval = stateid_hashval(sop->so_id, fp->fi_id); 2640 unsigned int hashval = stateid_hashval(sop->so_id, fp->fi_id);
2629 2641
2630 if ((stp = kmalloc(sizeof(struct nfs4_stateid), 2642 stp = nfs4_alloc_stateid();
2631 GFP_KERNEL)) == NULL) 2643 if (stp == NULL)
2632 goto out; 2644 goto out;
2633 INIT_LIST_HEAD(&stp->st_hash); 2645 INIT_LIST_HEAD(&stp->st_hash);
2634 INIT_LIST_HEAD(&stp->st_perfile); 2646 INIT_LIST_HEAD(&stp->st_perfile);