xfs_quota.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Copyright (c) 2000-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_QUOTA_H__
  19. #define __XFS_QUOTA_H__
  20. #include "xfs_quota_defs.h"
  21. /*
  22. * Kernel only quota definitions and functions
  23. */
  24. struct xfs_trans;
  25. /*
  26. * This check is done typically without holding the inode lock;
  27. * that may seem racy, but it is harmless in the context that it is used.
  28. * The inode cannot go inactive as long a reference is kept, and
  29. * therefore if dquot(s) were attached, they'll stay consistent.
  30. * If, for example, the ownership of the inode changes while
  31. * we didn't have the inode locked, the appropriate dquot(s) will be
  32. * attached atomically.
  33. */
  34. #define XFS_NOT_DQATTACHED(mp, ip) \
  35. ((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \
  36. (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \
  37. (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL))
  38. #define XFS_QM_NEED_QUOTACHECK(mp) \
  39. ((XFS_IS_UQUOTA_ON(mp) && \
  40. (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
  41. (XFS_IS_GQUOTA_ON(mp) && \
  42. (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
  43. (XFS_IS_PQUOTA_ON(mp) && \
  44. (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
  45. /*
  46. * The structure kept inside the xfs_trans_t keep track of dquot changes
  47. * within a transaction and apply them later.
  48. */
  49. typedef struct xfs_dqtrx {
  50. struct xfs_dquot *qt_dquot; /* the dquot this refers to */
  51. ulong qt_blk_res; /* blks reserved on a dquot */
  52. ulong qt_ino_res; /* inode reserved on a dquot */
  53. ulong qt_ino_res_used; /* inodes used from the reservation */
  54. long qt_bcount_delta; /* dquot blk count changes */
  55. long qt_delbcnt_delta; /* delayed dquot blk count changes */
  56. long qt_icount_delta; /* dquot inode count changes */
  57. ulong qt_rtblk_res; /* # blks reserved on a dquot */
  58. ulong qt_rtblk_res_used;/* # blks used from reservation */
  59. long qt_rtbcount_delta;/* dquot realtime blk changes */
  60. long qt_delrtb_delta; /* delayed RT blk count changes */
  61. } xfs_dqtrx_t;
  62. #ifdef CONFIG_XFS_QUOTA
  63. extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *);
  64. extern void xfs_trans_free_dqinfo(struct xfs_trans *);
  65. extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *,
  66. uint, long);
  67. extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *);
  68. extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *);
  69. extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
  70. struct xfs_inode *, long, long, uint);
  71. extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
  72. struct xfs_mount *, struct xfs_dquot *,
  73. struct xfs_dquot *, struct xfs_dquot *, long, long, uint);
  74. extern int xfs_qm_vop_dqalloc(struct xfs_inode *, xfs_dqid_t, xfs_dqid_t,
  75. prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
  76. struct xfs_dquot **);
  77. extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
  78. struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *);
  79. extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
  80. extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *,
  81. struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *);
  82. extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *,
  83. struct xfs_dquot *, struct xfs_dquot *,
  84. struct xfs_dquot *, uint);
  85. extern int xfs_qm_dqattach(struct xfs_inode *, uint);
  86. extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint);
  87. extern void xfs_qm_dqdetach(struct xfs_inode *);
  88. extern void xfs_qm_dqrele(struct xfs_dquot *);
  89. extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *);
  90. extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *);
  91. extern void xfs_qm_mount_quotas(struct xfs_mount *);
  92. extern void xfs_qm_unmount(struct xfs_mount *);
  93. extern void xfs_qm_unmount_quotas(struct xfs_mount *);
  94. #else
  95. static inline int
  96. xfs_qm_vop_dqalloc(struct xfs_inode *ip, xfs_dqid_t uid, xfs_dqid_t gid,
  97. prid_t prid, uint flags, struct xfs_dquot **udqp,
  98. struct xfs_dquot **gdqp, struct xfs_dquot **pdqp)
  99. {
  100. *udqp = NULL;
  101. *gdqp = NULL;
  102. *pdqp = NULL;
  103. return 0;
  104. }
  105. #define xfs_trans_dup_dqinfo(tp, tp2)
  106. #define xfs_trans_free_dqinfo(tp)
  107. #define xfs_trans_mod_dquot_byino(tp, ip, fields, delta)
  108. #define xfs_trans_apply_dquot_deltas(tp)
  109. #define xfs_trans_unreserve_and_mod_dquots(tp)
  110. static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
  111. struct xfs_inode *ip, long nblks, long ninos, uint flags)
  112. {
  113. return 0;
  114. }
  115. static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
  116. struct xfs_mount *mp, struct xfs_dquot *udqp,
  117. struct xfs_dquot *gdqp, struct xfs_dquot *pdqp,
  118. long nblks, long nions, uint flags)
  119. {
  120. return 0;
  121. }
  122. #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
  123. #define xfs_qm_vop_rename_dqattach(it) (0)
  124. #define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
  125. #define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl) (0)
  126. #define xfs_qm_dqattach(ip, fl) (0)
  127. #define xfs_qm_dqattach_locked(ip, fl) (0)
  128. #define xfs_qm_dqdetach(ip)
  129. #define xfs_qm_dqrele(d)
  130. #define xfs_qm_statvfs(ip, s)
  131. #define xfs_qm_newmount(mp, a, b) (0)
  132. #define xfs_qm_mount_quotas(mp)
  133. #define xfs_qm_unmount(mp)
  134. #define xfs_qm_unmount_quotas(mp)
  135. #endif /* CONFIG_XFS_QUOTA */
  136. #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
  137. xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
  138. #define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
  139. xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
  140. f | XFS_QMOPT_RES_REGBLKS)
  141. extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
  142. #endif /* __XFS_QUOTA_H__ */