summaryrefslogtreecommitdiff
path: root/fs/bcachefs/super-io.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-10 13:42:26 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:10:06 -0400
commit065bd3356ce490ae9454d8b3c98ff298e13d09ac (patch)
tree968bb0d1b3135ca9d51cdf43c2a963bede5552ab /fs/bcachefs/super-io.c
parent6619d84626ff266721f4c3c24339c60ca8cb12e0 (diff)
bcachefs: Version table now lists required recovery passes
Now that we've got forward compatibility sorted out, we should be doing more frequent version upgrades in the future. To avoid having to run a full fsck for every version upgrade, this improves the BCH_METADATA_VERSIONS() table to explicitly specify a bitmask of recovery passes to run when upgrading to or past a given version. This means we can also delete PASS_UPGRADE(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super-io.c')
-rw-r--r--fs/bcachefs/super-io.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index a06310492e79..6a97af0f5896 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -4,6 +4,7 @@
#include "btree_update_interior.h"
#include "buckets.h"
#include "checksum.h"
+#include "counters.h"
#include "disk_groups.h"
#include "ec.h"
#include "error.h"
@@ -12,13 +13,13 @@
#include "journal_io.h"
#include "journal_sb.h"
#include "journal_seq_blacklist.h"
+#include "recovery.h"
#include "replicas.h"
#include "quota.h"
#include "super-io.h"
#include "super.h"
#include "trace.h"
#include "vstructs.h"
-#include "counters.h"
#include <linux/backing-dev.h>
#include <linux/sort.h>
@@ -26,13 +27,18 @@
static const struct blk_holder_ops bch2_sb_handle_bdev_ops = {
};
-struct bch2_metadata_version_str {
+struct bch2_metadata_version {
u16 version;
const char *name;
+ u64 recovery_passes;
};
-static const struct bch2_metadata_version_str bch2_metadata_versions[] = {
-#define x(n, v) { .version = v, .name = #n },
+static const struct bch2_metadata_version bch2_metadata_versions[] = {
+#define x(n, v, _recovery_passes) { \
+ .version = v, \
+ .name = #n, \
+ .recovery_passes = _recovery_passes, \
+},
BCH_METADATA_VERSIONS()
#undef x
};
@@ -64,6 +70,24 @@ unsigned bch2_latest_compatible_version(unsigned v)
return v;
}
+u64 bch2_upgrade_recovery_passes(struct bch_fs *c,
+ unsigned old_version,
+ unsigned new_version)
+{
+ u64 ret = 0;
+
+ for (const struct bch2_metadata_version *i = bch2_metadata_versions;
+ i < bch2_metadata_versions + ARRAY_SIZE(bch2_metadata_versions);
+ i++)
+ if (i->version > old_version && i->version <= new_version) {
+ if (i->recovery_passes & RECOVERY_PASS_ALL_FSCK)
+ ret |= bch2_fsck_recovery_passes();
+ ret |= i->recovery_passes;
+ }
+
+ return ret &= ~RECOVERY_PASS_ALL_FSCK;
+}
+
const char * const bch2_sb_fields[] = {
#define x(name, nr) #name,
BCH_SB_FIELDS()