Skip to content

Commit

Permalink
bcachefs: Reallocate table when we're increasing size
Browse files Browse the repository at this point in the history
Fixes: c2f6e16 ("bcachefs: Increase size of cuckoo hash table on too many rehashes")
Signed-off-by: Kent Overstreet <[email protected]>
  • Loading branch information
Kent Overstreet committed Aug 19, 2024
1 parent 0e49d3f commit d6d539c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/bcachefs/buckets_waiting_for_journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

new_bits = ilog2(roundup_pow_of_two(nr_elements * 3));

realloc:
n = kvmalloc(sizeof(*n) + (sizeof(n->d[0]) << new_bits), GFP_KERNEL);
if (!n) {
ret = -BCH_ERR_ENOMEM_buckets_waiting_for_journal_set;
Expand All @@ -118,6 +118,8 @@ int bch2_set_bucket_needs_journal_commit(struct buckets_waiting_for_journal *b,
if (nr_rehashes_this_size == 3) {
new_bits++;
nr_rehashes_this_size = 0;
kvfree(n);
goto realloc;
}

nr_rehashes++;
Expand Down

0 comments on commit d6d539c

Please sign in to comment.