Commit 0c069781 authored by Daniel Hill's avatar Daniel Hill Committed by Kent Overstreet

bcachefs: rebalance should wakeup on shutdown if disabled

Signed-off-by: default avatarDaniel Hill <daniel@gluo.nz>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 74529338
...@@ -159,7 +159,7 @@ void bch2_move_ctxt_wait_for_io(struct moving_context *ctxt) ...@@ -159,7 +159,7 @@ void bch2_move_ctxt_wait_for_io(struct moving_context *ctxt)
atomic_read(&ctxt->write_sectors) != sectors_pending); 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)); move_ctxt_wait_event(ctxt, list_empty(&ctxt->reads));
bch2_trans_unlock_long(ctxt->trans); bch2_trans_unlock_long(ctxt->trans);
......
...@@ -83,6 +83,7 @@ void bch2_moving_ctxt_init(struct moving_context *, struct bch_fs *, ...@@ -83,6 +83,7 @@ void bch2_moving_ctxt_init(struct moving_context *, struct bch_fs *,
struct write_point_specifier, bool); struct write_point_specifier, bool);
struct moving_io *bch2_moving_ctxt_next_pending_write(struct moving_context *); 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_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 *); void bch2_move_ctxt_wait_for_io(struct moving_context *);
int bch2_move_ratelimit(struct moving_context *); int bch2_move_ratelimit(struct moving_context *);
......
...@@ -332,8 +332,16 @@ static int do_rebalance(struct moving_context *ctxt) ...@@ -332,8 +332,16 @@ static int do_rebalance(struct moving_context *ctxt)
BTREE_ID_rebalance_work, POS_MIN, BTREE_ID_rebalance_work, POS_MIN,
BTREE_ITER_ALL_SNAPSHOTS); BTREE_ITER_ALL_SNAPSHOTS);
while (!bch2_move_ratelimit(ctxt) && while (!bch2_move_ratelimit(ctxt)) {
!kthread_wait_freezable(r->enabled)) { 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); bch2_trans_begin(trans);
ret = bkey_err(k = next_rebalance_entry(trans, &rebalance_work_iter)); ret = bkey_err(k = next_rebalance_entry(trans, &rebalance_work_iter));
......
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