Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 3096
b: refs/heads/master
c: 5ac049a
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Jun 24, 2005
1 parent ab08257 commit 15d288f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e60d4398a7c20fbe9c4a6cc39d7188ef9f65d2f1
refs/heads/master: 5ac049ac66416bbe84923f7c2384f23f6ee4aa88
22 changes: 17 additions & 5 deletions trunk/fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ static DECLARE_MUTEX(client_sema);

kmem_cache_t *stateowner_slab = NULL;
kmem_cache_t *file_slab = NULL;
kmem_cache_t *stateid_slab = NULL;

void
nfs4_lock_state(void)
Expand Down Expand Up @@ -1010,6 +1011,7 @@ nfsd4_free_slabs(void)
{
nfsd4_free_slab(&stateowner_slab);
nfsd4_free_slab(&file_slab);
nfsd4_free_slab(&stateid_slab);
}

static int
Expand All @@ -1023,6 +1025,10 @@ nfsd4_init_slabs(void)
sizeof(struct nfs4_file), 0, 0, NULL, NULL);
if (file_slab == NULL)
goto out_nomem;
stateid_slab = kmem_cache_create("nfsd4_stateids",
sizeof(struct nfs4_stateid), 0, 0, NULL, NULL);
if (stateid_slab == NULL)
goto out_nomem;
return 0;
out_nomem:
nfsd4_free_slabs();
Expand Down Expand Up @@ -1173,7 +1179,7 @@ release_stateid(struct nfs4_stateid *stp, int flags)
vfsclose++;
} else if (flags & LOCK_STATE)
locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner);
kfree(stp);
kmem_cache_free(stateid_slab, stp);
stp = NULL;
}

Expand Down Expand Up @@ -1606,14 +1612,20 @@ nfs4_check_open(struct nfs4_file *fp, struct nfsd4_open *open, struct nfs4_state
return status;
}

static inline struct nfs4_stateid *
nfs4_alloc_stateid(void)
{
return kmem_cache_alloc(stateid_slab, GFP_KERNEL);
}

static int
nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
struct nfs4_delegation *dp,
struct svc_fh *cur_fh, int flags)
{
struct nfs4_stateid *stp;

stp = kmalloc(sizeof(struct nfs4_stateid), GFP_KERNEL);
stp = nfs4_alloc_stateid();
if (stp == NULL)
return nfserr_resource;

Expand All @@ -1627,7 +1639,7 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp,
if (status) {
if (status == nfserr_dropit)
status = nfserr_jukebox;
kfree(stp);
kmem_cache_free(stateid_slab, stp);
return status;
}
}
Expand Down Expand Up @@ -2627,8 +2639,8 @@ alloc_init_lock_stateid(struct nfs4_stateowner *sop, struct nfs4_file *fp, struc
struct nfs4_stateid *stp;
unsigned int hashval = stateid_hashval(sop->so_id, fp->fi_id);

if ((stp = kmalloc(sizeof(struct nfs4_stateid),
GFP_KERNEL)) == NULL)
stp = nfs4_alloc_stateid();
if (stp == NULL)
goto out;
INIT_LIST_HEAD(&stp->st_hash);
INIT_LIST_HEAD(&stp->st_perfile);
Expand Down

0 comments on commit 15d288f

Please sign in to comment.