From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Nikolay Borisov <nborisov@suse.com>,
Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2] btrfs: replace BUG_ON() in btrfs_csum_one_bio() with proper error handling
Date: Thu, 19 Aug 2021 20:34:46 +0800 [thread overview]
Message-ID: <27ffe5f1-db6b-aa72-949f-60984070a1ba@gmx.com> (raw)
In-Reply-To: <20210819122326.GD5047@twin.jikos.cz>
On 2021/8/19 下午8:23, David Sterba wrote:
> On Thu, Aug 19, 2021 at 09:08:00AM +0800, Qu Wenruo wrote:
>> I want to play safe by never bothering the WARN_ON() in if () condition
>> anymore.
>>
>> The fact that some if (WARN_ON()) is acceptable and some is not is
>> already worrying.
>>
>> Can we just stick to no-WARN_ON-in-if policy?
>
> So what would be the reocommended way to do that? Also with the obvious
> question "is the warning needed at all?"
IMHO we should use WARN() other than WARN_ON().
The WARN_ON(), even with proper condition, is not providing enough info.
We want the warning mostly for fstests to catch the error, so that we
know it's something wrong.
>
> if (condition) {
> WARN_ON(1);
> ...
> }
>
> This will hide the condition in the warning report, the value is usually
> in RAX and sometimes it helps to analyze what happend. We'd have to
> either duplicate it like
The condition itself is not really that helpful, compared to proper
warning message.
In fact, the line number is more useful than the condition itself.
>
> if (condition) {
> WARN_ON(condition);
> ...
> }
>
> or use a temporary variable.
>
> Another question is what to do with current if+WARN calls. Lots of them
> are there without a comment. Ideally if there's a need for a warning
> even on a production build, there should be a message also printed.
We can add comments on them when we're going to refactor the code.
But historic problems shouldn't be a blockage for us to update our
current code guideline.
>
> Lots of them seem to be an assert in disguise (like in
> extract_ordered_extent) or are called before returning EUCLEAN. We've
> talked about this a few times before, we'd need more fine grained
> warnings/assertions or have them better documented. There are 300+ of
> them so that's a lot for a single pass audit, but at least some of them
> share a common pattern and can be unified.
>
This already shows that we need a proper guideline for how to do proper
warning.
Thanks,
Qu
next prev parent reply other threads:[~2021-08-19 12:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-16 23:55 [PATCH v2] btrfs: replace BUG_ON() in btrfs_csum_one_bio() with proper error handling Qu Wenruo
2021-08-17 7:55 ` Nikolay Borisov
2021-08-17 8:03 ` Nikolay Borisov
2021-08-17 8:10 ` Qu Wenruo
2021-08-18 23:00 ` David Sterba
2021-08-19 1:08 ` Qu Wenruo
2021-08-19 12:23 ` David Sterba
2021-08-19 12:34 ` Qu Wenruo [this message]
2021-09-07 14:13 ` 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=27ffe5f1-db6b-aa72-949f-60984070a1ba@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.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