xref: /linux/fs/xfs/scrub/dabtree.h (revision 3ad0876554cafa368f574d4d408468510543e9ff)
1 /*
2  * Copyright (C) 2017 Oracle.  All Rights Reserved.
3  *
4  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it would be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write the Free Software Foundation,
18  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20 #ifndef __XFS_SCRUB_DABTREE_H__
21 #define __XFS_SCRUB_DABTREE_H__
22 
23 /* dir/attr btree */
24 
25 struct xfs_scrub_da_btree {
26 	struct xfs_da_args		dargs;
27 	xfs_dahash_t			hashes[XFS_DA_NODE_MAXDEPTH];
28 	int				maxrecs[XFS_DA_NODE_MAXDEPTH];
29 	struct xfs_da_state		*state;
30 	struct xfs_scrub_context	*sc;
31 	void				*private;
32 
33 	/*
34 	 * Lowest and highest directory block address in which we expect
35 	 * to find dir/attr btree node blocks.  For a directory this
36 	 * (presumably) means between LEAF_OFFSET and FREE_OFFSET; for
37 	 * attributes there is no limit.
38 	 */
39 	xfs_dablk_t			lowest;
40 	xfs_dablk_t			highest;
41 
42 	int				tree_level;
43 };
44 
45 typedef int (*xfs_scrub_da_btree_rec_fn)(struct xfs_scrub_da_btree *ds,
46 		int level, void *rec);
47 
48 /* Check for da btree operation errors. */
49 bool xfs_scrub_da_process_error(struct xfs_scrub_da_btree *ds, int level, int *error);
50 
51 /* Check for da btree corruption. */
52 void xfs_scrub_da_set_corrupt(struct xfs_scrub_da_btree *ds, int level);
53 
54 int xfs_scrub_da_btree_hash(struct xfs_scrub_da_btree *ds, int level,
55 			    __be32 *hashp);
56 int xfs_scrub_da_btree(struct xfs_scrub_context *sc, int whichfork,
57 		       xfs_scrub_da_btree_rec_fn scrub_fn, void *private);
58 
59 #endif /* __XFS_SCRUB_DABTREE_H__ */
60