mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 23:39:18 +00:00
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>
This commit is contained in:
parent
84cc758d6b
commit
73590619ec
@ -114,25 +114,6 @@ static void bch2_alloc_unpack_v1(struct bkey_alloc_unpacked *out,
|
||||
#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)
|
||||
{
|
||||
@ -225,10 +206,7 @@ void bch2_alloc_pack(struct bch_fs *c,
|
||||
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)
|
||||
|
@ -1380,6 +1380,7 @@ LE64_BITMASK(BCH_SB_METADATA_TARGET, struct bch_sb, flags[3], 16, 28);
|
||||
((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 \
|
||||
@ -1387,8 +1388,7 @@ LE64_BITMASK(BCH_SB_METADATA_TARGET, struct bch_sb, flags[3], 16, 28);
|
||||
(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,
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user