162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2017-2023 Oracle.  All Rights Reserved.
462306a36Sopenharmony_ci * Author: Darrick J. Wong <djwong@kernel.org>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci#ifndef __XFS_SCRUB_DABTREE_H__
762306a36Sopenharmony_ci#define __XFS_SCRUB_DABTREE_H__
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/* dir/attr btree */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_cistruct xchk_da_btree {
1262306a36Sopenharmony_ci	struct xfs_da_args	dargs;
1362306a36Sopenharmony_ci	xfs_dahash_t		hashes[XFS_DA_NODE_MAXDEPTH];
1462306a36Sopenharmony_ci	int			maxrecs[XFS_DA_NODE_MAXDEPTH];
1562306a36Sopenharmony_ci	struct xfs_da_state	*state;
1662306a36Sopenharmony_ci	struct xfs_scrub	*sc;
1762306a36Sopenharmony_ci	void			*private;
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci	/*
2062306a36Sopenharmony_ci	 * Lowest and highest directory block address in which we expect
2162306a36Sopenharmony_ci	 * to find dir/attr btree node blocks.  For a directory this
2262306a36Sopenharmony_ci	 * (presumably) means between LEAF_OFFSET and FREE_OFFSET; for
2362306a36Sopenharmony_ci	 * attributes there is no limit.
2462306a36Sopenharmony_ci	 */
2562306a36Sopenharmony_ci	xfs_dablk_t		lowest;
2662306a36Sopenharmony_ci	xfs_dablk_t		highest;
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci	int			tree_level;
2962306a36Sopenharmony_ci};
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_citypedef int (*xchk_da_btree_rec_fn)(struct xchk_da_btree *ds, int level);
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* Check for da btree operation errors. */
3462306a36Sopenharmony_cibool xchk_da_process_error(struct xchk_da_btree *ds, int level, int *error);
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci/* Check for da btree corruption. */
3762306a36Sopenharmony_civoid xchk_da_set_corrupt(struct xchk_da_btree *ds, int level);
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciint xchk_da_btree_hash(struct xchk_da_btree *ds, int level, __be32 *hashp);
4062306a36Sopenharmony_ciint xchk_da_btree(struct xfs_scrub *sc, int whichfork,
4162306a36Sopenharmony_ci		xchk_da_btree_rec_fn scrub_fn, void *private);
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci#endif /* __XFS_SCRUB_DABTREE_H__ */
44