diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 6ab98c2299dd..63e9dafa8395 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -344,6 +344,19 @@ static int bch2_fs_read_write_late(struct bch_fs *c) { int ret; + /* + * Data move operations can't run until after check_snapshots has + * completed, and bch2_snapshot_is_ancestor() is available. + * + * Ideally we'd start copygc/rebalance earlier instead of waiting for + * all of recovery/fsck to complete: + */ + ret = bch2_copygc_start(c); + if (ret) { + bch_err(c, "error starting copygc thread"); + return ret; + } + ret = bch2_rebalance_start(c); if (ret) { bch_err(c, "error starting rebalance thread"); @@ -403,12 +416,6 @@ static int __bch2_fs_read_write(struct bch_fs *c, bool early) return ret; } - ret = bch2_copygc_start(c); - if (ret) { - bch_err(c, "error starting copygc thread"); - return ret; - } - if (!early) { ret = bch2_fs_read_write_late(c); if (ret)