Commit 7b506b10 authored by Michal Hocko's avatar Michal Hocko Committed by Theodore Ts'o

jbd2: get rid of open coded allocation retry loop

insert_revoke_hash does an open coded endless allocation loop if
journal_oom_retry is true. It doesn't implement any allocation fallback
strategy between the retries, though. The memory allocator doesn't know
about the never fail requirement so it cannot potentially help to move
on with the allocation (e.g. use memory reserves).

Get rid of the retry loop and use __GFP_NOFAIL instead. We will lose the
debugging message but I am not sure it is anyhow helpful.

Do the same for journal_alloc_journal_head which is doing a similar
thing.
Signed-off-by: default avatarMichal Hocko <mhocko@suse.cz>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent b03a2f7e
...@@ -2377,10 +2377,8 @@ static struct journal_head *journal_alloc_journal_head(void) ...@@ -2377,10 +2377,8 @@ static struct journal_head *journal_alloc_journal_head(void)
if (!ret) { if (!ret) {
jbd_debug(1, "out of memory for journal_head\n"); jbd_debug(1, "out of memory for journal_head\n");
pr_notice_ratelimited("ENOMEM in %s, retrying.\n", __func__); pr_notice_ratelimited("ENOMEM in %s, retrying.\n", __func__);
while (!ret) { ret = kmem_cache_zalloc(jbd2_journal_head_cache,
yield(); GFP_NOFS | __GFP_NOFAIL);
ret = kmem_cache_zalloc(jbd2_journal_head_cache, GFP_NOFS);
}
} }
return ret; return ret;
} }
......
...@@ -141,11 +141,13 @@ static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr, ...@@ -141,11 +141,13 @@ static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr,
{ {
struct list_head *hash_list; struct list_head *hash_list;
struct jbd2_revoke_record_s *record; struct jbd2_revoke_record_s *record;
gfp_t gfp_mask = GFP_NOFS;
repeat: if (journal_oom_retry)
record = kmem_cache_alloc(jbd2_revoke_record_cache, GFP_NOFS); gfp_mask |= __GFP_NOFAIL;
record = kmem_cache_alloc(jbd2_revoke_record_cache, gfp_mask);
if (!record) if (!record)
goto oom; return -ENOMEM;
record->sequence = seq; record->sequence = seq;
record->blocknr = blocknr; record->blocknr = blocknr;
...@@ -154,13 +156,6 @@ static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr, ...@@ -154,13 +156,6 @@ static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr,
list_add(&record->hash, hash_list); list_add(&record->hash, hash_list);
spin_unlock(&journal->j_revoke_lock); spin_unlock(&journal->j_revoke_lock);
return 0; return 0;
oom:
if (!journal_oom_retry)
return -ENOMEM;
jbd_debug(1, "ENOMEM in %s, retrying\n", __func__);
yield();
goto repeat;
} }
/* Find a revoke record in the journal's hash table. */ /* Find a revoke record in the journal's hash table. */
......
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