Commit 0741d378 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Don't allocate memory under mark_lock

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 137b0ed9
...@@ -642,12 +642,7 @@ static int bch2_gc_start(struct bch_fs *c, ...@@ -642,12 +642,7 @@ static int bch2_gc_start(struct bch_fs *c,
{ {
struct bch_dev *ca; struct bch_dev *ca;
unsigned i; unsigned i;
int ret;
/*
* indicate to stripe code that we need to allocate for the gc stripes
* radix tree, too
*/
gc_pos_set(c, gc_phase(GC_PHASE_START));
BUG_ON(c->usage_gc); BUG_ON(c->usage_gc);
...@@ -675,6 +670,18 @@ static int bch2_gc_start(struct bch_fs *c, ...@@ -675,6 +670,18 @@ static int bch2_gc_start(struct bch_fs *c,
} }
} }
ret = bch2_ec_mem_alloc(c, true);
if (ret)
return ret;
percpu_down_write(&c->mark_lock);
/*
* indicate to stripe code that we need to allocate for the gc stripes
* radix tree, too
*/
gc_pos_set(c, gc_phase(GC_PHASE_START));
for_each_member_device(ca, c, i) { for_each_member_device(ca, c, i) {
struct bucket_array *dst = __bucket_array(ca, 1); struct bucket_array *dst = __bucket_array(ca, 1);
struct bucket_array *src = __bucket_array(ca, 0); struct bucket_array *src = __bucket_array(ca, 0);
...@@ -699,7 +706,9 @@ static int bch2_gc_start(struct bch_fs *c, ...@@ -699,7 +706,9 @@ static int bch2_gc_start(struct bch_fs *c,
} }
}; };
return bch2_ec_mem_alloc(c, true); percpu_up_write(&c->mark_lock);
return 0;
} }
/** /**
...@@ -732,10 +741,7 @@ int bch2_gc(struct bch_fs *c, struct journal_keys *journal_keys, ...@@ -732,10 +741,7 @@ int bch2_gc(struct bch_fs *c, struct journal_keys *journal_keys,
down_write(&c->gc_lock); down_write(&c->gc_lock);
again: again:
percpu_down_write(&c->mark_lock);
ret = bch2_gc_start(c, metadata_only); ret = bch2_gc_start(c, metadata_only);
percpu_up_write(&c->mark_lock);
if (ret) if (ret)
goto out; goto out;
......
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