xfs_quota_defs.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  4. * All Rights Reserved.
  5. */
  6. #ifndef __XFS_QUOTA_DEFS_H__
  7. #define __XFS_QUOTA_DEFS_H__
  8. /*
  9. * Quota definitions shared between user and kernel source trees.
  10. */
  11. /*
  12. * Even though users may not have quota limits occupying all 64-bits,
  13. * they may need 64-bit accounting. Hence, 64-bit quota-counters,
  14. * and quota-limits. This is a waste in the common case, but hey ...
  15. */
  16. typedef uint64_t xfs_qcnt_t;
  17. typedef uint8_t xfs_dqtype_t;
  18. #define XFS_DQTYPE_STRINGS \
  19. { XFS_DQTYPE_USER, "USER" }, \
  20. { XFS_DQTYPE_PROJ, "PROJ" }, \
  21. { XFS_DQTYPE_GROUP, "GROUP" }, \
  22. { XFS_DQTYPE_BIGTIME, "BIGTIME" }
  23. /*
  24. * flags for q_flags field in the dquot.
  25. */
  26. #define XFS_DQFLAG_DIRTY (1u << 0) /* dquot is dirty */
  27. #define XFS_DQFLAG_FREEING (1u << 1) /* dquot is being torn down */
  28. #define XFS_DQFLAG_STRINGS \
  29. { XFS_DQFLAG_DIRTY, "DIRTY" }, \
  30. { XFS_DQFLAG_FREEING, "FREEING" }
  31. /*
  32. * We have the possibility of all three quota types being active at once, and
  33. * hence free space modification requires modification of all three current
  34. * dquots in a single transaction. For this case we need to have a reservation
  35. * of at least 3 dquots.
  36. *
  37. * However, a chmod operation can change both UID and GID in a single
  38. * transaction, resulting in requiring {old, new} x {uid, gid} dquots to be
  39. * modified. Hence for this case we need to reserve space for at least 4 dquots.
  40. *
  41. * And in the worst case, there's a rename operation that can be modifying up to
  42. * 4 inodes with dquots attached to them. In reality, the only inodes that can
  43. * have their dquots modified are the source and destination directory inodes
  44. * due to directory name creation and removal. That can require space allocation
  45. * and/or freeing on both directory inodes, and hence all three dquots on each
  46. * inode can be modified. And if the directories are world writeable, all the
  47. * dquots can be unique and so 6 dquots can be modified....
  48. *
  49. * And, of course, we also need to take into account the dquot log format item
  50. * used to describe each dquot.
  51. */
  52. #define XFS_DQUOT_LOGRES(mp) \
  53. ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6)
  54. #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
  55. #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
  56. #define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
  57. #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
  58. #define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD)
  59. #define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)
  60. #define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD)
  61. /*
  62. * Flags to tell various functions what to do. Not all of these are meaningful
  63. * to a single function. None of these XFS_QMOPT_* flags are meant to have
  64. * persistent values (ie. their values can and will change between versions)
  65. */
  66. #define XFS_QMOPT_UQUOTA (1u << 0) /* user dquot requested */
  67. #define XFS_QMOPT_GQUOTA (1u << 1) /* group dquot requested */
  68. #define XFS_QMOPT_PQUOTA (1u << 2) /* project dquot requested */
  69. #define XFS_QMOPT_FORCE_RES (1u << 3) /* ignore quota limits */
  70. #define XFS_QMOPT_SBVERSION (1u << 4) /* change superblock version num */
  71. /*
  72. * flags to xfs_trans_mod_dquot to indicate which field needs to be
  73. * modified.
  74. */
  75. #define XFS_QMOPT_RES_REGBLKS (1u << 7)
  76. #define XFS_QMOPT_RES_RTBLKS (1u << 8)
  77. #define XFS_QMOPT_BCOUNT (1u << 9)
  78. #define XFS_QMOPT_ICOUNT (1u << 10)
  79. #define XFS_QMOPT_RTBCOUNT (1u << 11)
  80. #define XFS_QMOPT_DELBCOUNT (1u << 12)
  81. #define XFS_QMOPT_DELRTBCOUNT (1u << 13)
  82. #define XFS_QMOPT_RES_INOS (1u << 14)
  83. /*
  84. * flags for dqalloc.
  85. */
  86. #define XFS_QMOPT_INHERIT (1u << 31)
  87. #define XFS_QMOPT_FLAGS \
  88. { XFS_QMOPT_UQUOTA, "UQUOTA" }, \
  89. { XFS_QMOPT_PQUOTA, "PQUOTA" }, \
  90. { XFS_QMOPT_FORCE_RES, "FORCE_RES" }, \
  91. { XFS_QMOPT_SBVERSION, "SBVERSION" }, \
  92. { XFS_QMOPT_GQUOTA, "GQUOTA" }, \
  93. { XFS_QMOPT_INHERIT, "INHERIT" }, \
  94. { XFS_QMOPT_RES_REGBLKS, "RES_REGBLKS" }, \
  95. { XFS_QMOPT_RES_RTBLKS, "RES_RTBLKS" }, \
  96. { XFS_QMOPT_BCOUNT, "BCOUNT" }, \
  97. { XFS_QMOPT_ICOUNT, "ICOUNT" }, \
  98. { XFS_QMOPT_RTBCOUNT, "RTBCOUNT" }, \
  99. { XFS_QMOPT_DELBCOUNT, "DELBCOUNT" }, \
  100. { XFS_QMOPT_DELRTBCOUNT, "DELRTBCOUNT" }, \
  101. { XFS_QMOPT_RES_INOS, "RES_INOS" }
  102. /*
  103. * flags to xfs_trans_mod_dquot.
  104. */
  105. #define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS
  106. #define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS
  107. #define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS
  108. #define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT
  109. #define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT
  110. #define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT
  111. #define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT
  112. #define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
  113. #define XFS_QMOPT_QUOTALL \
  114. (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
  115. #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
  116. extern xfs_failaddr_t xfs_dquot_verify(struct xfs_mount *mp,
  117. struct xfs_disk_dquot *ddq, xfs_dqid_t id);
  118. extern xfs_failaddr_t xfs_dqblk_verify(struct xfs_mount *mp,
  119. struct xfs_dqblk *dqb, xfs_dqid_t id);
  120. extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
  121. extern void xfs_dqblk_repair(struct xfs_mount *mp, struct xfs_dqblk *dqb,
  122. xfs_dqid_t id, xfs_dqtype_t type);
  123. struct xfs_dquot;
  124. time64_t xfs_dquot_from_disk_ts(struct xfs_disk_dquot *ddq,
  125. __be32 dtimer);
  126. __be32 xfs_dquot_to_disk_ts(struct xfs_dquot *ddq, time64_t timer);
  127. #endif /* __XFS_QUOTA_H__ */