diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-03-21 16:20:40 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:56 -0400 |
commit | 73590619ec1b557c2dc64825d8d22f82f79ec8db (patch) | |
tree | 223777e8c79aa73687b37d9bdd7b9b33ab31b0f0 /fs/bcachefs/recovery.c | |
parent | 84cc758d6b19ae8a92389306fe3510e58a08d90c (diff) | |
download | lwn-73590619ec1b557c2dc64825d8d22f82f79ec8db.tar.gz lwn-73590619ec1b557c2dc64825d8d22f82f79ec8db.zip |
bcachefs: Don't unconditially version_upgrade in initialize
This is mkfs's job. Also, clean up the handling of feature bits some.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r-- | fs/bcachefs/recovery.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 03a25dd5acc6..92f7568175eb 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -991,11 +991,17 @@ int bch2_fs_recovery(struct bch_fs *c) goto err; } + if (!c->sb.clean && + !(c->sb.features & (1ULL << BCH_FEATURE_extents_above_btree_updates))) { + bch_err(c, "filesystem needs recovery from older version; run fsck from older bcachefs-tools to fix"); + ret = -EINVAL; + goto err; + } + if (!(c->sb.features & (1ULL << BCH_FEATURE_alloc_v2))) { bch_info(c, "alloc_v2 feature bit not set, fsck required"); c->opts.fsck = true; c->opts.fix_errors = FSCK_OPT_YES; - c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_alloc_v2; } if (!c->replicas.entries || @@ -1061,13 +1067,6 @@ use_clean: blacklist_seq = journal_seq = le64_to_cpu(clean->journal_seq) + 1; } - if (!c->sb.clean && - !(c->sb.features & (1ULL << BCH_FEATURE_extents_above_btree_updates))) { - bch_err(c, "filesystem needs recovery from older version; run fsck from older bcachefs-tools to fix"); - ret = -EINVAL; - goto err; - } - if (c->opts.reconstruct_alloc) { c->sb.compat &= ~(1ULL << BCH_COMPAT_alloc_info); drop_alloc_keys(&c->journal_keys); @@ -1228,9 +1227,6 @@ use_clean: mutex_lock(&c->sb_lock); if (c->opts.version_upgrade) { - if (c->sb.version < bcachefs_metadata_version_new_versioning) - c->disk_sb.sb->version_min = - le16_to_cpu(bcachefs_metadata_version_min); c->disk_sb.sb->version = le16_to_cpu(bcachefs_metadata_version_current); c->disk_sb.sb->features[0] |= BCH_SB_FEATURES_ALL; write_sb = true; @@ -1288,19 +1284,17 @@ int bch2_fs_initialize(struct bch_fs *c) bch_notice(c, "initializing new filesystem"); mutex_lock(&c->sb_lock); - for_each_online_member(ca, c, i) - bch2_mark_dev_superblock(c, ca, 0); - mutex_unlock(&c->sb_lock); - - mutex_lock(&c->sb_lock); - c->disk_sb.sb->version = c->disk_sb.sb->version_min = - le16_to_cpu(bcachefs_metadata_version_current); - c->disk_sb.sb->features[0] |= 1ULL << BCH_FEATURE_atomic_nlink; - c->disk_sb.sb->features[0] |= BCH_SB_FEATURES_ALL; c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_extents_above_btree_updates_done; c->disk_sb.sb->compat[0] |= 1ULL << BCH_COMPAT_bformat_overflow_done; - bch2_write_super(c); + if (c->opts.version_upgrade) { + c->disk_sb.sb->version = le16_to_cpu(bcachefs_metadata_version_current); + c->disk_sb.sb->features[0] |= BCH_SB_FEATURES_ALL; + bch2_write_super(c); + } + + for_each_online_member(ca, c, i) + bch2_mark_dev_superblock(c, ca, 0); mutex_unlock(&c->sb_lock); set_bit(BCH_FS_ALLOC_READ_DONE, &c->flags); |