xfs_ialloc_btree.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_IALLOC_BTREE_H__
  19. #define __XFS_IALLOC_BTREE_H__
  20. /*
  21. * Inode map on-disk structures
  22. */
  23. struct xfs_buf;
  24. struct xfs_btree_cur;
  25. struct xfs_mount;
  26. /*
  27. * Btree block header size depends on a superblock flag.
  28. */
  29. #define XFS_INOBT_BLOCK_LEN(mp) \
  30. (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \
  31. XFS_BTREE_SBLOCK_CRC_LEN : XFS_BTREE_SBLOCK_LEN)
  32. /*
  33. * Record, key, and pointer address macros for btree blocks.
  34. *
  35. * (note that some of these may appear unused, but they are used in userspace)
  36. */
  37. #define XFS_INOBT_REC_ADDR(mp, block, index) \
  38. ((xfs_inobt_rec_t *) \
  39. ((char *)(block) + \
  40. XFS_INOBT_BLOCK_LEN(mp) + \
  41. (((index) - 1) * sizeof(xfs_inobt_rec_t))))
  42. #define XFS_INOBT_KEY_ADDR(mp, block, index) \
  43. ((xfs_inobt_key_t *) \
  44. ((char *)(block) + \
  45. XFS_INOBT_BLOCK_LEN(mp) + \
  46. ((index) - 1) * sizeof(xfs_inobt_key_t)))
  47. #define XFS_INOBT_PTR_ADDR(mp, block, index, maxrecs) \
  48. ((xfs_inobt_ptr_t *) \
  49. ((char *)(block) + \
  50. XFS_INOBT_BLOCK_LEN(mp) + \
  51. (maxrecs) * sizeof(xfs_inobt_key_t) + \
  52. ((index) - 1) * sizeof(xfs_inobt_ptr_t)))
  53. extern struct xfs_btree_cur *xfs_inobt_init_cursor(struct xfs_mount *,
  54. struct xfs_trans *, struct xfs_buf *, xfs_agnumber_t,
  55. xfs_btnum_t);
  56. extern int xfs_inobt_maxrecs(struct xfs_mount *, int, int);
  57. /* ir_holemask to inode allocation bitmap conversion */
  58. uint64_t xfs_inobt_irec_to_allocmask(struct xfs_inobt_rec_incore *);
  59. #if defined(DEBUG) || defined(XFS_WARN)
  60. int xfs_inobt_rec_check_count(struct xfs_mount *,
  61. struct xfs_inobt_rec_incore *);
  62. #else
  63. #define xfs_inobt_rec_check_count(mp, rec) 0
  64. #endif /* DEBUG */
  65. #endif /* __XFS_IALLOC_BTREE_H__ */