Re: [PATCH] bcachefs: use mustfix to check invalid btree IDs

From: Kent Overstreet
Date: Fri Jun 27 2025 - 12:00:56 EST


On Fri, Jun 27, 2025 at 02:10:32PM +0530, Bharadwaj Raju wrote:
> Checking for invalid IDs was introduced in 9e7cfb35e266 ("bcachefs: Check for invalid btree IDs")
> to prevent an invalid shift later, but since 141526548052 ("bcachefs: Bad btree roots are now autofix")
> made the parent class btree_root_bkey_invalid FSCK_AUTOFIX, fsck_err_on
> no longer works for this check.
>
> Change the condition to use mustfix_fsck_err_on instead.

We can mark this one autofix instead

>
> Reported-by: syzbot+029d1989099aa5ae3e89@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=029d1989099aa5ae3e89
> Fixes: 141526548052 ("bcachefs: Bad btree roots are now autofix")
>
> Signed-off-by: Bharadwaj Raju <bharadwaj.raju777@xxxxxxxxx>
> ---
> fs/bcachefs/recovery.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
> index d0b7e3a36a54..abcaa0e3e2e6 100644
> --- a/fs/bcachefs/recovery.c
> +++ b/fs/bcachefs/recovery.c
> @@ -489,7 +489,7 @@ static int journal_replay_entry_early(struct bch_fs *c,
> if (unlikely(!entry->u64s))
> return 0;
>
> - if (fsck_err_on(entry->btree_id >= BTREE_ID_NR_MAX,
> + if (mustfix_fsck_err_on(entry->btree_id >= BTREE_ID_NR_MAX,
> c, invalid_btree_id,
> "invalid btree id %u (max %u)",
> entry->btree_id, BTREE_ID_NR_MAX))
> --
> 2.50.0
>