summaryrefslogtreecommitdiff
path: root/fs/bcachefs/rebalance.c
diff options
context:
space:
mode:
authorDaniel Hill <daniel@gluo.nz>2023-11-26 19:33:31 +1300
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-01 11:47:39 -0500
commit0c069781ddfa4e31c169a8eced1ee90b8929d522 (patch)
tree42d4dd63da54901fd5386c306d9f8cc66ffc1882 /fs/bcachefs/rebalance.c
parent74529338805d514a07ba4e6feb25997c4be3bddd (diff)
bcachefs: rebalance should wakeup on shutdown if disabled
Signed-off-by: Daniel Hill <daniel@gluo.nz> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/rebalance.c')
-rw-r--r--fs/bcachefs/rebalance.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/fs/bcachefs/rebalance.c b/fs/bcachefs/rebalance.c
index 1846f38cea38..9c415e14ff9c 100644
--- a/fs/bcachefs/rebalance.c
+++ b/fs/bcachefs/rebalance.c
@@ -332,8 +332,16 @@ static int do_rebalance(struct moving_context *ctxt)
BTREE_ID_rebalance_work, POS_MIN,
BTREE_ITER_ALL_SNAPSHOTS);
- while (!bch2_move_ratelimit(ctxt) &&
- !kthread_wait_freezable(r->enabled)) {
+ while (!bch2_move_ratelimit(ctxt)) {
+ if (!r->enabled) {
+ bch2_moving_ctxt_flush_all(ctxt);
+ kthread_wait_freezable(r->enabled ||
+ kthread_should_stop());
+ }
+
+ if (kthread_should_stop())
+ break;
+
bch2_trans_begin(trans);
ret = bkey_err(k = next_rebalance_entry(trans, &rebalance_work_iter));