xref: /openbmc/linux/fs/xfs/scrub/trace.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1739a2fe0SDarrick J. Wong // SPDX-License-Identifier: GPL-2.0-or-later
236fd6e86SDarrick J. Wong /*
3ecc73f8aSDarrick J. Wong  * Copyright (C) 2017-2023 Oracle.  All Rights Reserved.
4739a2fe0SDarrick J. Wong  * Author: Darrick J. Wong <djwong@kernel.org>
536fd6e86SDarrick J. Wong  */
636fd6e86SDarrick J. Wong #include "xfs.h"
736fd6e86SDarrick J. Wong #include "xfs_fs.h"
836fd6e86SDarrick J. Wong #include "xfs_shared.h"
936fd6e86SDarrick J. Wong #include "xfs_format.h"
1036fd6e86SDarrick J. Wong #include "xfs_log_format.h"
1136fd6e86SDarrick J. Wong #include "xfs_trans_resv.h"
1236fd6e86SDarrick J. Wong #include "xfs_mount.h"
1336fd6e86SDarrick J. Wong #include "xfs_inode.h"
1436fd6e86SDarrick J. Wong #include "xfs_btree.h"
1550f02fe3SDave Chinner #include "xfs_ag.h"
16*3934e8ebSDarrick J. Wong #include "scrub/scrub.h"
17*3934e8ebSDarrick J. Wong #include "scrub/xfile.h"
18*3934e8ebSDarrick J. Wong #include "scrub/xfarray.h"
1936fd6e86SDarrick J. Wong 
20537964bcSDarrick J. Wong /* Figure out which block the btree cursor was pointing to. */
21537964bcSDarrick J. Wong static inline xfs_fsblock_t
xchk_btree_cur_fsbno(struct xfs_btree_cur * cur,int level)22c517b3aaSDarrick J. Wong xchk_btree_cur_fsbno(
23537964bcSDarrick J. Wong 	struct xfs_btree_cur	*cur,
24537964bcSDarrick J. Wong 	int			level)
25537964bcSDarrick J. Wong {
266ca444cfSDarrick J. Wong 	if (level < cur->bc_nlevels && cur->bc_levels[level].bp)
279343ee76SDave Chinner 		return XFS_DADDR_TO_FSB(cur->bc_mp,
286ca444cfSDarrick J. Wong 				xfs_buf_daddr(cur->bc_levels[level].bp));
2994a14cfdSDarrick J. Wong 
3094a14cfdSDarrick J. Wong 	if (level == cur->bc_nlevels - 1 &&
3194a14cfdSDarrick J. Wong 	    (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE))
3292219c29SDave Chinner 		return XFS_INO_TO_FSB(cur->bc_mp, cur->bc_ino.ip->i_ino);
3394a14cfdSDarrick J. Wong 
34537964bcSDarrick J. Wong 	return NULLFSBLOCK;
35537964bcSDarrick J. Wong }
36537964bcSDarrick J. Wong 
3736fd6e86SDarrick J. Wong /*
3836fd6e86SDarrick J. Wong  * We include this last to have the helpers above available for the trace
3936fd6e86SDarrick J. Wong  * event implementations.
4036fd6e86SDarrick J. Wong  */
4136fd6e86SDarrick J. Wong #define CREATE_TRACE_POINTS
4236fd6e86SDarrick J. Wong #include "scrub/trace.h"
43