xfs_rmap_btree.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2014 Red Hat, 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_RMAP_BTREE_H__
  19. #define __XFS_RMAP_BTREE_H__
  20. struct xfs_buf;
  21. struct xfs_btree_cur;
  22. struct xfs_mount;
  23. /* rmaps only exist on crc enabled filesystems */
  24. #define XFS_RMAP_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_LEN
  25. /*
  26. * Record, key, and pointer address macros for btree blocks.
  27. *
  28. * (note that some of these may appear unused, but they are used in userspace)
  29. */
  30. #define XFS_RMAP_REC_ADDR(block, index) \
  31. ((struct xfs_rmap_rec *) \
  32. ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
  33. (((index) - 1) * sizeof(struct xfs_rmap_rec))))
  34. #define XFS_RMAP_KEY_ADDR(block, index) \
  35. ((struct xfs_rmap_key *) \
  36. ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
  37. ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
  38. #define XFS_RMAP_HIGH_KEY_ADDR(block, index) \
  39. ((struct xfs_rmap_key *) \
  40. ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
  41. sizeof(struct xfs_rmap_key) + \
  42. ((index) - 1) * 2 * sizeof(struct xfs_rmap_key)))
  43. #define XFS_RMAP_PTR_ADDR(block, index, maxrecs) \
  44. ((xfs_rmap_ptr_t *) \
  45. ((char *)(block) + XFS_RMAP_BLOCK_LEN + \
  46. (maxrecs) * 2 * sizeof(struct xfs_rmap_key) + \
  47. ((index) - 1) * sizeof(xfs_rmap_ptr_t)))
  48. struct xfs_btree_cur *xfs_rmapbt_init_cursor(struct xfs_mount *mp,
  49. struct xfs_trans *tp, struct xfs_buf *bp,
  50. xfs_agnumber_t agno);
  51. int xfs_rmapbt_maxrecs(struct xfs_mount *mp, int blocklen, int leaf);
  52. extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp);
  53. extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
  54. unsigned long long len);
  55. extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
  56. xfs_agblock_t agblocks);
  57. extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
  58. xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
  59. #endif /* __XFS_RMAP_BTREE_H__ */