Skip to content

Commit

Permalink
jbd: use kmem_cache_zalloc for allocating journal head
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Jan Kara <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
gnehzuil authored and jankara committed Apr 29, 2013
1 parent e162b2f commit 8bb9da9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions fs/jbd/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1856,15 +1856,15 @@ 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",
__func__);

while (ret == NULL) {
yield();
ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS);
ret = kmem_cache_zalloc(journal_head_cache, GFP_NOFS);
}
}
return ret;
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 8bb9da9

Please sign in to comment.