Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Daniel Hill and committed by
Kent Overstreet
0c069781 74529338

+12 -3
+1 -1
fs/bcachefs/move.c
··· 159 159 atomic_read(&ctxt->write_sectors) != sectors_pending); 160 160 } 161 161 162 - static void bch2_moving_ctxt_flush_all(struct moving_context *ctxt) 162 + void bch2_moving_ctxt_flush_all(struct moving_context *ctxt) 163 163 { 164 164 move_ctxt_wait_event(ctxt, list_empty(&ctxt->reads)); 165 165 bch2_trans_unlock_long(ctxt->trans);
+1
fs/bcachefs/move.h
··· 83 83 struct write_point_specifier, bool); 84 84 struct moving_io *bch2_moving_ctxt_next_pending_write(struct moving_context *); 85 85 void bch2_moving_ctxt_do_pending_writes(struct moving_context *); 86 + void bch2_moving_ctxt_flush_all(struct moving_context *); 86 87 void bch2_move_ctxt_wait_for_io(struct moving_context *); 87 88 int bch2_move_ratelimit(struct moving_context *); 88 89
+10 -2
fs/bcachefs/rebalance.c
··· 332 332 BTREE_ID_rebalance_work, POS_MIN, 333 333 BTREE_ITER_ALL_SNAPSHOTS); 334 334 335 - while (!bch2_move_ratelimit(ctxt) && 336 - !kthread_wait_freezable(r->enabled)) { 335 + while (!bch2_move_ratelimit(ctxt)) { 336 + if (!r->enabled) { 337 + bch2_moving_ctxt_flush_all(ctxt); 338 + kthread_wait_freezable(r->enabled || 339 + kthread_should_stop()); 340 + } 341 + 342 + if (kthread_should_stop()) 343 + break; 344 + 337 345 bch2_trans_begin(trans); 338 346 339 347 ret = bkey_err(k = next_rebalance_entry(trans, &rebalance_work_iter));