diff options
author | NeilBrown <neilb@cse.unsw.edu.au> | 2005-06-24 01:03:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-24 03:06:29 -0400 |
commit | 5b2d21c1965859acc881dd862b6ebbfae67cdc14 (patch) | |
tree | 4d7879cd09f0d0efd5e19e9a008668879327efe9 /fs/nfsd | |
parent | 5ac049ac66416bbe84923f7c2384f23f6ee4aa88 (diff) |
[PATCH] nfsd4: slabify delegations
Allocate delegations 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/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c5fce309d87e..927d2007d5ab 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -72,8 +72,6 @@ u32 add_perclient = 0; | |||
72 | u32 del_perclient = 0; | 72 | u32 del_perclient = 0; |
73 | u32 vfsopen = 0; | 73 | u32 vfsopen = 0; |
74 | u32 vfsclose = 0; | 74 | u32 vfsclose = 0; |
75 | u32 alloc_delegation= 0; | ||
76 | u32 free_delegation= 0; | ||
77 | 75 | ||
78 | /* forward declarations */ | 76 | /* forward declarations */ |
79 | struct nfs4_stateid * find_stateid(stateid_t *stid, int flags); | 77 | struct nfs4_stateid * find_stateid(stateid_t *stid, int flags); |
@@ -91,6 +89,7 @@ static DECLARE_MUTEX(client_sema); | |||
91 | kmem_cache_t *stateowner_slab = NULL; | 89 | kmem_cache_t *stateowner_slab = NULL; |
92 | kmem_cache_t *file_slab = NULL; | 90 | kmem_cache_t *file_slab = NULL; |
93 | kmem_cache_t *stateid_slab = NULL; | 91 | kmem_cache_t *stateid_slab = NULL; |
92 | kmem_cache_t *deleg_slab = NULL; | ||
94 | 93 | ||
95 | void | 94 | void |
96 | nfs4_lock_state(void) | 95 | nfs4_lock_state(void) |
@@ -138,8 +137,8 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_f | |||
138 | struct nfs4_callback *cb = &stp->st_stateowner->so_client->cl_callback; | 137 | struct nfs4_callback *cb = &stp->st_stateowner->so_client->cl_callback; |
139 | 138 | ||
140 | dprintk("NFSD alloc_init_deleg\n"); | 139 | dprintk("NFSD alloc_init_deleg\n"); |
141 | if ((dp = kmalloc(sizeof(struct nfs4_delegation), | 140 | dp = kmem_cache_alloc(deleg_slab, GFP_KERNEL); |
142 | GFP_KERNEL)) == NULL) | 141 | if (dp == NULL) |
143 | return dp; | 142 | return dp; |
144 | INIT_LIST_HEAD(&dp->dl_del_perfile); | 143 | INIT_LIST_HEAD(&dp->dl_del_perfile); |
145 | INIT_LIST_HEAD(&dp->dl_del_perclnt); | 144 | INIT_LIST_HEAD(&dp->dl_del_perclnt); |
@@ -164,7 +163,6 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_f | |||
164 | atomic_set(&dp->dl_count, 1); | 163 | atomic_set(&dp->dl_count, 1); |
165 | list_add(&dp->dl_del_perfile, &fp->fi_del_perfile); | 164 | list_add(&dp->dl_del_perfile, &fp->fi_del_perfile); |
166 | list_add(&dp->dl_del_perclnt, &clp->cl_del_perclnt); | 165 | list_add(&dp->dl_del_perclnt, &clp->cl_del_perclnt); |
167 | alloc_delegation++; | ||
168 | return dp; | 166 | return dp; |
169 | } | 167 | } |
170 | 168 | ||
@@ -173,8 +171,7 @@ nfs4_put_delegation(struct nfs4_delegation *dp) | |||
173 | { | 171 | { |
174 | if (atomic_dec_and_test(&dp->dl_count)) { | 172 | if (atomic_dec_and_test(&dp->dl_count)) { |
175 | dprintk("NFSD: freeing dp %p\n",dp); | 173 | dprintk("NFSD: freeing dp %p\n",dp); |
176 | kfree(dp); | 174 | kmem_cache_free(deleg_slab, dp); |
177 | free_delegation++; | ||
178 | } | 175 | } |
179 | } | 176 | } |
180 | 177 | ||
@@ -1012,6 +1009,7 @@ nfsd4_free_slabs(void) | |||
1012 | nfsd4_free_slab(&stateowner_slab); | 1009 | nfsd4_free_slab(&stateowner_slab); |
1013 | nfsd4_free_slab(&file_slab); | 1010 | nfsd4_free_slab(&file_slab); |
1014 | nfsd4_free_slab(&stateid_slab); | 1011 | nfsd4_free_slab(&stateid_slab); |
1012 | nfsd4_free_slab(&deleg_slab); | ||
1015 | } | 1013 | } |
1016 | 1014 | ||
1017 | static int | 1015 | static int |
@@ -1029,6 +1027,10 @@ nfsd4_init_slabs(void) | |||
1029 | sizeof(struct nfs4_stateid), 0, 0, NULL, NULL); | 1027 | sizeof(struct nfs4_stateid), 0, 0, NULL, NULL); |
1030 | if (stateid_slab == NULL) | 1028 | if (stateid_slab == NULL) |
1031 | goto out_nomem; | 1029 | goto out_nomem; |
1030 | deleg_slab = kmem_cache_create("nfsd4_delegations", | ||
1031 | sizeof(struct nfs4_delegation), 0, 0, NULL, NULL); | ||
1032 | if (deleg_slab == NULL) | ||
1033 | goto out_nomem; | ||
1032 | return 0; | 1034 | return 0; |
1033 | out_nomem: | 1035 | out_nomem: |
1034 | nfsd4_free_slabs(); | 1036 | nfsd4_free_slabs(); |
@@ -3312,9 +3314,6 @@ __nfs4_state_shutdown(void) | |||
3312 | add_perclient, del_perclient); | 3314 | add_perclient, del_perclient); |
3313 | dprintk("NFSD: vfsopen %d vfsclose %d\n", | 3315 | dprintk("NFSD: vfsopen %d vfsclose %d\n", |
3314 | vfsopen, vfsclose); | 3316 | vfsopen, vfsclose); |
3315 | dprintk("NFSD: alloc_delegation %d free_delegation %d\n", | ||
3316 | alloc_delegation, free_delegation); | ||
3317 | |||
3318 | } | 3317 | } |
3319 | 3318 | ||
3320 | void | 3319 | void |