xfs_refcount_btree.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2016 Oracle. All Rights Reserved.
  4. * Author: Darrick J. Wong <darrick.wong@oracle.com>
  5. */
  6. #ifndef __XFS_REFCOUNT_BTREE_H__
  7. #define __XFS_REFCOUNT_BTREE_H__
  8. /*
  9. * Reference Count Btree on-disk structures
  10. */
  11. struct xfs_buf;
  12. struct xfs_btree_cur;
  13. struct xfs_mount;
  14. /*
  15. * Btree block header size
  16. */
  17. #define XFS_REFCOUNT_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN
  18. /*
  19. * Record, key, and pointer address macros for btree blocks.
  20. *
  21. * (note that some of these may appear unused, but they are used in userspace)
  22. */
  23. #define XFS_REFCOUNT_REC_ADDR(block, index) \
  24. ((struct xfs_refcount_rec *) \
  25. ((char *)(block) + \
  26. XFS_REFCOUNT_BLOCK_LEN + \
  27. (((index) - 1) * sizeof(struct xfs_refcount_rec))))
  28. #define XFS_REFCOUNT_KEY_ADDR(block, index) \
  29. ((struct xfs_refcount_key *) \
  30. ((char *)(block) + \
  31. XFS_REFCOUNT_BLOCK_LEN + \
  32. ((index) - 1) * sizeof(struct xfs_refcount_key)))
  33. #define XFS_REFCOUNT_PTR_ADDR(block, index, maxrecs) \
  34. ((xfs_refcount_ptr_t *) \
  35. ((char *)(block) + \
  36. XFS_REFCOUNT_BLOCK_LEN + \
  37. (maxrecs) * sizeof(struct xfs_refcount_key) + \
  38. ((index) - 1) * sizeof(xfs_refcount_ptr_t)))
  39. extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp,
  40. struct xfs_trans *tp, struct xfs_buf *agbp,
  41. xfs_agnumber_t agno);
  42. extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf);
  43. extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
  44. extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
  45. unsigned long long len);
  46. extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
  47. xfs_agblock_t agblocks);
  48. extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
  49. struct xfs_trans *tp, xfs_agnumber_t agno, xfs_extlen_t *ask,
  50. xfs_extlen_t *used);
  51. #endif /* __XFS_REFCOUNT_BTREE_H__ */