summaryrefslogtreecommitdiff
path: root/fs/bcachefs/error.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2021-04-24 16:32:35 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:02 -0400
commitaae15aafcd43ec5346ac6c3f61c09798d26593ee (patch)
tree49df821335528b7d153ea17f6cfaf99c72321f3b /fs/bcachefs/error.c
parent4932e07ea04bcc7f1649052183d1ebbab30c711c (diff)
bcachefs: New and improved topology repair code
This splits out btree topology repair into a separate pass, and makes some improvements: - When we have to pick which of two overlapping nodes to drop keys from, we use the btree node header sequence number to preserve the newer node - the gc code has been changed so that it doesn't bail out if we're continuing/ignoring on fsck error - this way the dump tool can skip running the repair pass but still walk all reachable metadata - add a new superblock flag indicating when a filesystem is known to have btree topology issues, and the topology repair pass should be run - changing the start/end of a node might mean keys in that node have to be deleted: this patch handles that better by splitting it out into a separate function and running it explicitly in the topology repair code, previously those keys were only being dropped when the btree node was read in. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/error.c')
-rw-r--r--fs/bcachefs/error.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/fs/bcachefs/error.c b/fs/bcachefs/error.c
index a8ee1db8aa39..90c3b986c264 100644
--- a/fs/bcachefs/error.c
+++ b/fs/bcachefs/error.c
@@ -25,6 +25,13 @@ bool bch2_inconsistent_error(struct bch_fs *c)
}
}
+void bch2_topology_error(struct bch_fs *c)
+{
+ set_bit(BCH_FS_TOPOLOGY_ERROR, &c->flags);
+ if (test_bit(BCH_FS_INITIAL_GC_DONE, &c->flags))
+ bch2_inconsistent_error(c);
+}
+
void bch2_fatal_error(struct bch_fs *c)
{
if (bch2_fs_emergency_read_only(c))
@@ -74,9 +81,13 @@ enum fsck_err_ret bch2_fsck_err(struct bch_fs *c, unsigned flags,
vprintk(fmt, args);
va_end(args);
- return bch2_inconsistent_error(c)
- ? FSCK_ERR_EXIT
- : FSCK_ERR_FIX;
+ if (c->opts.errors == BCH_ON_ERROR_continue) {
+ bch_err(c, "fixing");
+ return FSCK_ERR_FIX;
+ } else {
+ bch2_inconsistent_error(c);
+ return FSCK_ERR_EXIT;
+ }
}
mutex_lock(&c->fsck_error_lock);
@@ -146,6 +157,7 @@ print:
set_bit(BCH_FS_ERRORS_FIXED, &c->flags);
return FSCK_ERR_FIX;
} else {
+ set_bit(BCH_FS_ERRORS_NOT_FIXED, &c->flags);
set_bit(BCH_FS_ERROR, &c->flags);
return c->opts.fix_errors == FSCK_OPT_EXIT ||
!(flags & FSCK_CAN_IGNORE)