Signed-off-by: Ivan Shapovalov <intelfx100@xxxxxxxxx> --- fs/reiser4/blocknrlist.c | 31 ++++++++++++++++++++++++++++--- fs/reiser4/super_ops.c | 7 +++++++ fs/reiser4/txnmgr.h | 2 ++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/fs/reiser4/blocknrlist.c b/fs/reiser4/blocknrlist.c index 2868771..39a4a9b 100644 --- a/fs/reiser4/blocknrlist.c +++ b/fs/reiser4/blocknrlist.c @@ -9,10 +9,13 @@ #include "dformat.h" #include "txnmgr.h" #include "context.h" +#include "super.h" #include <linux/slab.h> #include <linux/list_sort.h> +static struct kmem_cache *blocknr_list_slab = NULL; + /** * Represents an extent range [@start; @end). */ @@ -36,8 +39,8 @@ static blocknr_list_entry *blocknr_list_entry_alloc(void) { blocknr_list_entry *entry; - entry = (blocknr_list_entry *)kmalloc(sizeof(blocknr_list_entry), - reiser4_ctx_gfp_mask_get()); + entry = (blocknr_list_entry *)kmem_cache_alloc(blocknr_list_slab, + reiser4_ctx_gfp_mask_get()); if (entry == NULL) { return NULL; } @@ -51,7 +54,7 @@ static void blocknr_list_entry_free(blocknr_list_entry *entry) { assert("intelfx-12", entry != NULL); - kfree(entry); + kmem_cache_free(blocknr_list_slab, entry); } /** @@ -142,6 +145,28 @@ static int blocknr_list_entry_compare(void* priv UNUSED_ARG, return 0; } +int blocknr_list_init_static(void) +{ + assert("intelfx-54", blocknr_list_slab == NULL); + + blocknr_list_slab = kmem_cache_create("blocknr_list_entry", + sizeof(blocknr_list_entry), + 0, + SLAB_HWCACHE_ALIGN | + SLAB_RECLAIM_ACCOUNT, + NULL); + if (blocknr_list_slab == NULL) { + return RETERR(-ENOMEM); + } + + return 0; +} + +void blocknr_list_done_static(void) +{ + destroy_reiser4_cache(&blocknr_list_slab); +} + void blocknr_list_init(struct list_head* blist) { assert("intelfx-24", blist != NULL); diff --git a/fs/reiser4/super_ops.c b/fs/reiser4/super_ops.c index 81773b3..a63ceb5 100644 --- a/fs/reiser4/super_ops.c +++ b/fs/reiser4/super_ops.c @@ -678,11 +678,17 @@ static int __init init_reiser4(void) if ((result = reiser4_init_d_cursor()) != 0) goto failed_init_d_cursor; + /* initialize cache of blocknr list entries */ + if ((result = blocknr_list_init_static()) != 0) + goto failed_init_blocknr_list; + if ((result = register_filesystem(&reiser4_fs_type)) == 0) { reiser4_debugfs_root = debugfs_create_dir("reiser4", NULL); return 0; } + blocknr_list_done_static(); + failed_init_blocknr_list: reiser4_done_d_cursor(); failed_init_d_cursor: reiser4_done_file_fsdata(); @@ -718,6 +724,7 @@ static void __exit done_reiser4(void) debugfs_remove(reiser4_debugfs_root); result = unregister_filesystem(&reiser4_fs_type); BUG_ON(result != 0); + blocknr_list_done_static(); reiser4_done_d_cursor(); reiser4_done_file_fsdata(); reiser4_done_dentry_fsdata(); diff --git a/fs/reiser4/txnmgr.h b/fs/reiser4/txnmgr.h index 18ca23d..3515de9 100644 --- a/fs/reiser4/txnmgr.h +++ b/fs/reiser4/txnmgr.h @@ -486,6 +486,8 @@ extern int blocknr_set_iterator(txn_atom * atom, struct list_head * bset, int delete); /* This is the block list interface (see blocknrlist.c) */ +extern int blocknr_list_init_static(void); +extern void blocknr_list_done_static(void); extern void blocknr_list_init(struct list_head *blist); extern void blocknr_list_destroy(struct list_head *blist); extern void blocknr_list_merge(struct list_head *from, struct list_head *to); -- 2.0.3 -- To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html