btree.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /* btree scrub */
  9. /* Check for btree operation errors. */
  10. bool xchk_btree_process_error(struct xfs_scrub *sc,
  11. struct xfs_btree_cur *cur, int level, int *error);
  12. /* Check for btree xref operation errors. */
  13. bool xchk_btree_xref_process_error(struct xfs_scrub *sc,
  14. struct xfs_btree_cur *cur, int level, int *error);
  15. /* Check for btree corruption. */
  16. void xchk_btree_set_corrupt(struct xfs_scrub *sc,
  17. struct xfs_btree_cur *cur, int level);
  18. /* Check for btree xref discrepancies. */
  19. void xchk_btree_xref_set_corrupt(struct xfs_scrub *sc,
  20. struct xfs_btree_cur *cur, int level);
  21. struct xchk_btree;
  22. typedef int (*xchk_btree_rec_fn)(
  23. struct xchk_btree *bs,
  24. union xfs_btree_rec *rec);
  25. struct xchk_btree {
  26. /* caller-provided scrub state */
  27. struct xfs_scrub *sc;
  28. struct xfs_btree_cur *cur;
  29. xchk_btree_rec_fn scrub_rec;
  30. struct xfs_owner_info *oinfo;
  31. void *private;
  32. /* internal scrub state */
  33. union xfs_btree_rec lastrec;
  34. bool firstrec;
  35. union xfs_btree_key lastkey[XFS_BTREE_MAXLEVELS];
  36. bool firstkey[XFS_BTREE_MAXLEVELS];
  37. struct list_head to_check;
  38. };
  39. int xchk_btree(struct xfs_scrub *sc, struct xfs_btree_cur *cur,
  40. xchk_btree_rec_fn scrub_fn, struct xfs_owner_info *oinfo,
  41. void *private);
  42. #endif /* __XFS_SCRUB_BTREE_H__ */