xfs_trans_resv.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright (c) 2000-2002,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_TRANS_RESV_H__
  19. #define __XFS_TRANS_RESV_H__
  20. struct xfs_mount;
  21. /*
  22. * structure for maintaining pre-calculated transaction reservations.
  23. */
  24. struct xfs_trans_res {
  25. uint tr_logres; /* log space unit in bytes per log ticket */
  26. int tr_logcount; /* number of log operations per log ticket */
  27. int tr_logflags; /* log flags, currently only used for indicating
  28. * a reservation request is permanent or not */
  29. };
  30. struct xfs_trans_resv {
  31. struct xfs_trans_res tr_write; /* extent alloc trans */
  32. struct xfs_trans_res tr_itruncate; /* truncate trans */
  33. struct xfs_trans_res tr_rename; /* rename trans */
  34. struct xfs_trans_res tr_link; /* link trans */
  35. struct xfs_trans_res tr_remove; /* unlink trans */
  36. struct xfs_trans_res tr_symlink; /* symlink trans */
  37. struct xfs_trans_res tr_create; /* create trans */
  38. struct xfs_trans_res tr_create_tmpfile; /* create O_TMPFILE trans */
  39. struct xfs_trans_res tr_mkdir; /* mkdir trans */
  40. struct xfs_trans_res tr_ifree; /* inode free trans */
  41. struct xfs_trans_res tr_ichange; /* inode update trans */
  42. struct xfs_trans_res tr_growdata; /* fs data section grow trans */
  43. struct xfs_trans_res tr_addafork; /* add inode attr fork trans */
  44. struct xfs_trans_res tr_writeid; /* write setuid/setgid file */
  45. struct xfs_trans_res tr_attrinval; /* attr fork buffer
  46. * invalidation */
  47. struct xfs_trans_res tr_attrsetm; /* set/create an attribute at
  48. * mount time */
  49. struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at
  50. * runtime */
  51. struct xfs_trans_res tr_attrrm; /* remove an attribute */
  52. struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */
  53. struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */
  54. struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */
  55. struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */
  56. struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */
  57. struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */
  58. struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */
  59. struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */
  60. struct xfs_trans_res tr_sb; /* modify superblock */
  61. struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */
  62. };
  63. /* shorthand way of accessing reservation structure */
  64. #define M_RES(mp) (&(mp)->m_resv)
  65. /*
  66. * Per-directory log reservation for any directory change.
  67. * dir blocks: (1 btree block per level + data block + free block) * dblock size
  68. * bmap btree: (levels + 2) * max depth * block size
  69. * v2 directory blocks can be fragmented below the dirblksize down to the fsb
  70. * size, so account for that in the DAENTER macros.
  71. */
  72. #define XFS_DIROP_LOG_RES(mp) \
  73. (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \
  74. (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)))
  75. #define XFS_DIROP_LOG_COUNT(mp) \
  76. (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \
  77. XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1)
  78. /*
  79. * Various log count values.
  80. */
  81. #define XFS_DEFAULT_LOG_COUNT 1
  82. #define XFS_DEFAULT_PERM_LOG_COUNT 2
  83. #define XFS_ITRUNCATE_LOG_COUNT 2
  84. #define XFS_ITRUNCATE_LOG_COUNT_REFLINK 8
  85. #define XFS_INACTIVE_LOG_COUNT 2
  86. #define XFS_CREATE_LOG_COUNT 2
  87. #define XFS_CREATE_TMPFILE_LOG_COUNT 2
  88. #define XFS_MKDIR_LOG_COUNT 3
  89. #define XFS_SYMLINK_LOG_COUNT 3
  90. #define XFS_REMOVE_LOG_COUNT 2
  91. #define XFS_LINK_LOG_COUNT 2
  92. #define XFS_RENAME_LOG_COUNT 2
  93. #define XFS_WRITE_LOG_COUNT 2
  94. #define XFS_WRITE_LOG_COUNT_REFLINK 8
  95. #define XFS_ADDAFORK_LOG_COUNT 2
  96. #define XFS_ATTRINVAL_LOG_COUNT 1
  97. #define XFS_ATTRSET_LOG_COUNT 3
  98. #define XFS_ATTRRM_LOG_COUNT 3
  99. void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp);
  100. uint xfs_allocfree_log_count(struct xfs_mount *mp, uint num_ops);
  101. #endif /* __XFS_TRANS_RESV_H__ */