From: Josef Bacik <jbacik@fusionio.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs: use a slab for btrfs_dio_private
Date: Fri, 3 Aug 2012 17:10:47 -0400 [thread overview]
Message-ID: <1344028247-3143-1-git-send-email-jbacik@fusionio.com> (raw)
This is in the IO path, let's try to avoid latencies by having our own slab.
Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
fs/btrfs/inode.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 8a8f0d6..351dd3b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -75,6 +75,7 @@ struct kmem_cache *btrfs_trans_handle_cachep;
struct kmem_cache *btrfs_transaction_cachep;
struct kmem_cache *btrfs_path_cachep;
struct kmem_cache *btrfs_free_space_cachep;
+struct kmem_cache *btrfs_dip_cachep;
#define S_SHIFT 12
static unsigned char btrfs_type_by_mode[S_IFMT >> S_SHIFT] = {
@@ -6076,7 +6077,7 @@ failed:
dip->logical_offset + dip->bytes - 1);
bio->bi_private = dip->private;
- kfree(dip);
+ kmem_cache_free(btrfs_dip_cachep, dip);
/* If we had a csum failure make sure to clear the uptodate flag */
if (err)
@@ -6121,7 +6122,7 @@ out_test:
out_done:
bio->bi_private = dip->private;
- kfree(dip);
+ kmem_cache_free(btrfs_dip_cachep, dip);
/* If we had an error make sure to clear the uptodate flag */
if (err)
@@ -6344,7 +6345,7 @@ static void btrfs_submit_direct(int rw, struct bio *bio, struct inode *inode,
skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
- dip = kmalloc(sizeof(*dip), GFP_NOFS);
+ dip = kmem_cache_alloc(btrfs_dip_cachep, GFP_NOFS);
if (!dip) {
ret = -ENOMEM;
goto free_ordered;
@@ -7062,6 +7063,8 @@ void btrfs_destroy_cachep(void)
kmem_cache_destroy(btrfs_path_cachep);
if (btrfs_free_space_cachep)
kmem_cache_destroy(btrfs_free_space_cachep);
+ if (btrfs_dip_cachep)
+ kmem_cache_destroy(btrfs_dip_cachep);
}
int btrfs_init_cachep(void)
@@ -7096,6 +7099,12 @@ int btrfs_init_cachep(void)
if (!btrfs_free_space_cachep)
goto fail;
+ btrfs_dip_cachep = kmem_cache_create("btrfs_dio_private_cache",
+ sizeof(struct btrfs_dio_private), 0,
+ SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD, NULL);
+ if (!btrfs_dip_cachep)
+ goto fail;
+
return 0;
fail:
btrfs_destroy_cachep();
--
1.7.7.6
next reply other threads:[~2012-08-03 21:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-03 21:10 Josef Bacik [this message]
2012-08-07 22:25 ` [PATCH] Btrfs: use a slab for btrfs_dio_private Andi Kleen
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=1344028247-3143-1-git-send-email-jbacik@fusionio.com \
--to=jbacik@fusionio.com \
--cc=linux-btrfs@vger.kernel.org \
/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).