xfs_trans_resv.h 4.1 KB

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