Commit d6d539c9 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Reallocate table when we're increasing size

Fixes: c2f6e16a ("bcachefs: Increase size of cuckoo hash table on too many rehashes")
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 0e49d3ff
...@@ -107,7 +107,7 @@ int bch2_set_bucket_needs_journal_commit(struct buckets_waiting_for_journal *b, ...@@ -107,7 +107,7 @@ int bch2_set_bucket_needs_journal_commit(struct buckets_waiting_for_journal *b,
nr_elements += t->d[i].journal_seq > flushed_seq; nr_elements += t->d[i].journal_seq > flushed_seq;
new_bits = ilog2(roundup_pow_of_two(nr_elements * 3)); new_bits = ilog2(roundup_pow_of_two(nr_elements * 3));
realloc:
n = kvmalloc(sizeof(*n) + (sizeof(n->d[0]) << new_bits), GFP_KERNEL); n = kvmalloc(sizeof(*n) + (sizeof(n->d[0]) << new_bits), GFP_KERNEL);
if (!n) { if (!n) {
ret = -BCH_ERR_ENOMEM_buckets_waiting_for_journal_set; ret = -BCH_ERR_ENOMEM_buckets_waiting_for_journal_set;
...@@ -118,6 +118,8 @@ int bch2_set_bucket_needs_journal_commit(struct buckets_waiting_for_journal *b, ...@@ -118,6 +118,8 @@ int bch2_set_bucket_needs_journal_commit(struct buckets_waiting_for_journal *b,
if (nr_rehashes_this_size == 3) { if (nr_rehashes_this_size == 3) {
new_bits++; new_bits++;
nr_rehashes_this_size = 0; nr_rehashes_this_size = 0;
kvfree(n);
goto realloc;
} }
nr_rehashes++; nr_rehashes++;
......
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