]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bcachefs: rebalance should wakeup on shutdown if disabled
authorDaniel Hill <daniel@gluo.nz>
Sun, 26 Nov 2023 06:33:31 +0000 (19:33 +1300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2024 18:14:30 +0000 (19:14 +0100)
commit 0c069781ddfa4e31c169a8eced1ee90b8929d522 upstream.

Signed-off-by: Daniel Hill <daniel@gluo.nz>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/bcachefs/move.c
fs/bcachefs/move.h
fs/bcachefs/rebalance.c

index 54830ee0ed886795233e939158d9b4f417d11f85..f3dac4511af19b747e1abd9177f1bfa273eb268e 100644 (file)
@@ -152,7 +152,7 @@ void bch2_move_ctxt_wait_for_io(struct moving_context *ctxt)
                atomic_read(&ctxt->write_sectors) != sectors_pending);
 }
 
-static void bch2_moving_ctxt_flush_all(struct moving_context *ctxt)
+void bch2_moving_ctxt_flush_all(struct moving_context *ctxt)
 {
        move_ctxt_wait_event(ctxt, list_empty(&ctxt->reads));
        bch2_trans_unlock_long(ctxt->trans);
index 0906aa2d1de29c328fbbe9a43ca877eb7fc02471..c5a7aed2e1ae15992b9f5b7df60728ca4e1d6627 100644 (file)
@@ -81,6 +81,7 @@ void bch2_moving_ctxt_init(struct moving_context *, struct bch_fs *,
                           struct write_point_specifier, bool);
 struct moving_io *bch2_moving_ctxt_next_pending_write(struct moving_context *);
 void bch2_moving_ctxt_do_pending_writes(struct moving_context *);
+void bch2_moving_ctxt_flush_all(struct moving_context *);
 void bch2_move_ctxt_wait_for_io(struct moving_context *);
 int bch2_move_ratelimit(struct moving_context *);
 
index 3319190b8d9c330fde44ad959bc299aa00d2ba87..ba2606a067d018e22f7b31ec52a50d47e81a43ed 100644 (file)
@@ -317,8 +317,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));