bcachefs: version_upgrade is now an enum
The version_upgrade parameter is now an enum, not a bool, and it's persistent in the superblock: - compatible (default): upgrade to the latest compatible version - incompatible: upgrade to latest incompatible version - none Currently all upgrades are incompatible upgrades, but the next release will introduce major:minor versions. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
24964e1c5c
commit
3045bb958a
@ -573,6 +573,7 @@ enum {
|
||||
BCH_FS_INITIAL_GC_UNFIXED, /* kill when we enumerate fsck errors */
|
||||
BCH_FS_NEED_ANOTHER_GC,
|
||||
|
||||
BCH_FS_VERSION_UPGRADE,
|
||||
BCH_FS_HAVE_DELETED_SNAPSHOTS,
|
||||
|
||||
/* errors: */
|
||||
|
@ -1747,6 +1747,7 @@ LE64_BITMASK(BCH_SB_JOURNAL_RECLAIM_DELAY,struct bch_sb, flags[4], 0, 32);
|
||||
LE64_BITMASK(BCH_SB_JOURNAL_TRANSACTION_NAMES,struct bch_sb, flags[4], 32, 33);
|
||||
LE64_BITMASK(BCH_SB_NOCOW, struct bch_sb, flags[4], 33, 34);
|
||||
LE64_BITMASK(BCH_SB_WRITE_BUFFER_SIZE, struct bch_sb, flags[4], 34, 54);
|
||||
LE64_BITMASK(BCH_SB_VERSION_UPGRADE, struct bch_sb, flags[4], 54, 56);
|
||||
|
||||
/* flags[4] 56-64 unused: */
|
||||
|
||||
@ -1819,6 +1820,17 @@ enum bch_sb_compat {
|
||||
|
||||
/* options: */
|
||||
|
||||
#define BCH_VERSION_UPGRADE_OPTS() \
|
||||
x(compatible, 0) \
|
||||
x(incompatible, 1) \
|
||||
x(none, 2)
|
||||
|
||||
enum bch_version_upgrade_opts {
|
||||
#define x(t, n) BCH_VERSION_UPGRADE_##t = n,
|
||||
BCH_VERSION_UPGRADE_OPTS()
|
||||
#undef x
|
||||
};
|
||||
|
||||
#define BCH_REPLICAS_MAX 4U
|
||||
|
||||
#define BCH_BKEY_PTRS_MAX 16U
|
||||
|
@ -16,6 +16,11 @@ const char * const bch2_error_actions[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
const char * const bch2_version_upgrade_opts[] = {
|
||||
BCH_VERSION_UPGRADE_OPTS()
|
||||
NULL
|
||||
};
|
||||
|
||||
const char * const bch2_sb_features[] = {
|
||||
BCH_SB_FEATURES()
|
||||
NULL
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "bcachefs_format.h"
|
||||
|
||||
extern const char * const bch2_error_actions[];
|
||||
extern const char * const bch2_version_upgrade_opts[];
|
||||
extern const char * const bch2_sb_features[];
|
||||
extern const char * const bch2_sb_compat[];
|
||||
extern const char * const bch2_btree_ids[];
|
||||
@ -388,8 +389,8 @@ enum opt_type {
|
||||
NULL, "Reconstruct alloc btree") \
|
||||
x(version_upgrade, u8, \
|
||||
OPT_FS|OPT_MOUNT, \
|
||||
OPT_BOOL(), \
|
||||
BCH2_NO_SB_OPT, false, \
|
||||
OPT_STR(bch2_version_upgrade_opts), \
|
||||
BCH_SB_VERSION_UPGRADE, BCH_VERSION_UPGRADE_compatible, \
|
||||
NULL, "Set superblock to latest version,\n" \
|
||||
"allowing any new features to be used") \
|
||||
x(buckets_nouse, u8, \
|
||||
|
@ -1111,11 +1111,16 @@ static void check_version_upgrade(struct bch_fs *c)
|
||||
{
|
||||
unsigned version = c->sb.version_upgrade_complete ?: c->sb.version;
|
||||
|
||||
if (version < bcachefs_metadata_required_upgrade_below) {
|
||||
if (version < bcachefs_metadata_required_upgrade_below ||
|
||||
(version < bcachefs_metadata_version_current &&
|
||||
c->opts.version_upgrade != BCH_VERSION_UPGRADE_none)) {
|
||||
struct printbuf buf = PRINTBUF;
|
||||
|
||||
if (version != c->sb.version)
|
||||
prt_str(&buf, "version upgrade incomplete:\n");
|
||||
if (version != c->sb.version) {
|
||||
prt_str(&buf, "version upgrade to ");
|
||||
bch2_version_to_text(&buf, c->sb.version);
|
||||
prt_str(&buf, " incomplete:\n");
|
||||
}
|
||||
|
||||
prt_str(&buf, "version ");
|
||||
bch2_version_to_text(&buf, version);
|
||||
@ -1126,9 +1131,9 @@ static void check_version_upgrade(struct bch_fs *c)
|
||||
bch_info(c, "%s", buf.buf);
|
||||
printbuf_exit(&buf);
|
||||
|
||||
c->opts.version_upgrade = true;
|
||||
c->opts.fsck = true;
|
||||
c->opts.fix_errors = FSCK_OPT_YES;
|
||||
set_bit(BCH_FS_VERSION_UPGRADE, &c->flags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1534,11 +1539,9 @@ 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);
|
||||
|
||||
if (c->sb.version < bcachefs_metadata_version_inode_v3)
|
||||
c->opts.version_upgrade = true;
|
||||
|
||||
if (c->opts.version_upgrade) {
|
||||
if (c->opts.version_upgrade != BCH_VERSION_UPGRADE_none) {
|
||||
c->disk_sb.sb->version = cpu_to_le16(bcachefs_metadata_version_current);
|
||||
SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, bcachefs_metadata_version_current);
|
||||
c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALL);
|
||||
bch2_write_super(c);
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ int bch2_write_super(struct bch_fs *c)
|
||||
closure_init_stack(cl);
|
||||
memset(&sb_written, 0, sizeof(sb_written));
|
||||
|
||||
if (c->opts.version_upgrade) {
|
||||
if (test_bit(BCH_FS_VERSION_UPGRADE, &c->flags)) {
|
||||
c->disk_sb.sb->magic = BCHFS_MAGIC;
|
||||
c->disk_sb.sb->layout.magic = BCHFS_MAGIC;
|
||||
}
|
||||
@ -1197,11 +1197,11 @@ int bch2_fs_mark_dirty(struct bch_fs *c)
|
||||
if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) > bcachefs_metadata_version_current)
|
||||
SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, bcachefs_metadata_version_current);
|
||||
|
||||
if (c->opts.version_upgrade ||
|
||||
if (test_bit(BCH_FS_VERSION_UPGRADE, &c->flags) ||
|
||||
c->sb.version > bcachefs_metadata_version_current)
|
||||
c->disk_sb.sb->version = cpu_to_le16(bcachefs_metadata_version_current);
|
||||
|
||||
if (c->opts.version_upgrade)
|
||||
if (test_bit(BCH_FS_VERSION_UPGRADE, &c->flags))
|
||||
c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALL);
|
||||
|
||||
c->disk_sb.sb->features[0] |= cpu_to_le64(BCH_SB_FEATURES_ALWAYS);
|
||||
|
Loading…
x
Reference in New Issue
Block a user