summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal_io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-06-29 03:27:07 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:10:05 +0300
commita02a0121b3de81f985d6c751f1557c7aea832b9a (patch)
treebe6dcc255c2c8b389fa9743345e4b91ce2dfb40d /fs/bcachefs/journal_io.c
parente3804b55e4358cf5a235fa1ba32204af9f7046dd (diff)
downloadlinux-a02a0121b3de81f985d6c751f1557c7aea832b9a.tar.xz
bcachefs: bch2_version_compatible()
This adds a new helper for checking if an on-disk version is compatible with the running version of bcachefs - prep work for introducing major:minor version numbers. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r--fs/bcachefs/journal_io.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c
index 7d0dd1b1d5cf..a084c6d0fe23 100644
--- a/fs/bcachefs/journal_io.c
+++ b/fs/bcachefs/journal_io.c
@@ -745,14 +745,10 @@ static int jset_validate(struct bch_fs *c,
return JOURNAL_ENTRY_NONE;
version = le32_to_cpu(jset->version);
- if (journal_entry_err_on((version != BCH_JSET_VERSION_OLD &&
- version < bcachefs_metadata_version_min) ||
- version >= bcachefs_metadata_version_max,
- c, jset, NULL,
- "%s sector %llu seq %llu: unknown journal entry version %u",
+ if (journal_entry_err_on(!bch2_version_compatible(version), c, jset, NULL,
+ "%s sector %llu seq %llu: incompatible journal entry version %u",
ca ? ca->name : c->name,
- sector, le64_to_cpu(jset->seq),
- version)) {
+ sector, le64_to_cpu(jset->seq), version)) {
/* don't try to continue: */
return -EINVAL;
}
@@ -796,14 +792,10 @@ static int jset_validate_early(struct bch_fs *c,
return JOURNAL_ENTRY_NONE;
version = le32_to_cpu(jset->version);
- if (journal_entry_err_on((version != BCH_JSET_VERSION_OLD &&
- version < bcachefs_metadata_version_min) ||
- version >= bcachefs_metadata_version_max,
- c, jset, NULL,
+ if (journal_entry_err_on(!bch2_version_compatible(version), c, jset, NULL,
"%s sector %llu seq %llu: unknown journal entry version %u",
ca ? ca->name : c->name,
- sector, le64_to_cpu(jset->seq),
- version)) {
+ sector, le64_to_cpu(jset->seq), version)) {
/* don't try to continue: */
return -EINVAL;
}
@@ -1755,9 +1747,7 @@ void bch2_journal_write(struct closure *cl)
}
jset->magic = cpu_to_le64(jset_magic(c));
- jset->version = c->sb.version < bcachefs_metadata_version_bkey_renumber
- ? cpu_to_le32(BCH_JSET_VERSION_OLD)
- : cpu_to_le32(c->sb.version);
+ jset->version = cpu_to_le32(c->sb.version);
SET_JSET_BIG_ENDIAN(jset, CPU_BIG_ENDIAN);
SET_JSET_CSUM_TYPE(jset, bch2_meta_checksum_type(c));