From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: handle errors properly in update_inline_extent_backref()
Date: Wed, 9 Aug 2023 13:20:58 +0200 [thread overview]
Message-ID: <ZNN2muT7ONRWvn1c@twin.jikos.cz> (raw)
In-Reply-To: <7a56e967d536bbb3d40c90def6e59e9970ef3445.1691564698.git.wqu@suse.com>
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/
?
next prev parent reply other threads:[~2023-08-09 11:21 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 [this message]
2023-08-09 11:29 ` Qu Wenruo
2023-08-09 18:38 ` David Sterba
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=ZNN2muT7ONRWvn1c@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--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