Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Oracle. All Rights Reserved. |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_SCRUB_DABTREE_H__ |
| 7 | #define __XFS_SCRUB_DABTREE_H__ |
| 8 | |
| 9 | /* dir/attr btree */ |
| 10 | |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 11 | struct xchk_da_btree { |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 12 | struct xfs_da_args dargs; |
| 13 | xfs_dahash_t hashes[XFS_DA_NODE_MAXDEPTH]; |
| 14 | int maxrecs[XFS_DA_NODE_MAXDEPTH]; |
| 15 | struct xfs_da_state *state; |
Darrick J. Wong | 1d8a748 | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 16 | struct xfs_scrub *sc; |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 17 | void *private; |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 18 | |
| 19 | /* |
| 20 | * Lowest and highest directory block address in which we expect |
| 21 | * to find dir/attr btree node blocks. For a directory this |
| 22 | * (presumably) means between LEAF_OFFSET and FREE_OFFSET; for |
| 23 | * attributes there is no limit. |
| 24 | */ |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 25 | xfs_dablk_t lowest; |
| 26 | xfs_dablk_t highest; |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 27 | |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 28 | int tree_level; |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 29 | }; |
| 30 | |
Christoph Hellwig | 649d9d9 | 2019-11-08 14:52:07 -0800 | [diff] [blame] | 31 | typedef int (*xchk_da_btree_rec_fn)(struct xchk_da_btree *ds, int level); |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 32 | |
| 33 | /* Check for da btree operation errors. */ |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 34 | bool xchk_da_process_error(struct xchk_da_btree *ds, int level, int *error); |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 35 | |
| 36 | /* Check for da btree corruption. */ |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 37 | void xchk_da_set_corrupt(struct xchk_da_btree *ds, int level); |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 38 | |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 39 | int xchk_da_btree_hash(struct xchk_da_btree *ds, int level, __be32 *hashp); |
Darrick J. Wong | 1d8a748 | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 40 | int xchk_da_btree(struct xfs_scrub *sc, int whichfork, |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 41 | xchk_da_btree_rec_fn scrub_fn, void *private); |
Darrick J. Wong | 7c4a07a | 2017-10-17 21:37:43 -0700 | [diff] [blame] | 42 | |
| 43 | #endif /* __XFS_SCRUB_DABTREE_H__ */ |