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: */
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: */
/* 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
NULL
};
+const char * const bch2_version_upgrade_opts[] = {
+ BCH_VERSION_UPGRADE_OPTS()
+ NULL
+};
+
const char * const bch2_sb_features[] = {
BCH_SB_FEATURES()
NULL
#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[];
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, \
{
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);
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);
}
}
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);
}
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;
}
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);