xfs_alloc_btree.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_ALLOC_BTREE_H__
  7. #define __XFS_ALLOC_BTREE_H__
  8. /*
  9. * Freespace on-disk structures
  10. */
  11. struct xfs_buf;
  12. struct xfs_btree_cur;
  13. struct xfs_mount;
  14. /*
  15. * Btree block header size depends on a superblock flag.
  16. */
  17. #define XFS_ALLOC_BLOCK_LEN(mp) \
  18. (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
  19. XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
  20. /*
  21. * Record, key, and pointer address macros for btree blocks.
  22. *
  23. * (note that some of these may appear unused, but they are used in userspace)
  24. */
  25. #define XFS_ALLOC_REC_ADDR(mp, block, index) \
  26. ((xfs_alloc_rec_t *) \
  27. ((char *)(block) + \
  28. XFS_ALLOC_BLOCK_LEN(mp) + \
  29. (((index) - 1) * sizeof(xfs_alloc_rec_t))))
  30. #define XFS_ALLOC_KEY_ADDR(mp, block, index) \
  31. ((xfs_alloc_key_t *) \
  32. ((char *)(block) + \
  33. XFS_ALLOC_BLOCK_LEN(mp) + \
  34. ((index) - 1) * sizeof(xfs_alloc_key_t)))
  35. #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \
  36. ((xfs_alloc_ptr_t *) \
  37. ((char *)(block) + \
  38. XFS_ALLOC_BLOCK_LEN(mp) + \
  39. (maxrecs) * sizeof(xfs_alloc_key_t) + \
  40. ((index) - 1) * sizeof(xfs_alloc_ptr_t)))
  41. extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
  42. struct xfs_trans *, struct xfs_buf *,
  43. xfs_agnumber_t, xfs_btnum_t);
  44. extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
  45. extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,
  46. unsigned long long len);
  47. #endif /* __XFS_ALLOC_BTREE_H__ */