diff mbox series

[v4.1,01/17] xfs: fix incorrect decoding in xchk_btree_cur_fsbno

Message ID 20211015004203.GO24307@magnolia (mailing list archive)
State Accepted
Headers show
Series [v4.1,01/17] xfs: fix incorrect decoding in xchk_btree_cur_fsbno | expand

Commit Message

Darrick J. Wong Oct. 15, 2021, 12:42 a.m. UTC
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.

Note: This changes the btree scrubber tracepoints behavior -- if the
cursor has no buffer for a certain level, it will always report
NULLFSBLOCK.  It is assumed that anyone tracing the online fsck code
will also be tracing xchk_start/xchk_done or otherwise be aware of what
exactly is being scrubbed.

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

Comments

Dave Chinner Oct. 18, 2021, 10:26 p.m. UTC | #1
On Thu, Oct 14, 2021 at 05:42:03PM -0700, Darrick J. Wong wrote:
> 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.
> 
> Note: This changes the btree scrubber tracepoints behavior -- if the
> cursor has no buffer for a certain level, it will always report
> NULLFSBLOCK.  It is assumed that anyone tracing the online fsck code
> will also be tracing xchk_start/xchk_done or otherwise be aware of what
> exactly is being scrubbed.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
> v4.1: note the new behavior in the commit message
> ---
>  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);
> -	if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS))
> -		return XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_ag.pag->pag_agno, 0);
> +
>  	return NULLFSBLOCK;
>  }

Looks good with the update to the commit message.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
diff mbox series

Patch

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);
-	if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS))
-		return XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_ag.pag->pag_agno, 0);
+
 	return NULLFSBLOCK;
 }