Skip to content

Commit 5612daa

Browse files
author
Kent Overstreet
committed
bcachefs: Fix fsck warnings from bkey validation
__bch2_fsck_err() warns if the current task has a btree_trans object and it wasn't passed in, because if it has to prompt for user input it has to be able to unlock it. But plumbing the btree_trans through bkey_validate(), as well as transaction restarts, is problematic - so instead make bkey fsck errors FSCK_AUTOFIX, which doesn't need to warn. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 7c980a4 commit 5612daa

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

fs/bcachefs/error.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,19 @@ int __bch2_fsck_err(struct bch_fs *c,
239239
if (!c)
240240
c = trans->c;
241241

242-
WARN_ON(!trans && bch2_current_has_btree_trans(c));
242+
/*
243+
* Ugly: if there's a transaction in the current task it has to be
244+
* passed in to unlock if we prompt for user input.
245+
*
246+
* But, plumbing a transaction and transaction restarts into
247+
* bkey_validate() is problematic.
248+
*
249+
* So:
250+
* - make all bkey errors AUTOFIX, they're simple anyways (we just
251+
* delete the key)
252+
* - and we don't need to warn if we're not prompting
253+
*/
254+
WARN_ON(!(flags & FSCK_AUTOFIX) && !trans && bch2_current_has_btree_trans(c));
243255

244256
if ((flags & FSCK_CAN_FIX) &&
245257
test_bit(err, c->sb.errors_silent))

fs/bcachefs/error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ do { \
184184
ret = -BCH_ERR_fsck_delete_bkey; \
185185
goto fsck_err; \
186186
} \
187-
int _ret = __bch2_bkey_fsck_err(c, k, FSCK_CAN_FIX, \
187+
int _ret = __bch2_bkey_fsck_err(c, k, FSCK_CAN_FIX|FSCK_AUTOFIX,\
188188
BCH_FSCK_ERR_##_err_type, \
189189
_err_msg, ##__VA_ARGS__); \
190190
if (_ret != -BCH_ERR_fsck_fix && \

0 commit comments

Comments
 (0)