newbt.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2022-2023 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <djwong@kernel.org>
  5. */
  6. #ifndef __XFS_SCRUB_NEWBT_H__
  7. #define __XFS_SCRUB_NEWBT_H__
  8. struct xfs_alloc_arg;
  9. struct xrep_newbt_resv {
  10. /* Link to list of extents that we've reserved. */
  11. struct list_head list;
  12. struct xfs_perag *pag;
  13. /* Auto-freeing this reservation if we don't commit. */
  14. struct xfs_alloc_autoreap autoreap;
  15. /* AG block of the extent we reserved. */
  16. xfs_agblock_t agbno;
  17. /* Length of the reservation. */
  18. xfs_extlen_t len;
  19. /* How much of this reservation has been used. */
  20. xfs_extlen_t used;
  21. };
  22. struct xrep_newbt {
  23. struct xfs_scrub *sc;
  24. /* Custom allocation function, or NULL for xfs_alloc_vextent */
  25. int (*alloc_vextent)(struct xfs_scrub *sc,
  26. struct xfs_alloc_arg *args,
  27. xfs_fsblock_t alloc_hint);
  28. /* List of extents that we've reserved. */
  29. struct list_head resv_list;
  30. /* Fake root for new btree. */
  31. union {
  32. struct xbtree_afakeroot afake;
  33. struct xbtree_ifakeroot ifake;
  34. };
  35. /* rmap owner of these blocks */
  36. struct xfs_owner_info oinfo;
  37. /* btree geometry for the bulk loader */
  38. struct xfs_btree_bload bload;
  39. /* Allocation hint */
  40. xfs_fsblock_t alloc_hint;
  41. /* per-ag reservation type */
  42. enum xfs_ag_resv_type resv;
  43. };
  44. void xrep_newbt_init_bare(struct xrep_newbt *xnr, struct xfs_scrub *sc);
  45. void xrep_newbt_init_ag(struct xrep_newbt *xnr, struct xfs_scrub *sc,
  46. const struct xfs_owner_info *oinfo, xfs_fsblock_t alloc_hint,
  47. enum xfs_ag_resv_type resv);
  48. int xrep_newbt_init_inode(struct xrep_newbt *xnr, struct xfs_scrub *sc,
  49. int whichfork, const struct xfs_owner_info *oinfo);
  50. int xrep_newbt_alloc_blocks(struct xrep_newbt *xnr, uint64_t nr_blocks);
  51. int xrep_newbt_add_extent(struct xrep_newbt *xnr, struct xfs_perag *pag,
  52. xfs_agblock_t agbno, xfs_extlen_t len);
  53. void xrep_newbt_cancel(struct xrep_newbt *xnr);
  54. int xrep_newbt_commit(struct xrep_newbt *xnr);
  55. int xrep_newbt_claim_block(struct xfs_btree_cur *cur, struct xrep_newbt *xnr,
  56. union xfs_btree_ptr *ptr);
  57. unsigned int xrep_newbt_unused_blocks(struct xrep_newbt *xnr);
  58. #endif /* __XFS_SCRUB_NEWBT_H__ */