Skip to content

Commit 757601e

Browse files
author
Kent Overstreet
committed
bcachefs: Don't put rhashtable on stack
Object debugging generally needs special provisions for putting said objects on the stack, which rhashtable does not have. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent f946ce0 commit 757601e

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

fs/bcachefs/movinggc.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <linux/wait.h>
2929

3030
struct buckets_in_flight {
31-
struct rhashtable table;
31+
struct rhashtable *table;
3232
struct move_bucket *first;
3333
struct move_bucket *last;
3434
size_t nr;
@@ -98,7 +98,7 @@ static int bch2_bucket_is_movable(struct btree_trans *trans,
9898
static void move_bucket_free(struct buckets_in_flight *list,
9999
struct move_bucket *b)
100100
{
101-
int ret = rhashtable_remove_fast(&list->table, &b->hash,
101+
int ret = rhashtable_remove_fast(list->table, &b->hash,
102102
bch_move_bucket_params);
103103
BUG_ON(ret);
104104
kfree(b);
@@ -133,7 +133,7 @@ static void move_buckets_wait(struct moving_context *ctxt,
133133
static bool bucket_in_flight(struct buckets_in_flight *list,
134134
struct move_bucket_key k)
135135
{
136-
return rhashtable_lookup_fast(&list->table, &k, bch_move_bucket_params);
136+
return rhashtable_lookup_fast(list->table, &k, bch_move_bucket_params);
137137
}
138138

139139
static int bch2_copygc_get_buckets(struct moving_context *ctxt,
@@ -185,7 +185,7 @@ static int bch2_copygc_get_buckets(struct moving_context *ctxt,
185185
goto err;
186186
}
187187

188-
ret2 = rhashtable_lookup_insert_fast(&buckets_in_flight->table, &b_i->hash,
188+
ret2 = rhashtable_lookup_insert_fast(buckets_in_flight->table, &b_i->hash,
189189
bch_move_bucket_params);
190190
BUG_ON(ret2);
191191

@@ -350,10 +350,13 @@ static int bch2_copygc_thread(void *arg)
350350
struct buckets_in_flight buckets = {};
351351
u64 last, wait;
352352

353-
int ret = rhashtable_init(&buckets.table, &bch_move_bucket_params);
353+
buckets.table = kzalloc(sizeof(*buckets.table), GFP_KERNEL);
354+
int ret = !buckets.table
355+
? -ENOMEM
356+
: rhashtable_init(buckets.table, &bch_move_bucket_params);
354357
bch_err_msg(c, ret, "allocating copygc buckets in flight");
355358
if (ret)
356-
return ret;
359+
goto err;
357360

358361
set_freezable();
359362

@@ -421,11 +424,12 @@ static int bch2_copygc_thread(void *arg)
421424
}
422425

423426
move_buckets_wait(&ctxt, &buckets, true);
424-
rhashtable_destroy(&buckets.table);
427+
rhashtable_destroy(buckets.table);
425428
bch2_moving_ctxt_exit(&ctxt);
426429
bch2_move_stats_exit(&move_stats, c);
427-
428-
return 0;
430+
err:
431+
kfree(buckets.table);
432+
return ret;
429433
}
430434

431435
void bch2_copygc_stop(struct bch_fs *c)

0 commit comments

Comments
 (0)