* [PATCH] Btrfs: use a slab for btrfs_dio_private
@ 2012-08-03 21:10 Josef Bacik
2012-08-07 22:25 ` Andi Kleen
0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2012-08-03 21:10 UTC (permalink / raw)
To: linux-btrfs
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-07 22:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-03 21:10 [PATCH] Btrfs: use a slab for btrfs_dio_private Josef Bacik
2012-08-07 22:25 ` Andi Kleen
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).