From: Guo Xuenan <guoxuenan@huawei.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: <dchinner@redhat.com>, <linux-xfs@vger.kernel.org>,
<houtao1@huawei.com>, <jack.qiu@huawei.com>,
<fangwei1@huawei.com>, <yi.zhang@huawei.com>,
<zhengbin13@huawei.com>, <leo.lilong@huawei.com>,
<zengheng4@huawei.com>
Subject: Re: [PATCH] xfs: fix incorrect usage of xfs_btree_check_block
Date: Tue, 8 Nov 2022 09:50:29 +0800 [thread overview]
Message-ID: <1afe73bb-481c-01b3-8c61-3d208e359f40@huawei.com> (raw)
In-Reply-To: <Y2k5NTjTRdsDAuhN@magnolia>
On 2022/11/8 0:58, Darrick J. Wong wrote:
> On Thu, Nov 03, 2022 at 07:37:09PM +0800, Guo Xuenan wrote:
>> xfs_btree_check_block contains a tag XFS_ERRTAG_BTREE_CHECK_{L,S}BLOCK,
>> it is a fault injection tag, better not use it in the macro ASSERT.
>>
>> Since with XFS_DEBUG setting up, we can always trigger assert by `echo 1
>>> /sys/fs/xfs/${disk}/errortag/btree_chk_{s,l}blk`.
>> It's confusing and strange.
> Please be more specific about how this is confusing or strange.
I meant in current code, the ASSERT will alway happen,when we
`echo 1 > /sys/fs/xfs/${disk}/errortag/btree_chk_{s,l}blk`.
xfs_btree_islastblock
->ASSERT(block && xfs_btree_check_block(cur, block, level, bp) == 0);
->xfs_btree_check_{l/s}block
->XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BTREE_CHECK_{S,L}BLOCK)
we can use error injection to trigger this ASSERT.
I think ASERRT macro and error injection are to find some effective
problems,
not to create some kernel panic. So, putting the error injection
function in
ASSERT is a little strange.
>> Instead of using it in ASSERT, replace it with
>> xfs_warn.
>>
>> Fixes: 27d9ee577dcc ("xfs: actually check xfs_btree_check_block return in xfs_btree_islastblock")
>> Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
>> ---
>> fs/xfs/libxfs/xfs_btree.h | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
>> index eef27858a013..637513087c18 100644
>> --- a/fs/xfs/libxfs/xfs_btree.h
>> +++ b/fs/xfs/libxfs/xfs_btree.h
>> @@ -556,8 +556,11 @@ xfs_btree_islastblock(
>> struct xfs_buf *bp;
>>
>> block = xfs_btree_get_block(cur, level, &bp);
>> - ASSERT(block && xfs_btree_check_block(cur, block, level, bp) == 0);
>> -
>> + ASSERT(block);
>> +#if defined(DEBUG) || defined(XFS_WARN)
>> + if (xfs_btree_check_block(cur, block, level, bp))
>> + xfs_warn(cur->bc_mp, "%s: xfs_btree_check_block() error.", __func__);
>> +#endif
> ...because this seems like open-coding ASSERT, possibly without the
> panic on errors part.
yes,exactly!I also think it can be deleted, but i have no idea if this
is necessary,
I just retain it in this fix patch; looking forward to your decision :)
> --D
>
>> if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
>> return block->bb_u.l.bb_rightsib == cpu_to_be64(NULLFSBLOCK);
>> return block->bb_u.s.bb_rightsib == cpu_to_be32(NULLAGBLOCK);
>> --
>> 2.31.1
>>
> .
--
Guo Xuenan [OS Kernel Lab]
-----------------------------
Email: guoxuenan@huawei.com
next prev parent reply other threads:[~2022-11-08 1:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 11:37 [PATCH] xfs: fix incorrect usage of xfs_btree_check_block Guo Xuenan
2022-11-07 16:58 ` Darrick J. Wong
2022-11-08 1:50 ` Guo Xuenan [this message]
2022-11-17 16:13 ` Eric Sandeen
2022-11-17 19:07 ` Darrick J. Wong
2022-11-29 3:52 ` Guo Xuenan
2022-11-30 1:06 ` Darrick J. Wong
2022-11-30 2:51 ` Guo Xuenan
2022-11-17 14:55 ` friendly ping Guo Xuenan
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=1afe73bb-481c-01b3-8c61-3d208e359f40@huawei.com \
--to=guoxuenan@huawei.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=fangwei1@huawei.com \
--cc=houtao1@huawei.com \
--cc=jack.qiu@huawei.com \
--cc=leo.lilong@huawei.com \
--cc=linux-xfs@vger.kernel.org \
--cc=yi.zhang@huawei.com \
--cc=zengheng4@huawei.com \
--cc=zhengbin13@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.