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 xfs_scrub_btree_process_error(struct xfs_scrub_context *sc, 13 struct xfs_btree_cur *cur, int level, int *error); 14 15 /* Check for btree xref operation errors. */ 16 bool xfs_scrub_btree_xref_process_error(struct xfs_scrub_context *sc, 17 struct xfs_btree_cur *cur, int level, 18 int *error); 19 20 /* Check for btree corruption. */ 21 void xfs_scrub_btree_set_corrupt(struct xfs_scrub_context *sc, 22 struct xfs_btree_cur *cur, int level); 23 24 /* Check for btree xref discrepancies. */ 25 void xfs_scrub_btree_xref_set_corrupt(struct xfs_scrub_context *sc, 26 struct xfs_btree_cur *cur, int level); 27 28 struct xfs_scrub_btree; 29 typedef int (*xfs_scrub_btree_rec_fn)( 30 struct xfs_scrub_btree *bs, 31 union xfs_btree_rec *rec); 32 33 struct xfs_scrub_btree { 34 /* caller-provided scrub state */ 35 struct xfs_scrub_context *sc; 36 struct xfs_btree_cur *cur; 37 xfs_scrub_btree_rec_fn scrub_rec; 38 struct xfs_owner_info *oinfo; 39 void *private; 40 41 /* internal scrub state */ 42 union xfs_btree_rec lastrec; 43 bool firstrec; 44 union xfs_btree_key lastkey[XFS_BTREE_MAXLEVELS]; 45 bool firstkey[XFS_BTREE_MAXLEVELS]; 46 struct list_head to_check; 47 }; 48 int xfs_scrub_btree(struct xfs_scrub_context *sc, struct xfs_btree_cur *cur, 49 xfs_scrub_btree_rec_fn scrub_fn, 50 struct xfs_owner_info *oinfo, void *private); 51 52 #endif /* __XFS_SCRUB_BTREE_H__ */ 53