xfs_refcount_btree.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2016 Oracle. All Rights Reserved.
  3. *
  4. * Author: Darrick J. Wong <darrick.wong@oracle.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it would be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write the Free Software Foundation,
  18. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef __XFS_REFCOUNT_BTREE_H__
  21. #define __XFS_REFCOUNT_BTREE_H__
  22. /*
  23. * Reference Count Btree on-disk structures
  24. */
  25. struct xfs_buf;
  26. struct xfs_btree_cur;
  27. struct xfs_mount;
  28. /*
  29. * Btree block header size
  30. */
  31. #define XFS_REFCOUNT_BLOCK_LEN XFS_BTREE_SBLOCK_CRC_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_REFCOUNT_REC_ADDR(block, index) \
  38. ((struct xfs_refcount_rec *) \
  39. ((char *)(block) + \
  40. XFS_REFCOUNT_BLOCK_LEN + \
  41. (((index) - 1) * sizeof(struct xfs_refcount_rec))))
  42. #define XFS_REFCOUNT_KEY_ADDR(block, index) \
  43. ((struct xfs_refcount_key *) \
  44. ((char *)(block) + \
  45. XFS_REFCOUNT_BLOCK_LEN + \
  46. ((index) - 1) * sizeof(struct xfs_refcount_key)))
  47. #define XFS_REFCOUNT_PTR_ADDR(block, index, maxrecs) \
  48. ((xfs_refcount_ptr_t *) \
  49. ((char *)(block) + \
  50. XFS_REFCOUNT_BLOCK_LEN + \
  51. (maxrecs) * sizeof(struct xfs_refcount_key) + \
  52. ((index) - 1) * sizeof(xfs_refcount_ptr_t)))
  53. extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp,
  54. struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agnumber_t agno,
  55. struct xfs_defer_ops *dfops);
  56. extern int xfs_refcountbt_maxrecs(struct xfs_mount *mp, int blocklen,
  57. bool leaf);
  58. extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp);
  59. extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
  60. unsigned long long len);
  61. extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
  62. xfs_agblock_t agblocks);
  63. extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
  64. xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
  65. #endif /* __XFS_REFCOUNT_BTREE_H__ */