bcachefs: Ensure fsck error is printed before panic
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 9 Oct 2022 04:54:36 +0000 (00:54 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:42 +0000 (17:09 -0400)
When errors=panic, we want to make sure we print the error before
calling bch2_inconsistent_error().

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/error.c

index 762abdf2f283719a9e5f8757f72ecb8926cb8fec..2fb5102ee31d16da84e83a37b32a0a0872254284 100644 (file)
@@ -104,7 +104,7 @@ int bch2_fsck_err(struct bch_fs *c, unsigned flags, const char *fmt, ...)
 {
        struct fsck_err_state *s = NULL;
        va_list args;
-       bool print = true, suppressing = false;
+       bool print = true, suppressing = false, inconsistent = false;
        struct printbuf buf = PRINTBUF, *out = &buf;
        int ret = -BCH_ERR_fsck_ignore;
 
@@ -136,7 +136,7 @@ int bch2_fsck_err(struct bch_fs *c, unsigned flags, const char *fmt, ...)
                if (c->opts.errors != BCH_ON_ERROR_continue ||
                    !(flags & (FSCK_CAN_FIX|FSCK_CAN_IGNORE))) {
                        prt_str(out, ", shutting down");
-                       bch2_inconsistent_error(c);
+                       inconsistent = true;
                        ret = -BCH_ERR_fsck_errors_not_fixed;
                } else if (flags & FSCK_CAN_FIX) {
                        prt_str(out, ", fixing");
@@ -189,6 +189,9 @@ int bch2_fsck_err(struct bch_fs *c, unsigned flags, const char *fmt, ...)
 
        printbuf_exit(&buf);
 
+       if (inconsistent)
+               bch2_inconsistent_error(c);
+
        if (ret == -BCH_ERR_fsck_fix) {
                set_bit(BCH_FS_ERRORS_FIXED, &c->flags);
        } else {