diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 67bba156cce9..bbb896a8aae5 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -1031,6 +1031,7 @@ int bch2_fs_initialize(struct bch_fs *c) struct bkey_inode_buf packed_inode; struct qstr lostfound = QSTR("lost+found"); int ret; + struct bch_member *m; bch_notice(c, "initializing new filesystem"); set_bit(BCH_FS_new_fs, &c->flags); @@ -1039,6 +1040,7 @@ int bch2_fs_initialize(struct bch_fs *c) c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_extents_above_btree_updates_done); c->disk_sb.sb->compat[0] |= cpu_to_le64(1ULL << BCH_COMPAT_bformat_overflow_done); + bch2_check_version_downgrade(c); if (c->opts.version_upgrade != BCH_VERSION_UPGRADE_none) { @@ -1086,8 +1088,18 @@ int bch2_fs_initialize(struct bch_fs *c) bch_verbose(c, "marking superblocks"); ret = bch2_trans_mark_dev_sbs(c); bch_err_msg(c, ret, "marking superblocks"); - if (ret) + if (ret) { + mutex_lock(&c->sb_lock); + for_each_member_device(c, ca) { + m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); + bch_notice(c, "freespace initialized: %lld", BCH_MEMBER_FREESPACE_INITIALIZED(m)); + SET_BCH_MEMBER_FREESPACE_INITIALIZED(m, false); + ca->mi = bch2_mi_to_cpu(m); + } + mutex_unlock(&c->sb_lock); + goto err; + } for_each_online_member(c, ca) ca->new_fs_bucket_idx = 0;