1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2017 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5  */
6 #ifndef __XFS_SCRUB_BTREE_H__
7 #define __XFS_SCRUB_BTREE_H__
8 
9 /* btree scrub */
10 
11 /* Check for btree operation errors. */
12 bool xchk_btree_process_error(struct xfs_scrub *sc,
13 		struct xfs_btree_cur *cur, int level, int *error);
14 
15 /* Check for btree xref operation errors. */
16 bool xchk_btree_xref_process_error(struct xfs_scrub *sc,
17 		struct xfs_btree_cur *cur, int level, int *error);
18 
19 /* Check for btree corruption. */
20 void xchk_btree_set_corrupt(struct xfs_scrub *sc,
21 		struct xfs_btree_cur *cur, int level);
22 
23 /* Check for btree xref discrepancies. */
24 void xchk_btree_xref_set_corrupt(struct xfs_scrub *sc,
25 		struct xfs_btree_cur *cur, int level);
26 
27 struct xchk_btree;
28 typedef int (*xchk_btree_rec_fn)(
29 	struct xchk_btree	*bs,
30 	union xfs_btree_rec	*rec);
31 
32 struct xchk_btree {
33 	/* caller-provided scrub state */
34 	struct xfs_scrub	*sc;
35 	struct xfs_btree_cur	*cur;
36 	xchk_btree_rec_fn	scrub_rec;
37 	struct xfs_owner_info	*oinfo;
38 	void			*private;
39 
40 	/* internal scrub state */
41 	union xfs_btree_rec	lastrec;
42 	bool			firstrec;
43 	union xfs_btree_key	lastkey[XFS_BTREE_MAXLEVELS];
44 	bool			firstkey[XFS_BTREE_MAXLEVELS];
45 	struct list_head	to_check;
46 };
47 int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
48 		xchk_btree_rec_fn scrub_fn, struct xfs_owner_info *oinfo,
49 		void *private);
50 
51 #endif /* __XFS_SCRUB_BTREE_H__ */
52