#undef x
}
-static void bch2_alloc_pack_v1(struct bkey_alloc_buf *dst,
- const struct bkey_alloc_unpacked src)
-{
- struct bkey_i_alloc *a = bkey_alloc_init(&dst->k);
- void *d = a->v.data;
- unsigned bytes, idx = 0;
-
- a->k.p = POS(src.dev, src.bucket);
- a->v.fields = 0;
- a->v.gen = src.gen;
-
-#define x(_name, _bits) alloc_field_v1_put(a, &d, idx++, src._name);
- BCH_ALLOC_FIELDS_V1()
-#undef x
- bytes = (void *) d - (void *) &a->v;
- set_bkey_val_bytes(&a->k, bytes);
- memset_u64s_tail(&a->v, 0, bytes);
-}
-
static int bch2_alloc_unpack_v2(struct bkey_alloc_unpacked *out,
struct bkey_s_c k)
{
struct bkey_alloc_buf *dst,
const struct bkey_alloc_unpacked src)
{
- if (c->sb.features & (1ULL << BCH_FEATURE_alloc_v2))
- bch2_alloc_pack_v2(dst, src);
- else
- bch2_alloc_pack_v1(dst, src);
+ bch2_alloc_pack_v2(dst, src);
}
static unsigned bch_alloc_val_u64s(const struct bch_alloc *a)
((1ULL << BCH_FEATURE_new_extent_overwrite)| \
(1ULL << BCH_FEATURE_extents_above_btree_updates)|\
(1ULL << BCH_FEATURE_btree_updates_journalled)|\
+ (1ULL << BCH_FEATURE_alloc_v2)|\
(1ULL << BCH_FEATURE_extents_across_btree_nodes))
#define BCH_SB_FEATURES_ALL \
(1ULL << BCH_FEATURE_new_siphash)| \
(1ULL << BCH_FEATURE_btree_ptr_v2)| \
(1ULL << BCH_FEATURE_new_varint)| \
- (1ULL << BCH_FEATURE_journal_no_flush)| \
- (1ULL << BCH_FEATURE_alloc_v2))
+ (1ULL << BCH_FEATURE_journal_no_flush))
enum bch_sb_feature {
#define x(f, n) BCH_FEATURE_##f,
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 ||
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);
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;
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);