From 7c0732b88dfb87b5f32dcf5fdd7984d2acb992b9 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 29 Jun 2022 17:14:06 -0400 Subject: bcachefs: Fix move path when move_stats == NULL This isn't done very often, but it is legitimate Signed-off-by: Kent Overstreet --- fs/bcachefs/move.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'fs/bcachefs/move.c') diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index eae93c65e1c7..8b44d95c32ce 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -140,13 +140,15 @@ void bch2_moving_ctxt_exit(struct moving_context *ctxt) { move_ctxt_wait_event(ctxt, NULL, list_empty(&ctxt->reads)); closure_sync(&ctxt->cl); - progress_list_del(ctxt->c, ctxt->stats); - EBUG_ON(atomic_read(&ctxt->write_sectors)); - trace_move_data(ctxt->c, - atomic64_read(&ctxt->stats->sectors_moved), - atomic64_read(&ctxt->stats->keys_moved)); + if (ctxt->stats) { + progress_list_del(ctxt->c, ctxt->stats); + + trace_move_data(ctxt->c, + atomic64_read(&ctxt->stats->sectors_moved), + atomic64_read(&ctxt->stats->keys_moved)); + } } void bch2_moving_ctxt_init(struct moving_context *ctxt, @@ -164,13 +166,14 @@ void bch2_moving_ctxt_init(struct moving_context *ctxt, ctxt->wp = wp; ctxt->wait_on_copygc = wait_on_copygc; - progress_list_add(c, stats); closure_init_stack(&ctxt->cl); INIT_LIST_HEAD(&ctxt->reads); init_waitqueue_head(&ctxt->wait); - if (stats) + if (stats) { + progress_list_add(c, stats); stats->data_type = BCH_DATA_user; + } } void bch_move_stats_init(struct bch_move_stats *stats, char *name) -- cgit v1.2.3