Commit 8bb9da94 authored by Zheng Liu's avatar Zheng Liu Committed by Jan Kara

jbd: use kmem_cache_zalloc for allocating journal head

This commit tries to use kmem_cache_zalloc instead of kmem_cache_alloc/
memset when a new journal head is alloctated.
Signed-off-by: default avatarZheng Liu <wenqing.lz@taobao.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent e162b2f8
...@@ -1856,7 +1856,7 @@ static struct journal_head *journal_alloc_journal_head(void) ...@@ -1856,7 +1856,7 @@ static struct journal_head *journal_alloc_journal_head(void)
#ifdef CONFIG_JBD_DEBUG #ifdef CONFIG_JBD_DEBUG
atomic_inc(&nr_journal_heads); atomic_inc(&nr_journal_heads);
#endif #endif
ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); ret = kmem_cache_zalloc(journal_head_cache, GFP_NOFS);
if (ret == NULL) { if (ret == NULL) {
jbd_debug(1, "out of memory for journal_head\n"); jbd_debug(1, "out of memory for journal_head\n");
printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n", printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n",
...@@ -1864,7 +1864,7 @@ static struct journal_head *journal_alloc_journal_head(void) ...@@ -1864,7 +1864,7 @@ static struct journal_head *journal_alloc_journal_head(void)
while (ret == NULL) { while (ret == NULL) {
yield(); yield();
ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); ret = kmem_cache_zalloc(journal_head_cache, GFP_NOFS);
} }
} }
return ret; return ret;
...@@ -1926,10 +1926,8 @@ struct journal_head *journal_add_journal_head(struct buffer_head *bh) ...@@ -1926,10 +1926,8 @@ struct journal_head *journal_add_journal_head(struct buffer_head *bh)
struct journal_head *new_jh = NULL; struct journal_head *new_jh = NULL;
repeat: repeat:
if (!buffer_jbd(bh)) { if (!buffer_jbd(bh))
new_jh = journal_alloc_journal_head(); new_jh = journal_alloc_journal_head();
memset(new_jh, 0, sizeof(*new_jh));
}
jbd_lock_bh_journal_head(bh); jbd_lock_bh_journal_head(bh);
if (buffer_jbd(bh)) { if (buffer_jbd(bh)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment