xref: /OK3568_Linux_fs/kernel/fs/xfs/scrub/dabtree.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0+
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2017 Oracle.  All Rights Reserved.
4*4882a593Smuzhiyun  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef __XFS_SCRUB_DABTREE_H__
7*4882a593Smuzhiyun #define __XFS_SCRUB_DABTREE_H__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun /* dir/attr btree */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun struct xchk_da_btree {
12*4882a593Smuzhiyun 	struct xfs_da_args	dargs;
13*4882a593Smuzhiyun 	xfs_dahash_t		hashes[XFS_DA_NODE_MAXDEPTH];
14*4882a593Smuzhiyun 	int			maxrecs[XFS_DA_NODE_MAXDEPTH];
15*4882a593Smuzhiyun 	struct xfs_da_state	*state;
16*4882a593Smuzhiyun 	struct xfs_scrub	*sc;
17*4882a593Smuzhiyun 	void			*private;
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun 	/*
20*4882a593Smuzhiyun 	 * Lowest and highest directory block address in which we expect
21*4882a593Smuzhiyun 	 * to find dir/attr btree node blocks.  For a directory this
22*4882a593Smuzhiyun 	 * (presumably) means between LEAF_OFFSET and FREE_OFFSET; for
23*4882a593Smuzhiyun 	 * attributes there is no limit.
24*4882a593Smuzhiyun 	 */
25*4882a593Smuzhiyun 	xfs_dablk_t		lowest;
26*4882a593Smuzhiyun 	xfs_dablk_t		highest;
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun 	int			tree_level;
29*4882a593Smuzhiyun };
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun typedef int (*xchk_da_btree_rec_fn)(struct xchk_da_btree *ds, int level);
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun /* Check for da btree operation errors. */
34*4882a593Smuzhiyun bool xchk_da_process_error(struct xchk_da_btree *ds, int level, int *error);
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun /* Check for da btree corruption. */
37*4882a593Smuzhiyun void xchk_da_set_corrupt(struct xchk_da_btree *ds, int level);
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun int xchk_da_btree_hash(struct xchk_da_btree *ds, int level, __be32 *hashp);
40*4882a593Smuzhiyun int xchk_da_btree(struct xfs_scrub *sc, int whichfork,
41*4882a593Smuzhiyun 		xchk_da_btree_rec_fn scrub_fn, void *private);
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #endif /* __XFS_SCRUB_DABTREE_H__ */
44