From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: handle errors properly in update_inline_extent_backref()
Date: Wed, 9 Aug 2023 20:38:47 +0200 [thread overview]
Message-ID: <ZNPdN6zV2oWooJFb@twin.jikos.cz> (raw)
In-Reply-To: <82f89f3c-78b0-4c7f-a426-7fde89bf490a@gmx.com>
On Wed, Aug 09, 2023 at 07:29:20PM +0800, Qu Wenruo wrote:
>
>
> On 2023/8/9 19:20, David Sterba wrote:
> > On Wed, Aug 09, 2023 at 03:08:21PM +0800, Qu Wenruo wrote:
> > > [PROBLEM]
> > > Inside function update_inline_extent_backref(), we have several
> > > BUG_ON()s along with some ASSERT()s which can be triggered by corrupted
> > > filesystem.
> > >
> > > [ANAYLYSE]
> > > Most of those BUG_ON()s and ASSERT()s are just a way of handling
> > > unexpected on-disk data.
> > >
> > > Although we have tree-checker to rule out obviously incorrect extent
> > > tree blocks, it's not enough for those ones.
> > >
> > > Thus we need proper error handling for them.
> > >
> > > [FIX]
> > > Thankfully all the callers of update_inline_extent_backref() would
> > > eventually handle the errror by aborting the current transaction.
> > >
> > > So this patch would do the proper error handling by:
> > >
> > > - Make update_inline_extent_backref() to return int
> > > The return value would be either 0 or -EUCLEAN.
> > >
> > > - Replace BUG_ON()s and ASSERT()s with proper error handling
> > > This includes:
> > > * Dump the bad extent tree leaf
> > > * Output an error message for the cause
> > > This would include the extent bytenr, num_bytes (if needed),
> > > the bad values and expected good values.
> > > * Return -EUCLEAN
> > >
> > > Note here we remove all the WARN_ON()s, as eventually the transaction
> > > would be aborted, thus a backtrace would be triggered anyway.
> > >
> > > - Better comments on why we expect refs == 1 and refs_to_mode == -1 for
> > > tree blocks
> > >
> > > Signed-off-by: Qu Wenruo <wqu@suse.com>
> >
> > Is this fix for syzbot report
> > https://lore.kernel.org/linux-btrfs/000000000000287928060275b914@google.com/
> > ?
>
> Unfortunately, I don't think this is the proper fix.
>
> Since there is no reproducer, I'm not sure if it's really corrupted fs
> causing the bug.
>
> If it's something else, then the patch won't help at all, except a
> little better debug output.
Ok, thanks. Adding more error handling instead of BUG_ON or ASSERT that
could be possibly hit by corrupted images is good on its own.
next prev parent reply other threads:[~2023-08-09 18:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-09 7:08 [PATCH] btrfs: handle errors properly in update_inline_extent_backref() Qu Wenruo
2023-08-09 11:20 ` David Sterba
2023-08-09 11:29 ` Qu Wenruo
2023-08-09 18:38 ` David Sterba [this message]
2023-08-09 13:20 ` Josef Bacik
2023-08-09 18:44 ` David Sterba
2023-08-09 18:59 ` David Sterba
2023-08-10 1:13 ` Qu Wenruo
2023-08-17 12:40 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZNPdN6zV2oWooJFb@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox