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