diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-04-18 18:01:49 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2021-11-04 12:24:58 -0400 |
commit | ae13e123f7744d9877b39da65ad0f6fbbed2d3ca (patch) | |
tree | 8fbbfa9be37717776a20c8b0938fb0a2858445ad | |
parent | 13a2d627c23b5c6f27061ff7e38be75fa4a6ea08 (diff) |
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: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/alloc_background.h | 4 | ||||
-rw-r--r-- | fs/bcachefs/super.c | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/fs/bcachefs/alloc_background.h b/fs/bcachefs/alloc_background.h index 73e1c27c96e3..ad15a80602c0 100644 --- a/fs/bcachefs/alloc_background.h +++ b/fs/bcachefs/alloc_background.h @@ -100,10 +100,8 @@ static inline void bch2_wake_allocator(struct bch_dev *ca) rcu_read_lock(); p = rcu_dereference(ca->alloc_thread); - if (p) { + if (p) wake_up_process(p); - ca->allocator_state = ALLOCATOR_running; - } rcu_read_unlock(); } diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 8bead6afd65f..aaf49a6db1f4 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -900,9 +900,16 @@ int bch2_fs_start(struct bch_fs *c) /* * Allocator threads don't start filling copygc reserve until after we * 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); + } if (c->opts.read_only || c->opts.nochanges) { bch2_fs_read_only(c); |