Commit 2ee47eec authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix for copygc getting stuck waiting for reserve to be filled

This fixes a regression from the patch
  bcachefs: Fix copygc dying on startup

In general only the allocator thread itself should be updating
ca->allocator_state, the thread waking up the allocator setting it is an
ugly hack only needed to avoid racing with the copygc threads when we're
first starting up.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent bae895a5
...@@ -100,10 +100,8 @@ static inline void bch2_wake_allocator(struct bch_dev *ca) ...@@ -100,10 +100,8 @@ static inline void bch2_wake_allocator(struct bch_dev *ca)
rcu_read_lock(); rcu_read_lock();
p = rcu_dereference(ca->alloc_thread); p = rcu_dereference(ca->alloc_thread);
if (p) { if (p)
wake_up_process(p); wake_up_process(p);
ca->allocator_state = ALLOCATOR_running;
}
rcu_read_unlock(); rcu_read_unlock();
} }
......
...@@ -908,9 +908,16 @@ int bch2_fs_start(struct bch_fs *c) ...@@ -908,9 +908,16 @@ int bch2_fs_start(struct bch_fs *c)
/* /*
* Allocator threads don't start filling copygc reserve until after we * Allocator threads don't start filling copygc reserve until after we
* set BCH_FS_STARTED - wake them now: * set BCH_FS_STARTED - wake them now:
*
* XXX ugly hack:
* Need to set ca->allocator_state here instead of relying on the
* allocator threads to do it to avoid racing with the copygc threads
* checking it and thinking they have no alloc reserve:
*/ */
for_each_online_member(ca, c, i) for_each_online_member(ca, c, i) {
ca->allocator_state = ALLOCATOR_running;
bch2_wake_allocator(ca); bch2_wake_allocator(ca);
}
if (c->opts.read_only || c->opts.nochanges) { if (c->opts.read_only || c->opts.nochanges) {
bch2_fs_read_only(c); bch2_fs_read_only(c);
......
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