xfs_quota_priv.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Copyright (c) 2000-2003 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_QUOTA_PRIV_H__
  19. #define __XFS_QUOTA_PRIV_H__
  20. /*
  21. * Number of bmaps that we ask from bmapi when doing a quotacheck.
  22. * We make this restriction to keep the memory usage to a minimum.
  23. */
  24. #define XFS_DQITER_MAP_SIZE 10
  25. /* Number of dquots that fit in to a dquot block */
  26. #define XFS_QM_DQPERBLK(mp) ((mp)->m_quotainfo->qi_dqperchunk)
  27. #define XFS_DQ_IS_ADDEDTO_TRX(t, d) ((d)->q_transp == (t))
  28. #define XFS_QI_UQIP(mp) ((mp)->m_quotainfo->qi_uquotaip)
  29. #define XFS_QI_GQIP(mp) ((mp)->m_quotainfo->qi_gquotaip)
  30. #define XFS_QI_DQCHUNKLEN(mp) ((mp)->m_quotainfo->qi_dqchunklen)
  31. #define XFS_QI_BTIMELIMIT(mp) ((mp)->m_quotainfo->qi_btimelimit)
  32. #define XFS_QI_RTBTIMELIMIT(mp) ((mp)->m_quotainfo->qi_rtbtimelimit)
  33. #define XFS_QI_ITIMELIMIT(mp) ((mp)->m_quotainfo->qi_itimelimit)
  34. #define XFS_QI_BWARNLIMIT(mp) ((mp)->m_quotainfo->qi_bwarnlimit)
  35. #define XFS_QI_RTBWARNLIMIT(mp) ((mp)->m_quotainfo->qi_rtbwarnlimit)
  36. #define XFS_QI_IWARNLIMIT(mp) ((mp)->m_quotainfo->qi_iwarnlimit)
  37. #define XFS_QI_QOFFLOCK(mp) ((mp)->m_quotainfo->qi_quotaofflock)
  38. #define xfs_qm_freelist_lock(qm) \
  39. mutex_lock(&((qm)->qm_dqfreelist.qh_lock))
  40. #define xfs_qm_freelist_lock_nowait(qm) \
  41. mutex_trylock(&((qm)->qm_dqfreelist.qh_lock))
  42. #define xfs_qm_freelist_unlock(qm) \
  43. mutex_unlock(&((qm)->qm_dqfreelist.qh_lock))
  44. /*
  45. * Hash into a bucket in the dquot hash table, based on <mp, id>.
  46. */
  47. #define XFS_DQ_HASHVAL(mp, id) (((__psunsigned_t)(mp) + \
  48. (__psunsigned_t)(id)) & \
  49. (xfs_Gqm->qm_dqhashmask - 1))
  50. #define XFS_DQ_HASH(mp, id, type) (type == XFS_DQ_USER ? \
  51. (xfs_Gqm->qm_usr_dqhtable + \
  52. XFS_DQ_HASHVAL(mp, id)) : \
  53. (xfs_Gqm->qm_grp_dqhtable + \
  54. XFS_DQ_HASHVAL(mp, id)))
  55. #define XFS_IS_DQTYPE_ON(mp, type) (type == XFS_DQ_USER ? \
  56. XFS_IS_UQUOTA_ON(mp) : \
  57. XFS_IS_OQUOTA_ON(mp))
  58. #define XFS_IS_DQUOT_UNINITIALIZED(dqp) ( \
  59. !dqp->q_core.d_blk_hardlimit && \
  60. !dqp->q_core.d_blk_softlimit && \
  61. !dqp->q_core.d_rtb_hardlimit && \
  62. !dqp->q_core.d_rtb_softlimit && \
  63. !dqp->q_core.d_ino_hardlimit && \
  64. !dqp->q_core.d_ino_softlimit && \
  65. !dqp->q_core.d_bcount && \
  66. !dqp->q_core.d_rtbcount && \
  67. !dqp->q_core.d_icount)
  68. #define HL_PREVP dq_hashlist.ql_prevp
  69. #define HL_NEXT dq_hashlist.ql_next
  70. #define _LIST_REMOVE(h, dqp, PVP, NXT) \
  71. { \
  72. xfs_dquot_t *d; \
  73. if (((d) = (dqp)->NXT)) \
  74. (d)->PVP = (dqp)->PVP; \
  75. *((dqp)->PVP) = d; \
  76. (dqp)->NXT = NULL; \
  77. (dqp)->PVP = NULL; \
  78. (h)->qh_version++; \
  79. (h)->qh_nelems--; \
  80. }
  81. #define _LIST_INSERT(h, dqp, PVP, NXT) \
  82. { \
  83. xfs_dquot_t *d; \
  84. if (((d) = (h)->qh_next)) \
  85. (d)->PVP = &((dqp)->NXT); \
  86. (dqp)->NXT = d; \
  87. (dqp)->PVP = &((h)->qh_next); \
  88. (h)->qh_next = dqp; \
  89. (h)->qh_version++; \
  90. (h)->qh_nelems++; \
  91. }
  92. #define FOREACH_DQUOT_IN_FREELIST(dqp, qlist) \
  93. for ((dqp) = (qlist)->qh_next; (dqp) != (xfs_dquot_t *)(qlist); \
  94. (dqp) = (dqp)->dq_flnext)
  95. #define XQM_HASHLIST_INSERT(h, dqp) \
  96. _LIST_INSERT(h, dqp, HL_PREVP, HL_NEXT)
  97. #define XQM_FREELIST_INSERT(h, dqp) \
  98. xfs_qm_freelist_append(h, dqp)
  99. #define XQM_HASHLIST_REMOVE(h, dqp) \
  100. _LIST_REMOVE(h, dqp, HL_PREVP, HL_NEXT)
  101. #define XQM_FREELIST_REMOVE(dqp) \
  102. xfs_qm_freelist_unlink(dqp)
  103. #define XFS_DQ_IS_LOGITEM_INITD(dqp) ((dqp)->q_logitem.qli_dquot == (dqp))
  104. #define XFS_QM_DQP_TO_DQACCT(tp, dqp) (XFS_QM_ISUDQ(dqp) ? \
  105. (tp)->t_dqinfo->dqa_usrdquots : \
  106. (tp)->t_dqinfo->dqa_grpdquots)
  107. #define XFS_IS_SUSER_DQUOT(dqp) \
  108. (!((dqp)->q_core.d_id))
  109. #define DQFLAGTO_TYPESTR(d) (((d)->dq_flags & XFS_DQ_USER) ? "USR" : \
  110. (((d)->dq_flags & XFS_DQ_GROUP) ? "GRP" : \
  111. (((d)->dq_flags & XFS_DQ_PROJ) ? "PRJ":"???")))
  112. #endif /* __XFS_QUOTA_PRIV_H__ */