Commit 74b33393 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: x-macro metadata version enum

Now we've got strings for metadata versions - this changes
bch2_sb_to_text() and our mount log message to use it.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 3a306f3c
...@@ -1279,19 +1279,23 @@ struct bch_sb_field_journal_seq_blacklist { ...@@ -1279,19 +1279,23 @@ struct bch_sb_field_journal_seq_blacklist {
#define BCH_JSET_VERSION_OLD 2 #define BCH_JSET_VERSION_OLD 2
#define BCH_BSET_VERSION_OLD 3 #define BCH_BSET_VERSION_OLD 3
#define BCH_METADATA_VERSIONS() \
x(bkey_renumber, 10) \
x(inode_btree_change, 11) \
x(snapshot, 12) \
x(inode_backpointers, 13) \
x(btree_ptr_sectors_written, 14) \
x(snapshot_2, 15) \
x(reflink_p_fix, 16) \
x(subvol_dirent, 17) \
x(inode_v2, 18)
enum bcachefs_metadata_version { enum bcachefs_metadata_version {
bcachefs_metadata_version_min = 9, bcachefs_metadata_version_min = 9,
bcachefs_metadata_version_new_versioning = 10, #define x(t, n) bcachefs_metadata_version_##t = n,
bcachefs_metadata_version_bkey_renumber = 10, BCH_METADATA_VERSIONS()
bcachefs_metadata_version_inode_btree_change = 11, #undef x
bcachefs_metadata_version_snapshot = 12, bcachefs_metadata_version_max
bcachefs_metadata_version_inode_backpointers = 13,
bcachefs_metadata_version_btree_ptr_sectors_written = 14,
bcachefs_metadata_version_snapshot_2 = 15,
bcachefs_metadata_version_reflink_p_fix = 16,
bcachefs_metadata_version_subvol_dirent = 17,
bcachefs_metadata_version_inode_v2 = 18,
bcachefs_metadata_version_max = 19,
}; };
#define bcachefs_metadata_version_current (bcachefs_metadata_version_max - 1) #define bcachefs_metadata_version_current (bcachefs_metadata_version_max - 1)
......
...@@ -1887,7 +1887,7 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, unsigned flags) ...@@ -1887,7 +1887,7 @@ void __bch2_btree_node_write(struct bch_fs *c, struct btree *b, unsigned flags)
BUG_ON(BSET_BIG_ENDIAN(i) != CPU_BIG_ENDIAN); BUG_ON(BSET_BIG_ENDIAN(i) != CPU_BIG_ENDIAN);
BUG_ON(i->seq != b->data->keys.seq); BUG_ON(i->seq != b->data->keys.seq);
i->version = c->sb.version < bcachefs_metadata_version_new_versioning i->version = c->sb.version < bcachefs_metadata_version_bkey_renumber
? cpu_to_le16(BCH_BSET_VERSION_OLD) ? cpu_to_le16(BCH_BSET_VERSION_OLD)
: cpu_to_le16(c->sb.version); : cpu_to_le16(c->sb.version);
SET_BSET_OFFSET(i, b->written); SET_BSET_OFFSET(i, b->written);
......
...@@ -1574,7 +1574,7 @@ void bch2_journal_write(struct closure *cl) ...@@ -1574,7 +1574,7 @@ void bch2_journal_write(struct closure *cl)
BUG_ON(vstruct_sectors(jset, c->block_bits) > w->sectors); BUG_ON(vstruct_sectors(jset, c->block_bits) > w->sectors);
jset->magic = cpu_to_le64(jset_magic(c)); jset->magic = cpu_to_le64(jset_magic(c));
jset->version = c->sb.version < bcachefs_metadata_version_new_versioning jset->version = c->sb.version < bcachefs_metadata_version_bkey_renumber
? cpu_to_le32(BCH_JSET_VERSION_OLD) ? cpu_to_le32(BCH_JSET_VERSION_OLD)
: cpu_to_le32(c->sb.version); : cpu_to_le32(c->sb.version);
......
...@@ -9,7 +9,12 @@ ...@@ -9,7 +9,12 @@
#include "super-io.h" #include "super-io.h"
#include "util.h" #include "util.h"
#define x(t, n) #t, #define x(t, n) [n] = #t,
const char * const bch2_metadata_versions[] = {
BCH_METADATA_VERSIONS()
NULL
};
const char * const bch2_error_actions[] = { const char * const bch2_error_actions[] = {
BCH_ERROR_ACTIONS() BCH_ERROR_ACTIONS()
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include "bcachefs_format.h" #include "bcachefs_format.h"
extern const char * const bch2_metadata_versions[];
extern const char * const bch2_error_actions[]; extern const char * const bch2_error_actions[];
extern const char * const bch2_sb_features[]; extern const char * const bch2_sb_features[];
extern const char * const bch2_sb_compat[]; extern const char * const bch2_sb_compat[];
......
...@@ -263,7 +263,7 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out) ...@@ -263,7 +263,7 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out)
int ret; int ret;
version = le16_to_cpu(sb->version); version = le16_to_cpu(sb->version);
version_min = version >= bcachefs_metadata_version_new_versioning version_min = version >= bcachefs_metadata_version_bkey_renumber
? le16_to_cpu(sb->version_min) ? le16_to_cpu(sb->version_min)
: version; : version;
...@@ -518,7 +518,7 @@ static int read_one_super(struct bch_sb_handle *sb, u64 offset, struct printbuf ...@@ -518,7 +518,7 @@ static int read_one_super(struct bch_sb_handle *sb, u64 offset, struct printbuf
} }
version = le16_to_cpu(sb->sb->version); version = le16_to_cpu(sb->sb->version);
version_min = version >= bcachefs_metadata_version_new_versioning version_min = version >= bcachefs_metadata_version_bkey_renumber
? le16_to_cpu(sb->sb->version_min) ? le16_to_cpu(sb->sb->version_min)
: version; : version;
...@@ -1552,12 +1552,12 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb, ...@@ -1552,12 +1552,12 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb,
pr_buf(out, "Version:"); pr_buf(out, "Version:");
pr_tab(out); pr_tab(out);
pr_buf(out, "%u", le16_to_cpu(sb->version)); pr_buf(out, "%s", bch2_metadata_versions[le16_to_cpu(sb->version)]);
pr_newline(out); pr_newline(out);
pr_buf(out, "Oldest version on disk:"); pr_buf(out, "Oldest version on disk:");
pr_tab(out); pr_tab(out);
pr_buf(out, "%u", le16_to_cpu(sb->version_min)); pr_buf(out, "%u", bch2_metadata_versions[le16_to_cpu(sb->version_min)]);
pr_newline(out); pr_newline(out);
pr_buf(out, "Created:"); pr_buf(out, "Created:");
......
...@@ -897,7 +897,7 @@ static void print_mount_opts(struct bch_fs *c) ...@@ -897,7 +897,7 @@ static void print_mount_opts(struct bch_fs *c)
if (!p.pos) if (!p.pos)
pr_buf(&p, "(null)"); pr_buf(&p, "(null)");
bch_info(c, "mounted with opts: %s", p.buf); bch_info(c, "mounted version=%s opts=%s", bch2_metadata_versions[c->sb.version], p.buf);
printbuf_exit(&p); printbuf_exit(&p);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment