Skip to content

Commit d6d539c

Browse files
author
Kent Overstreet
committed
bcachefs: Reallocate table when we're increasing size
Fixes: c2f6e16 ("bcachefs: Increase size of cuckoo hash table on too many rehashes") Signed-off-by: Kent Overstreet <[email protected]>
1 parent 0e49d3f commit d6d539c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/bcachefs/buckets_waiting_for_journal.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ int bch2_set_bucket_needs_journal_commit(struct buckets_waiting_for_journal *b,
107107
nr_elements += t->d[i].journal_seq > flushed_seq;
108108

109109
new_bits = ilog2(roundup_pow_of_two(nr_elements * 3));
110-
110+
realloc:
111111
n = kvmalloc(sizeof(*n) + (sizeof(n->d[0]) << new_bits), GFP_KERNEL);
112112
if (!n) {
113113
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,
118118
if (nr_rehashes_this_size == 3) {
119119
new_bits++;
120120
nr_rehashes_this_size = 0;
121+
kvfree(n);
122+
goto realloc;
121123
}
122124

123125
nr_rehashes++;

0 commit comments

Comments
 (0)