xfs_alloc_btree.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. struct xfs_perag;
  15. struct xbtree_afakeroot;
  16. /*
  17. * Btree block header size depends on a superblock flag.
  18. */
  19. #define XFS_ALLOC_BLOCK_LEN(mp) \
  20. (xfs_has_crc(((mp))) ? \
  21. XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
  22. /*
  23. * Record, key, and pointer address macros for btree blocks.
  24. *
  25. * (note that some of these may appear unused, but they are used in userspace)
  26. */
  27. #define XFS_ALLOC_REC_ADDR(mp, block, index) \
  28. ((xfs_alloc_rec_t *) \
  29. ((char *)(block) + \
  30. XFS_ALLOC_BLOCK_LEN(mp) + \
  31. (((index) - 1) * sizeof(xfs_alloc_rec_t))))
  32. #define XFS_ALLOC_KEY_ADDR(mp, block, index) \
  33. ((xfs_alloc_key_t *) \
  34. ((char *)(block) + \
  35. XFS_ALLOC_BLOCK_LEN(mp) + \
  36. ((index) - 1) * sizeof(xfs_alloc_key_t)))
  37. #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \
  38. ((xfs_alloc_ptr_t *) \
  39. ((char *)(block) + \
  40. XFS_ALLOC_BLOCK_LEN(mp) + \
  41. (maxrecs) * sizeof(xfs_alloc_key_t) + \
  42. ((index) - 1) * sizeof(xfs_alloc_ptr_t)))
  43. extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *mp,
  44. struct xfs_trans *tp, struct xfs_buf *bp,
  45. struct xfs_perag *pag, xfs_btnum_t btnum);
  46. struct xfs_btree_cur *xfs_allocbt_stage_cursor(struct xfs_mount *mp,
  47. struct xbtree_afakeroot *afake, struct xfs_perag *pag,
  48. xfs_btnum_t btnum);
  49. extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
  50. extern xfs_extlen_t xfs_allocbt_calc_size(struct xfs_mount *mp,
  51. unsigned long long len);
  52. void xfs_allocbt_commit_staged_btree(struct xfs_btree_cur *cur,
  53. struct xfs_trans *tp, struct xfs_buf *agbp);
  54. unsigned int xfs_allocbt_maxlevels_ondisk(void);
  55. int __init xfs_allocbt_init_cur_cache(void);
  56. void xfs_allocbt_destroy_cur_cache(void);
  57. #endif /* __XFS_ALLOC_BTREE_H__ */