]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/rebalance.c
Update bcachefs sources to eb83f1f842bb mean and variance: Promote to lib/math
[bcachefs-tools-debian] / libbcachefs / rebalance.c
index fefa4395fabb3ea2d1f36ff2241a028917ceddb4..79bd4ad0126521d3719cc16e2a1a96a5420095a8 100644 (file)
@@ -331,8 +331,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(c->copy_gc_enabled ||
+                                              kthread_should_stop());
+               }
+
+               if (kthread_should_stop())
+                       break;
+
                bch2_trans_begin(trans);
 
                ret = bkey_err(k = next_rebalance_entry(trans, &rebalance_work_iter));