public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: fix incorrect usage of xfs_btree_check_block
@ 2022-11-03 11:37 Guo Xuenan
  2022-11-07 16:58 ` Darrick J. Wong
  2022-11-17 14:55 ` friendly ping Guo Xuenan
  0 siblings, 2 replies; 9+ messages in thread
From: Guo Xuenan @ 2022-11-03 11:37 UTC (permalink / raw)
  To: djwong, dchinner
  Cc: linux-xfs, guoxuenan, houtao1, jack.qiu, fangwei1, yi.zhang,
	zhengbin13, leo.lilong, zengheng4

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. 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
 	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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-11-30  2:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox