xfs_ialloc_btree.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_IALLOC_BTREE_H__
  7. #define __XFS_IALLOC_BTREE_H__
  8. /*
  9. * Inode map on-disk structures
  10. */
  11. struct xfs_buf;
  12. struct xfs_btree_cur;
  13. struct xfs_mount;
  14. struct xfs_perag;
  15. /*
  16. * Btree block header size depends on a superblock flag.
  17. */
  18. #define XFS_INOBT_BLOCK_LEN(mp) \
  19. (xfs_has_crc(((mp))) ? \
  20. XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
  21. /*
  22. * Record, key, and pointer address macros for btree blocks.
  23. *
  24. * (note that some of these may appear unused, but they are used in userspace)
  25. */
  26. #define XFS_INOBT_REC_ADDR(mp, block, index) \
  27. ((xfs_inobt_rec_t *) \
  28. ((char *)(block) + \
  29. XFS_INOBT_BLOCK_LEN(mp) + \
  30. (((index) - 1) * sizeof(xfs_inobt_rec_t))))
  31. #define XFS_INOBT_KEY_ADDR(mp, block, index) \
  32. ((xfs_inobt_key_t *) \
  33. ((char *)(block) + \
  34. XFS_INOBT_BLOCK_LEN(mp) + \
  35. ((index) - 1) * sizeof(xfs_inobt_key_t)))
  36. #define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \
  37. ((xfs_inobt_ptr_t *) \
  38. ((char *)(block) + \
  39. XFS_INOBT_BLOCK_LEN(mp) + \
  40. (maxrecs) * sizeof(xfs_inobt_key_t) + \
  41. ((index) - 1) * sizeof(xfs_inobt_ptr_t)))
  42. extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *mp,
  43. struct xfs_trans *tp, struct xfs_buf *agbp,
  44. struct xfs_perag *pag, xfs_btnum_t btnum);
  45. struct xfs_btree_cur *xfs_inobt_stage_cursor(struct xfs_mount *mp,
  46. struct xbtree_afakeroot *afake, struct xfs_perag *pag,
  47. xfs_btnum_t btnum);
  48. extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int);
  49. /* ir_holemask to inode allocation bitmap conversion */
  50. uint64_t xfs_inobt_irec_to_allocmask(struct xfs_inobt_rec_incore *);
  51. #if defined(DEBUG) || defined(XFS_WARN)
  52. int xfs_inobt_rec_check_count(struct xfs_mount *,
  53. struct xfs_inobt_rec_incore *);
  54. #else
  55. #define xfs_inobt_rec_check_count(mp, rec) 0
  56. #endif /* DEBUG */
  57. int xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,
  58. struct xfs_perag *pag, xfs_extlen_t *ask, xfs_extlen_t *used);
  59. extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
  60. unsigned long long len);
  61. int xfs_inobt_cur(struct xfs_mount *mp, struct xfs_trans *tp,
  62. struct xfs_perag *pag, xfs_btnum_t btnum,
  63. struct xfs_btree_cur **curpp, struct xfs_buf **agi_bpp);
  64. void xfs_inobt_commit_staged_btree(struct xfs_btree_cur *cur,
  65. struct xfs_trans *tp, struct xfs_buf *agbp);
  66. unsigned int xfs_iallocbt_maxlevels_ondisk(void);
  67. int __init xfs_inobt_init_cur_cache(void);
  68. void xfs_inobt_destroy_cur_cache(void);
  69. #endif /* __XFS_IALLOC_BTREE_H__ */