Skip to content

Commit 658c82f

Browse files
author
Kent Overstreet
committed
bcachefs: bkey errors are only AUTOFIX during read
Newly generated keys, in the transaction commit path or write path, should not be AUTOFIX; those indicate bugs that we need to fail fast for. Fixes: 5612daa ("bcachefs: Fix fsck warnings from bkey validation") Signed-off-by: Kent Overstreet <[email protected]>
1 parent fda7b1f commit 658c82f

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

fs/bcachefs/error.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,17 @@ int __bch2_fsck_err(struct bch_fs *c,
430430

431431
int __bch2_bkey_fsck_err(struct bch_fs *c,
432432
struct bkey_s_c k,
433-
enum bch_fsck_flags flags,
433+
enum bch_validate_flags validate_flags,
434434
enum bch_sb_error_id err,
435435
const char *fmt, ...)
436436
{
437+
if (validate_flags & BCH_VALIDATE_silent)
438+
return -BCH_ERR_fsck_delete_bkey;
439+
440+
unsigned fsck_flags = 0;
441+
if (!(validate_flags & (BCH_VALIDATE_write|BCH_VALIDATE_commit)))
442+
fsck_flags |= FSCK_AUTOFIX|FSCK_CAN_FIX;
443+
437444
struct printbuf buf = PRINTBUF;
438445
va_list args;
439446

@@ -445,7 +452,7 @@ int __bch2_bkey_fsck_err(struct bch_fs *c,
445452
va_end(args);
446453
prt_str(&buf, ": delete?");
447454

448-
int ret = __bch2_fsck_err(c, NULL, flags, err, "%s", buf.buf);
455+
int ret = __bch2_fsck_err(c, NULL, fsck_flags, err, "%s", buf.buf);
449456
printbuf_exit(&buf);
450457
return ret;
451458
}

fs/bcachefs/error.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ void bch2_flush_fsck_errs(struct bch_fs *);
167167
#define fsck_err_on(cond, c, _err_type, ...) \
168168
__fsck_err_on(cond, c, FSCK_CAN_FIX|FSCK_CAN_IGNORE, _err_type, __VA_ARGS__)
169169

170+
enum bch_validate_flags;
170171
__printf(5, 6)
171172
int __bch2_bkey_fsck_err(struct bch_fs *,
172173
struct bkey_s_c,
173-
enum bch_fsck_flags,
174+
enum bch_validate_flags,
174175
enum bch_sb_error_id,
175176
const char *, ...);
176177

@@ -180,11 +181,7 @@ int __bch2_bkey_fsck_err(struct bch_fs *,
180181
*/
181182
#define bkey_fsck_err(c, _err_type, _err_msg, ...) \
182183
do { \
183-
if ((flags & BCH_VALIDATE_silent)) { \
184-
ret = -BCH_ERR_fsck_delete_bkey; \
185-
goto fsck_err; \
186-
} \
187-
int _ret = __bch2_bkey_fsck_err(c, k, FSCK_CAN_FIX|FSCK_AUTOFIX,\
184+
int _ret = __bch2_bkey_fsck_err(c, k, flags, \
188185
BCH_FSCK_ERR_##_err_type, \
189186
_err_msg, ##__VA_ARGS__); \
190187
if (_ret != -BCH_ERR_fsck_fix && \

0 commit comments

Comments
 (0)