xref: /openbmc/linux/fs/xfs/scrub/btree.h (revision e2a06704)
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_BTREE_H__
21 #define __XFS_SCRUB_BTREE_H__
22 
23 /* btree scrub */
24 
25 /* Check for btree operation errors. */
26 bool xfs_scrub_btree_process_error(struct xfs_scrub_context *sc,
27 		struct xfs_btree_cur *cur, int level, int *error);
28 
29 /* Check for btree corruption. */
30 void xfs_scrub_btree_set_corrupt(struct xfs_scrub_context *sc,
31 		struct xfs_btree_cur *cur, int level);
32 
33 struct xfs_scrub_btree;
34 typedef int (*xfs_scrub_btree_rec_fn)(
35 	struct xfs_scrub_btree	*bs,
36 	union xfs_btree_rec	*rec);
37 
38 struct xfs_scrub_btree {
39 	/* caller-provided scrub state */
40 	struct xfs_scrub_context	*sc;
41 	struct xfs_btree_cur		*cur;
42 	xfs_scrub_btree_rec_fn		scrub_rec;
43 	struct xfs_owner_info		*oinfo;
44 	void				*private;
45 
46 	/* internal scrub state */
47 	union xfs_btree_rec		lastrec;
48 	bool				firstrec;
49 	union xfs_btree_key		lastkey[XFS_BTREE_MAXLEVELS];
50 	bool				firstkey[XFS_BTREE_MAXLEVELS];
51 	struct list_head		to_check;
52 };
53 int xfs_scrub_btree(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur,
54 		    xfs_scrub_btree_rec_fn scrub_fn,
55 		    struct xfs_owner_info *oinfo, void *private);
56 
57 #endif /* __XFS_SCRUB_BTREE_H__ */
58