From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Johannes Thumshirn <jthumshirn@suse.de>, Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org
Cc: Nikolay Borisov <nborisov@suse.com>
Subject: Re: [PATCH v2 1/5] btrfs: Always output error message when key/level verification fails
Date: Thu, 17 Jan 2019 21:25:12 +0800 [thread overview]
Message-ID: <da4f4d74-f497-3605-d111-ce6673e70b54@gmx.com> (raw)
In-Reply-To: <80247a76-7a61-da01-7453-234e9d897f0b@suse.de>
On 2019/1/17 下午9:14, Johannes Thumshirn wrote:
> On 17/01/2019 11:15, Qu Wenruo wrote:
>> @@ -449,9 +449,10 @@ static int verify_level_key(struct btrfs_fs_info *fs_info,
>> btrfs_item_key_to_cpu(eb, &found_key, 0);
>> ret = btrfs_comp_cpu_keys(first_key, &found_key);
>>
>> -#ifdef CONFIG_BTRFS_DEBUG
>> if (ret) {
>> +#ifdef CONFIG_BTRFS_DEBUG
>> WARN_ON(1);
>> +#endif
>> btrfs_err(fs_info,
>> "tree first key mismatch detected, bytenr=%llu parent_transid=%llu key expected=(%llu,%u,%llu) has=(%llu,%u,%llu)",
>> eb->start, parent_transid, first_key->objectid,
>> @@ -459,7 +460,6 @@ static int verify_level_key(struct btrfs_fs_info *fs_info,
>> found_key.objectid, found_key.type,
>> found_key.offset);
>> }
>> -#endif
>> return ret;
>> }
>
>
> Hmm I think the resulting code looks a bit odd now, doesn't it?
> if (ret) {
> #ifdef CONFIG_BTRFS_DEBUG
> WARN_ON(1);
> #endif
>
> btrfs_err(fs_info,
>
>
> Why not something like:
> if (ret) {
> if (IS_ENABLED(CONFIG_BTRFS_DEBUG))
> WARN_ON(1);
Didn't know that macro, and indeed it looks much better.
>
> btrfs_err(fs_info,
>
> Or even hide the if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) WARN_ON(1); in a macro
> #define BTRFS_DEBUG_WARN_ON(x) do { \
> if (IS_ENABLED(CONFIG_BTRFS_DEBUG)) \
> WARN_ON((x)); \
> } while(0)
Although I'd say such WARN_ON() for DEBUG build will finally get moved
to any build.
Thanks,
Qu
>
next prev parent reply other threads:[~2019-01-17 13:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 10:15 [PATCH v2 0/5] btrfs: Enhancement to tree block validation Qu Wenruo
2019-01-17 10:15 ` [PATCH v2 1/5] btrfs: Always output error message when key/level verification fails Qu Wenruo
2019-01-17 13:14 ` Johannes Thumshirn
2019-01-17 13:25 ` Qu Wenruo [this message]
2019-01-17 10:15 ` [PATCH v2 2/5] btrfs: extent_io: Kill the forward declaration of flush_write_bio() Qu Wenruo
2019-01-17 13:22 ` Johannes Thumshirn
2019-01-17 10:15 ` [PATCH v2 3/5] btrfs: extent_io: Kill the BUG_ON() in flush_write_bio() Qu Wenruo
2019-01-17 10:15 ` [PATCH v2 4/5] btrfs: disk-io: Show the timing of corrupted tree block explicitly Qu Wenruo
2019-01-17 13:36 ` Johannes Thumshirn
2019-01-17 13:42 ` Qu Wenruo
2019-01-17 14:08 ` Johannes Thumshirn
2019-01-17 14:29 ` Qu Wenruo
2019-01-17 10:15 ` [PATCH v2 5/5] btrfs: Do mandatory tree block check before submitting bio Qu Wenruo
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=da4f4d74-f497-3605-d111-ce6673e70b54@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=jthumshirn@suse.de \
--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;
as well as URLs for NNTP newsgroup(s).