xref: /linux/fs/xfs/scrub/trace.c (revision 537964bceb9a4c9e39a16a83042b80986d373453)
136fd6e86SDarrick J. Wong /*
236fd6e86SDarrick J. Wong  * Copyright (C) 2017 Oracle.  All Rights Reserved.
336fd6e86SDarrick J. Wong  *
436fd6e86SDarrick J. Wong  * Author: Darrick J. Wong <darrick.wong@oracle.com>
536fd6e86SDarrick J. Wong  *
636fd6e86SDarrick J. Wong  * This program is free software; you can redistribute it and/or
736fd6e86SDarrick J. Wong  * modify it under the terms of the GNU General Public License
836fd6e86SDarrick J. Wong  * as published by the Free Software Foundation; either version 2
936fd6e86SDarrick J. Wong  * of the License, or (at your option) any later version.
1036fd6e86SDarrick J. Wong  *
1136fd6e86SDarrick J. Wong  * This program is distributed in the hope that it would be useful,
1236fd6e86SDarrick J. Wong  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1336fd6e86SDarrick J. Wong  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1436fd6e86SDarrick J. Wong  * GNU General Public License for more details.
1536fd6e86SDarrick J. Wong  *
1636fd6e86SDarrick J. Wong  * You should have received a copy of the GNU General Public License
1736fd6e86SDarrick J. Wong  * along with this program; if not, write the Free Software Foundation,
1836fd6e86SDarrick J. Wong  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
1936fd6e86SDarrick J. Wong  */
2036fd6e86SDarrick J. Wong #include "xfs.h"
2136fd6e86SDarrick J. Wong #include "xfs_fs.h"
2236fd6e86SDarrick J. Wong #include "xfs_shared.h"
2336fd6e86SDarrick J. Wong #include "xfs_format.h"
2436fd6e86SDarrick J. Wong #include "xfs_log_format.h"
2536fd6e86SDarrick J. Wong #include "xfs_trans_resv.h"
2636fd6e86SDarrick J. Wong #include "xfs_mount.h"
2736fd6e86SDarrick J. Wong #include "xfs_defer.h"
2836fd6e86SDarrick J. Wong #include "xfs_da_format.h"
2936fd6e86SDarrick J. Wong #include "xfs_defer.h"
3036fd6e86SDarrick J. Wong #include "xfs_inode.h"
3136fd6e86SDarrick J. Wong #include "xfs_btree.h"
3236fd6e86SDarrick J. Wong #include "xfs_trans.h"
33*537964bcSDarrick J. Wong #include "xfs_bit.h"
3436fd6e86SDarrick J. Wong #include "scrub/xfs_scrub.h"
3536fd6e86SDarrick J. Wong #include "scrub/scrub.h"
36dcb660f9SDarrick J. Wong #include "scrub/common.h"
3736fd6e86SDarrick J. Wong 
38*537964bcSDarrick J. Wong /* Figure out which block the btree cursor was pointing to. */
39*537964bcSDarrick J. Wong static inline xfs_fsblock_t
40*537964bcSDarrick J. Wong xfs_scrub_btree_cur_fsbno(
41*537964bcSDarrick J. Wong 	struct xfs_btree_cur		*cur,
42*537964bcSDarrick J. Wong 	int				level)
43*537964bcSDarrick J. Wong {
44*537964bcSDarrick J. Wong 	if (level < cur->bc_nlevels && cur->bc_bufs[level])
45*537964bcSDarrick J. Wong 		return XFS_DADDR_TO_FSB(cur->bc_mp, cur->bc_bufs[level]->b_bn);
46*537964bcSDarrick J. Wong 	else if (level == cur->bc_nlevels - 1 &&
47*537964bcSDarrick J. Wong 		 cur->bc_flags & XFS_BTREE_LONG_PTRS)
48*537964bcSDarrick J. Wong 		return XFS_INO_TO_FSB(cur->bc_mp, cur->bc_private.b.ip->i_ino);
49*537964bcSDarrick J. Wong 	else if (!(cur->bc_flags & XFS_BTREE_LONG_PTRS))
50*537964bcSDarrick J. Wong 		return XFS_AGB_TO_FSB(cur->bc_mp, cur->bc_private.a.agno, 0);
51*537964bcSDarrick J. Wong 	return NULLFSBLOCK;
52*537964bcSDarrick J. Wong }
53*537964bcSDarrick J. Wong 
5436fd6e86SDarrick J. Wong /*
5536fd6e86SDarrick J. Wong  * We include this last to have the helpers above available for the trace
5636fd6e86SDarrick J. Wong  * event implementations.
5736fd6e86SDarrick J. Wong  */
5836fd6e86SDarrick J. Wong #define CREATE_TRACE_POINTS
5936fd6e86SDarrick J. Wong #include "scrub/trace.h"
60