xfs_alloc_btree.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_ALLOC_BTREE_H__
  19. #define __XFS_ALLOC_BTREE_H__
  20. /*
  21. * Freespace 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_ALLOC_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_ALLOC_REC_ADDR(mp, block, index) \
  38. ((xfs_alloc_rec_t *) \
  39. ((char *)(block) + \
  40. XFS_ALLOC_BLOCK_LEN(mp) + \
  41. (((index) - 1) * sizeof(xfs_alloc_rec_t))))
  42. #define XFS_ALLOC_KEY_ADDR(mp, block, index) \
  43. ((xfs_alloc_key_t *) \
  44. ((char *)(block) + \
  45. XFS_ALLOC_BLOCK_LEN(mp) + \
  46. ((index) - 1) * sizeof(xfs_alloc_key_t)))
  47. #define XFS_ALLOC_PTR_ADDR(mp, block, index, maxrecs) \
  48. ((xfs_alloc_ptr_t *) \
  49. ((char *)(block) + \
  50. XFS_ALLOC_BLOCK_LEN(mp) + \
  51. (maxrecs) * sizeof(xfs_alloc_key_t) + \
  52. ((index) - 1) * sizeof(xfs_alloc_ptr_t)))
  53. extern struct xfs_btree_cur *xfs_allocbt_init_cursor(struct xfs_mount *,
  54. struct xfs_trans *, struct xfs_buf *,
  55. xfs_agnumber_t, xfs_btnum_t);
  56. extern int xfs_allocbt_maxrecs(struct xfs_mount *, int, int);
  57. #endif /* __XFS_ALLOC_BTREE_H__ */