xfs_trans_space.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #ifndef __XFS_TRANS_SPACE_H__
  33. #define __XFS_TRANS_SPACE_H__
  34. /*
  35. * Components of space reservations.
  36. */
  37. #define XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) \
  38. (((mp)->m_alloc_mxr[0]) - ((mp)->m_alloc_mnr[0]))
  39. #define XFS_EXTENTADD_SPACE_RES(mp,w) (XFS_BM_MAXLEVELS(mp,w) - 1)
  40. #define XFS_NEXTENTADD_SPACE_RES(mp,b,w)\
  41. (((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \
  42. XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \
  43. XFS_EXTENTADD_SPACE_RES(mp,w))
  44. #define XFS_DAENTER_1B(mp,w) ((w) == XFS_DATA_FORK ? (mp)->m_dirblkfsbs : 1)
  45. #define XFS_DAENTER_DBS(mp,w) \
  46. (XFS_DA_NODE_MAXDEPTH + \
  47. ((XFS_DIR_IS_V2(mp) && (w) == XFS_DATA_FORK) ? 2 : 0))
  48. #define XFS_DAENTER_BLOCKS(mp,w) \
  49. (XFS_DAENTER_1B(mp,w) * XFS_DAENTER_DBS(mp,w))
  50. #define XFS_DAENTER_BMAP1B(mp,w) \
  51. XFS_NEXTENTADD_SPACE_RES(mp, XFS_DAENTER_1B(mp, w), w)
  52. #define XFS_DAENTER_BMAPS(mp,w) \
  53. (XFS_DAENTER_DBS(mp,w) * XFS_DAENTER_BMAP1B(mp,w))
  54. #define XFS_DAENTER_SPACE_RES(mp,w) \
  55. (XFS_DAENTER_BLOCKS(mp,w) + XFS_DAENTER_BMAPS(mp,w))
  56. #define XFS_DAREMOVE_SPACE_RES(mp,w) XFS_DAENTER_BMAPS(mp,w)
  57. #define XFS_DIRENTER_MAX_SPLIT(mp,nl) \
  58. (((mp)->m_sb.sb_blocksize == 512 && \
  59. XFS_DIR_IS_V1(mp) && \
  60. (nl) >= XFS_DIR_LEAF_CAN_DOUBLE_SPLIT_LEN) ? 2 : 1)
  61. #define XFS_DIRENTER_SPACE_RES(mp,nl) \
  62. (XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK) * \
  63. XFS_DIRENTER_MAX_SPLIT(mp,nl))
  64. #define XFS_DIRREMOVE_SPACE_RES(mp) \
  65. XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK)
  66. #define XFS_IALLOC_SPACE_RES(mp) \
  67. (XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp)-1)
  68. /*
  69. * Space reservation values for various transactions.
  70. */
  71. #define XFS_ADDAFORK_SPACE_RES(mp) \
  72. ((mp)->m_dirblkfsbs + \
  73. (XFS_DIR_IS_V1(mp) ? 0 : XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK)))
  74. #define XFS_ATTRRM_SPACE_RES(mp) \
  75. XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK)
  76. /* This macro is not used - see inline code in xfs_attr_set */
  77. #define XFS_ATTRSET_SPACE_RES(mp, v) \
  78. (XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + XFS_B_TO_FSB(mp, v))
  79. #define XFS_CREATE_SPACE_RES(mp,nl) \
  80. (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
  81. #define XFS_DIOSTRAT_SPACE_RES(mp, v) \
  82. (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + (v))
  83. #define XFS_GROWFS_SPACE_RES(mp) \
  84. (2 * XFS_AG_MAXLEVELS(mp))
  85. #define XFS_GROWFSRT_SPACE_RES(mp,b) \
  86. ((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK))
  87. #define XFS_LINK_SPACE_RES(mp,nl) \
  88. XFS_DIRENTER_SPACE_RES(mp,nl)
  89. #define XFS_MKDIR_SPACE_RES(mp,nl) \
  90. (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
  91. #define XFS_QM_DQALLOC_SPACE_RES(mp) \
  92. (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + \
  93. XFS_DQUOT_CLUSTER_SIZE_FSB)
  94. #define XFS_QM_QINOCREATE_SPACE_RES(mp) \
  95. XFS_IALLOC_SPACE_RES(mp)
  96. #define XFS_REMOVE_SPACE_RES(mp) \
  97. XFS_DIRREMOVE_SPACE_RES(mp)
  98. #define XFS_RENAME_SPACE_RES(mp,nl) \
  99. (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
  100. #define XFS_SYMLINK_SPACE_RES(mp,nl,b) \
  101. (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b))
  102. #endif /* __XFS_TRANS_SPACE_H__ */