1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2017-2023 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <djwong@kernel.org>
6 #ifndef __XFS_SCRUB_BTREE_H__
7 #define __XFS_SCRUB_BTREE_H__
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
);
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
);
19 /* Check for btree corruption. */
20 void xchk_btree_set_corrupt(struct xfs_scrub
*sc
,
21 struct xfs_btree_cur
*cur
, int level
);
22 void xchk_btree_set_preen(struct xfs_scrub
*sc
, struct xfs_btree_cur
*cur
,
25 /* Check for btree xref discrepancies. */
26 void xchk_btree_xref_set_corrupt(struct xfs_scrub
*sc
,
27 struct xfs_btree_cur
*cur
, int level
);
30 typedef int (*xchk_btree_rec_fn
)(
31 struct xchk_btree
*bs
,
32 const union xfs_btree_rec
*rec
);
34 struct xchk_btree_key
{
35 union xfs_btree_key key
;
40 /* caller-provided scrub state */
42 struct xfs_btree_cur
*cur
;
43 xchk_btree_rec_fn scrub_rec
;
44 const struct xfs_owner_info
*oinfo
;
47 /* internal scrub state */
49 union xfs_btree_rec lastrec
;
50 struct list_head to_check
;
52 /* this element must come last! */
53 struct xchk_btree_key lastkey
[];
57 * Calculate the size of a xchk_btree structure. There are nlevels-1 slots for
58 * keys because we track leaf records separately in lastrec.
61 xchk_btree_sizeof(unsigned int nlevels
)
63 return struct_size_t(struct xchk_btree
, lastkey
, nlevels
- 1);
66 int xchk_btree(struct xfs_scrub
*sc
, struct xfs_btree_cur
*cur
,
67 xchk_btree_rec_fn scrub_fn
, const struct xfs_owner_info
*oinfo
,
70 #endif /* __XFS_SCRUB_BTREE_H__ */