repair.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2018 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <darrick.wong@oracle.com>
  5. */
  6. #ifndef __XFS_SCRUB_REPAIR_H__
  7. #define __XFS_SCRUB_REPAIR_H__
  8. static inline int xrep_notsupported(struct xfs_scrub *sc)
  9. {
  10. return -EOPNOTSUPP;
  11. }
  12. #ifdef CONFIG_XFS_ONLINE_REPAIR
  13. /* Repair helpers */
  14. int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc, bool *fixed);
  15. void xrep_failure(struct xfs_mount *mp);
  16. int xrep_roll_ag_trans(struct xfs_scrub *sc);
  17. bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
  18. enum xfs_ag_resv_type type);
  19. xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
  20. int xrep_alloc_ag_block(struct xfs_scrub *sc, struct xfs_owner_info *oinfo,
  21. xfs_fsblock_t *fsbno, enum xfs_ag_resv_type resv);
  22. int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
  23. struct xfs_buf **bpp, xfs_btnum_t btnum,
  24. const struct xfs_buf_ops *ops);
  25. struct xfs_bitmap;
  26. int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
  27. int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xfs_bitmap *btlist);
  28. int xrep_reap_extents(struct xfs_scrub *sc, struct xfs_bitmap *exlist,
  29. struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
  30. struct xrep_find_ag_btree {
  31. /* in: rmap owner of the btree we're looking for */
  32. uint64_t rmap_owner;
  33. /* in: buffer ops */
  34. const struct xfs_buf_ops *buf_ops;
  35. /* in: magic number of the btree */
  36. uint32_t magic;
  37. /* out: the highest btree block found and the tree height */
  38. xfs_agblock_t root;
  39. unsigned int height;
  40. };
  41. int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
  42. struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
  43. void xrep_force_quotacheck(struct xfs_scrub *sc, uint dqtype);
  44. int xrep_ino_dqattach(struct xfs_scrub *sc);
  45. /* Metadata repairers */
  46. int xrep_probe(struct xfs_scrub *sc);
  47. int xrep_superblock(struct xfs_scrub *sc);
  48. int xrep_agf(struct xfs_scrub *sc);
  49. int xrep_agfl(struct xfs_scrub *sc);
  50. int xrep_agi(struct xfs_scrub *sc);
  51. #else
  52. static inline int xrep_attempt(
  53. struct xfs_inode *ip,
  54. struct xfs_scrub *sc,
  55. bool *fixed)
  56. {
  57. return -EOPNOTSUPP;
  58. }
  59. static inline void xrep_failure(struct xfs_mount *mp) {}
  60. static inline xfs_extlen_t
  61. xrep_calc_ag_resblks(
  62. struct xfs_scrub *sc)
  63. {
  64. ASSERT(!(sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR));
  65. return 0;
  66. }
  67. #define xrep_probe xrep_notsupported
  68. #define xrep_superblock xrep_notsupported
  69. #define xrep_agf xrep_notsupported
  70. #define xrep_agfl xrep_notsupported
  71. #define xrep_agi xrep_notsupported
  72. #endif /* CONFIG_XFS_ONLINE_REPAIR */
  73. #endif /* __XFS_SCRUB_REPAIR_H__ */