Thread (35 messages) 35 messages, 2 authors, 2021-10-18

Re: [PATCH 01/17] xfs: fix incorrect decoding in xchk_btree_cur_fsbno

From: "Darrick J. Wong" <djwong@kernel.org>
Date: 2021-10-14 23:05:52

On Fri, Oct 15, 2021 at 09:48:13AM +1100, Dave Chinner wrote:
On Thu, Oct 14, 2021 at 01:17:00PM -0700, Darrick J. Wong wrote:
quoted
From: Darrick J. Wong <djwong@kernel.org>

During review of subsequent patches, Dave and I noticed that this
function doesn't work quite right -- accessing cur->bc_ino depends on
the ROOT_IN_INODE flag, not LONG_PTRS.  Fix that and the parentheses
isssue.  While we're at it, remove the piece that accesses cur->bc_ag,
because block 0 of an AG is never part of a btree.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/scrub/trace.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/scrub/trace.c b/fs/xfs/scrub/trace.c
index c0ef53fe6611..93c13763c15e 100644
--- a/fs/xfs/scrub/trace.c
+++ b/fs/xfs/scrub/trace.c
@@ -24,10 +24,11 @@ xchk_btree_cur_fsbno(
 	if (level < cur->bc_nlevels && cur->bc_bufs[level])
 		return XFS_DADDR_TO_FSB(cur->bc_mp,
 				xfs_buf_daddr(cur->bc_bufs[level]));
-	if (level == cur->bc_nlevels - 1 && cur->bc_flags & XFS_BTREE_LONG_PTRS)
+
+	if (level == cur->bc_nlevels - 1 &&
+	    (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE))
 		return XFS_INO_TO_FSB(cur->bc_mp, cur->bc_ino.ip->i_ino);
Ok.
quoted
-	if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS))
-		return XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_ag.pag->pag_agno, 0);
+
But doesn't this break the tracing code on short pointers as the
tracing code does:

	TP_fast_assign(
		xfs_fsblock_t fsbno = xchk_btree_cur_fsbno(cur, level);
		...
		__entry->agno = XFS_FSB_TO_AGNO(cur->bc_mp, fsbno);


i.e. the tracing will no longer give the correct agno for per-ag
cursors that don't have any buffers attached to them at the current
level?
Hmmm.  By that logic, maybe we should get rid of the (level ==
cur->bc_nlevels - 1) check entirely so that any cursor without a buffer
attached at that level will always provide *some* kind of breadcrumb to
the tracepoints?

I almost did that instead, except for the consideration that if you're
tracing the online fsck code, you should /probably/ have at least one of
xchk_stop/xrep_attempt/xchk_done included in the filter list so you can
be certain of what the kernel is checking.

--D
Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help