From: Christoph Hellwig <hch@lst.de>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Jeff Layton <jlayton@primarydata.com>,
Sachin Bhamare <sachin.bhamare@primarydata.com>,
linux-nfs@vger.kernel.org
Subject: [PATCH 1/2] nfsd: add a slab cache for odstate structures
Date: Tue, 28 Apr 2015 14:00:48 +0200 [thread overview]
Message-ID: <1430222449-3921-2-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1430222449-3921-1-git-send-email-hch@lst.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/nfsd/nfs4state.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 09c7056..f417362 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -94,6 +94,7 @@ static struct kmem_cache *lockowner_slab;
static struct kmem_cache *file_slab;
static struct kmem_cache *stateid_slab;
static struct kmem_cache *deleg_slab;
+static struct kmem_cache *odstate_slab;
static void free_session(struct nfsd4_session *);
@@ -482,7 +483,7 @@ alloc_clnt_odstate(struct nfs4_client *clp)
{
struct nfs4_clnt_odstate *co;
- co = kzalloc(sizeof(struct nfs4_clnt_odstate), GFP_KERNEL);
+ co = kmem_cache_zalloc(odstate_slab, GFP_KERNEL);
if (co) {
co->co_client = clp;
atomic_set(&co->co_odcount, 1);
@@ -522,7 +523,7 @@ put_clnt_odstate(struct nfs4_clnt_odstate *co)
spin_unlock(&fp->fi_lock);
nfsd4_return_all_file_layouts(co->co_client, fp);
- kfree(co);
+ kmem_cache_free(odstate_slab, co);
}
}
@@ -3163,6 +3164,7 @@ static void nfsd4_init_file(struct knfsd_fh *fh, unsigned int hashval,
void
nfsd4_free_slabs(void)
{
+ kmem_cache_destroy(odstate_slab);
kmem_cache_destroy(openowner_slab);
kmem_cache_destroy(lockowner_slab);
kmem_cache_destroy(file_slab);
@@ -3193,8 +3195,14 @@ nfsd4_init_slabs(void)
sizeof(struct nfs4_delegation), 0, 0, NULL);
if (deleg_slab == NULL)
goto out_free_stateid_slab;
+ odstate_slab = kmem_cache_create("nfsd4_odstate",
+ sizeof(struct nfs4_clnt_odstate), 0, 0, NULL);
+ if (odstate_slab == NULL)
+ goto out_free_deleg_slab;
return 0;
+out_free_deleg_slab:
+ kmem_cache_destroy(deleg_slab);
out_free_stateid_slab:
kmem_cache_destroy(stateid_slab);
out_free_file_slab:
@@ -4233,7 +4241,7 @@ void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate,
if (open->op_stp)
nfs4_put_stid(&open->op_stp->st_stid);
if (open->op_odstate)
- kfree(open->op_odstate);
+ kmem_cache_free(odstate_slab, open->op_odstate);
}
__be32
--
1.9.1
next prev parent reply other threads:[~2015-04-28 12:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-28 12:00 two odstate optimizations Christoph Hellwig
2015-04-28 12:00 ` Christoph Hellwig [this message]
2015-04-28 12:00 ` [PATCH 2/2] nfsd: don't allocate odstates unless pNFS is enabled Christoph Hellwig
2015-04-28 12:50 ` two odstate optimizations Jeff Layton
2015-04-28 16:31 ` J. Bruce Fields
[not found] ` <CANMZn7___SXopxOB-dO0fBj3keVrkXOTwLaYPazzVLHGtgLvPw@mail.gmail.com>
2015-04-29 14:24 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430222449-3921-2-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=bfields@fieldses.org \
--cc=jlayton@primarydata.com \
--cc=linux-nfs@vger.kernel.org \
--cc=sachin.bhamare@primarydata.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).