jbd: use kmem_cache_zalloc for allocating journal head
authorZheng Liu <wenqing.lz@taobao.com>
Mon, 29 Apr 2013 09:08:51 +0000 (17:08 +0800)
committerJan Kara <jack@suse.cz>
Mon, 29 Apr 2013 12:34:05 +0000 (14:34 +0200)
This commit tries to use kmem_cache_zalloc instead of kmem_cache_alloc/
memset when a new journal head is alloctated.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/jbd/journal.c

index 81880c6d6b5e68dc1609933a2e3f56aa24034a4c..726a4432cbb15a05f8758f9bcf99e8d74170f569 100644 (file)
@@ -1856,7 +1856,7 @@ static struct journal_head *journal_alloc_journal_head(void)
 #ifdef CONFIG_JBD_DEBUG
        atomic_inc(&nr_journal_heads);
 #endif
-       ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
+       ret = kmem_cache_zalloc(journal_head_cache, GFP_NOFS);
        if (ret == NULL) {
                jbd_debug(1, "out of memory for journal_head\n");
                printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n",
@@ -1864,7 +1864,7 @@ static struct journal_head *journal_alloc_journal_head(void)
 
                while (ret == NULL) {
                        yield();
-                       ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
+                       ret = kmem_cache_zalloc(journal_head_cache, GFP_NOFS);
                }
        }
        return ret;
@@ -1926,10 +1926,8 @@ struct journal_head *journal_add_journal_head(struct buffer_head *bh)
        struct journal_head *new_jh = NULL;
 
 repeat:
-       if (!buffer_jbd(bh)) {
+       if (!buffer_jbd(bh))
                new_jh = journal_alloc_journal_head();
-               memset(new_jh, 0, sizeof(*new_jh));
-       }
 
        jbd_lock_bh_journal_head(bh);
        if (buffer_jbd(bh)) {