18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * Copyright (C) 2017 Oracle. All Rights Reserved. 48c2ecf20Sopenharmony_ci * Author: Darrick J. Wong <darrick.wong@oracle.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#ifndef __XFS_SCRUB_BTREE_H__ 78c2ecf20Sopenharmony_ci#define __XFS_SCRUB_BTREE_H__ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* btree scrub */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* Check for btree operation errors. */ 128c2ecf20Sopenharmony_cibool xchk_btree_process_error(struct xfs_scrub *sc, 138c2ecf20Sopenharmony_ci struct xfs_btree_cur *cur, int level, int *error); 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* Check for btree xref operation errors. */ 168c2ecf20Sopenharmony_cibool xchk_btree_xref_process_error(struct xfs_scrub *sc, 178c2ecf20Sopenharmony_ci struct xfs_btree_cur *cur, int level, int *error); 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* Check for btree corruption. */ 208c2ecf20Sopenharmony_civoid xchk_btree_set_corrupt(struct xfs_scrub *sc, 218c2ecf20Sopenharmony_ci struct xfs_btree_cur *cur, int level); 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci/* Check for btree xref discrepancies. */ 248c2ecf20Sopenharmony_civoid xchk_btree_xref_set_corrupt(struct xfs_scrub *sc, 258c2ecf20Sopenharmony_ci struct xfs_btree_cur *cur, int level); 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistruct xchk_btree; 288c2ecf20Sopenharmony_citypedef int (*xchk_btree_rec_fn)( 298c2ecf20Sopenharmony_ci struct xchk_btree *bs, 308c2ecf20Sopenharmony_ci union xfs_btree_rec *rec); 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cistruct xchk_btree { 338c2ecf20Sopenharmony_ci /* caller-provided scrub state */ 348c2ecf20Sopenharmony_ci struct xfs_scrub *sc; 358c2ecf20Sopenharmony_ci struct xfs_btree_cur *cur; 368c2ecf20Sopenharmony_ci xchk_btree_rec_fn scrub_rec; 378c2ecf20Sopenharmony_ci const struct xfs_owner_info *oinfo; 388c2ecf20Sopenharmony_ci void *private; 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci /* internal scrub state */ 418c2ecf20Sopenharmony_ci union xfs_btree_rec lastrec; 428c2ecf20Sopenharmony_ci bool firstrec; 438c2ecf20Sopenharmony_ci union xfs_btree_key lastkey[XFS_BTREE_MAXLEVELS]; 448c2ecf20Sopenharmony_ci bool firstkey[XFS_BTREE_MAXLEVELS]; 458c2ecf20Sopenharmony_ci struct list_head to_check; 468c2ecf20Sopenharmony_ci}; 478c2ecf20Sopenharmony_ciint xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur, 488c2ecf20Sopenharmony_ci xchk_btree_rec_fn scrub_fn, const struct xfs_owner_info *oinfo, 498c2ecf20Sopenharmony_ci void *private); 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci#endif /* __XFS_SCRUB_BTREE_H__ */ 52