From: Ivan Shapovalov <intelfx100@gmail.com>
To: reiserfs-devel@vger.kernel.org
Cc: edward.shishkin@gmail.com, Ivan Shapovalov <intelfx100@gmail.com>
Subject: [PATCHv7 4/6] reiser4: blocknr_list: use kmem_cache instead of kmalloc for allocating entries.
Date: Thu, 31 Jul 2014 14:19:47 +0400 [thread overview]
Message-ID: <1406801989-6884-5-git-send-email-intelfx100@gmail.com> (raw)
In-Reply-To: <1406801989-6884-1-git-send-email-intelfx100@gmail.com>
Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
---
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
next prev parent reply other threads:[~2014-07-31 10:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 10:19 [PATCHv7 0/6] reiser4: discard support: simplified and race-free initial implementation Ivan Shapovalov
2014-07-31 10:19 ` [PATCHv7 1/6] reiser4: fix reiser4_post_{commit,write_back}_hook() and their invocations Ivan Shapovalov
2014-07-31 10:19 ` [PATCHv7 2/6] reiser4: make space_allocator's check_blocks() reusable Ivan Shapovalov
2014-07-31 10:19 ` [PATCHv7 3/6] reiser4: add an implementation of "block lists", splitted off the discard code Ivan Shapovalov
2014-07-31 10:19 ` Ivan Shapovalov [this message]
2014-07-31 10:19 ` [PATCHv7 5/6] reiser4: blocknr_set: use kmem_cache instead of kmalloc for allocating entries Ivan Shapovalov
2014-07-31 10:19 ` [PATCHv7 6/6] reiser4: discard support: initial implementation using blocknr_list, without extent padding Ivan Shapovalov
2014-07-31 10:34 ` [PATCHv7 0/6] reiser4: discard support: simplified and race-free initial implementation Ivan Shapovalov
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=1406801989-6884-5-git-send-email-intelfx100@gmail.com \
--to=intelfx100@gmail.com \
--cc=edward.shishkin@gmail.com \
--cc=reiserfs-devel@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).