Skip to content

Commit

Permalink
bcachefs: rebalance should wakeup on shutdown if disabled
Browse files Browse the repository at this point in the history
commit 0c06978 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>
  • Loading branch information
YellowOnion authored and gregkh committed Feb 16, 2024
1 parent f114cfc commit 6763051
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs/bcachefs/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions fs/bcachefs/move.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
12 changes: 10 additions & 2 deletions fs/bcachefs/rebalance.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 6763051

Please sign in to comment.