diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-21 06:34:11 +0300 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-23 00:09:28 +0300 |
commit | 74b33393db54dd321c807c621fad966eb9ec54e5 (patch) | |
tree | 598e0c8ae9467a2b7629670e09db36b66979ae1c /fs/bcachefs | |
parent | 3a306f3c2c303febffefea4caf09b2326107507a (diff) | |
download | linux-74b33393db54dd321c807c621fad966eb9ec54e5.tar.xz |
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: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/bcachefs_format.h | 28 | ||||
-rw-r--r-- | fs/bcachefs/btree_io.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/journal_io.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/opts.c | 7 | ||||
-rw-r--r-- | fs/bcachefs/opts.h | 1 | ||||
-rw-r--r-- | fs/bcachefs/super-io.c | 8 | ||||
-rw-r--r-- | fs/bcachefs/super.c | 2 |
7 files changed, 30 insertions, 20 deletions
diff --git a/fs/bcachefs/bcachefs_format.h b/fs/bcachefs/bcachefs_format.h index ace3df19950d..2c9243031dab 100644 --- a/fs/bcachefs/bcachefs_format.h +++ b/fs/bcachefs/bcachefs_format.h @@ -1279,19 +1279,23 @@ struct bch_sb_field_journal_seq_blacklist { #define BCH_JSET_VERSION_OLD 2 #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 { - bcachefs_metadata_version_min = 9, - bcachefs_metadata_version_new_versioning = 10, - bcachefs_metadata_version_bkey_renumber = 10, - bcachefs_metadata_version_inode_btree_change = 11, - bcachefs_metadata_version_snapshot = 12, - 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, + bcachefs_metadata_version_min = 9, +#define x(t, n) bcachefs_metadata_version_##t = n, + BCH_METADATA_VERSIONS() +#undef x + bcachefs_metadata_version_max }; #define bcachefs_metadata_version_current (bcachefs_metadata_version_max - 1) diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c index 887a1b145cdc..c8f6e120fb43 100644 --- a/fs/bcachefs/btree_io.c +++ b/fs/bcachefs/btree_io.c @@ -1887,7 +1887,7 @@ do_write: BUG_ON(BSET_BIG_ENDIAN(i) != CPU_BIG_ENDIAN); 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(c->sb.version); SET_BSET_OFFSET(i, b->written); diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index e3b3d0b72232..ba43e5771c7c 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -1574,7 +1574,7 @@ void bch2_journal_write(struct closure *cl) BUG_ON(vstruct_sectors(jset, c->block_bits) > w->sectors); 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(c->sb.version); diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c index e78d3b75f6fb..ce5cb7edcbd3 100644 --- a/fs/bcachefs/opts.c +++ b/fs/bcachefs/opts.c @@ -9,7 +9,12 @@ #include "super-io.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[] = { BCH_ERROR_ACTIONS() diff --git a/fs/bcachefs/opts.h b/fs/bcachefs/opts.h index fffe3e066864..eeab4bb22597 100644 --- a/fs/bcachefs/opts.h +++ b/fs/bcachefs/opts.h @@ -8,6 +8,7 @@ #include <linux/sysfs.h> #include "bcachefs_format.h" +extern const char * const bch2_metadata_versions[]; extern const char * const bch2_error_actions[]; extern const char * const bch2_sb_features[]; extern const char * const bch2_sb_compat[]; diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c index bb61a288b7fd..eaa54167d6b3 100644 --- a/fs/bcachefs/super-io.c +++ b/fs/bcachefs/super-io.c @@ -263,7 +263,7 @@ static int bch2_sb_validate(struct bch_sb_handle *disk_sb, struct printbuf *out) int ret; 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) : version; @@ -518,7 +518,7 @@ reread: } 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) : version; @@ -1552,12 +1552,12 @@ void bch2_sb_to_text(struct printbuf *out, struct bch_sb *sb, pr_buf(out, "Version:"); 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_buf(out, "Oldest version on disk:"); 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_buf(out, "Created:"); diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 56b01624d5fb..e4201aecdba1 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -897,7 +897,7 @@ static void print_mount_opts(struct bch_fs *c) if (!p.pos) 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); } |