184be0ffcSDave Chinner /* 284be0ffcSDave Chinner * Copyright (c) 2000-2005 Silicon Graphics, Inc. 384be0ffcSDave Chinner * All Rights Reserved. 484be0ffcSDave Chinner * 584be0ffcSDave Chinner * This program is free software; you can redistribute it and/or 684be0ffcSDave Chinner * modify it under the terms of the GNU General Public License as 784be0ffcSDave Chinner * published by the Free Software Foundation. 884be0ffcSDave Chinner * 984be0ffcSDave Chinner * This program is distributed in the hope that it would be useful, 1084be0ffcSDave Chinner * but WITHOUT ANY WARRANTY; without even the implied warranty of 1184be0ffcSDave Chinner * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1284be0ffcSDave Chinner * GNU General Public License for more details. 1384be0ffcSDave Chinner * 1484be0ffcSDave Chinner * You should have received a copy of the GNU General Public License 1584be0ffcSDave Chinner * along with this program; if not, write the Free Software Foundation, 1684be0ffcSDave Chinner * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 1784be0ffcSDave Chinner */ 1884be0ffcSDave Chinner #ifndef __XFS_QUOTA_DEFS_H__ 1984be0ffcSDave Chinner #define __XFS_QUOTA_DEFS_H__ 2084be0ffcSDave Chinner 2184be0ffcSDave Chinner /* 2284be0ffcSDave Chinner * Quota definitions shared between user and kernel source trees. 2384be0ffcSDave Chinner */ 2484be0ffcSDave Chinner 2584be0ffcSDave Chinner /* 2684be0ffcSDave Chinner * Even though users may not have quota limits occupying all 64-bits, 2784be0ffcSDave Chinner * they may need 64-bit accounting. Hence, 64-bit quota-counters, 2884be0ffcSDave Chinner * and quota-limits. This is a waste in the common case, but hey ... 2984be0ffcSDave Chinner */ 3084be0ffcSDave Chinner typedef __uint64_t xfs_qcnt_t; 3184be0ffcSDave Chinner typedef __uint16_t xfs_qwarncnt_t; 3284be0ffcSDave Chinner 3384be0ffcSDave Chinner /* 3484be0ffcSDave Chinner * flags for q_flags field in the dquot. 3584be0ffcSDave Chinner */ 3684be0ffcSDave Chinner #define XFS_DQ_USER 0x0001 /* a user quota */ 3784be0ffcSDave Chinner #define XFS_DQ_PROJ 0x0002 /* project quota */ 3884be0ffcSDave Chinner #define XFS_DQ_GROUP 0x0004 /* a group quota */ 3984be0ffcSDave Chinner #define XFS_DQ_DIRTY 0x0008 /* dquot is dirty */ 4084be0ffcSDave Chinner #define XFS_DQ_FREEING 0x0010 /* dquot is beeing torn down */ 4184be0ffcSDave Chinner 4284be0ffcSDave Chinner #define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP) 4384be0ffcSDave Chinner 4484be0ffcSDave Chinner #define XFS_DQ_FLAGS \ 4584be0ffcSDave Chinner { XFS_DQ_USER, "USER" }, \ 4684be0ffcSDave Chinner { XFS_DQ_PROJ, "PROJ" }, \ 4784be0ffcSDave Chinner { XFS_DQ_GROUP, "GROUP" }, \ 4884be0ffcSDave Chinner { XFS_DQ_DIRTY, "DIRTY" }, \ 4984be0ffcSDave Chinner { XFS_DQ_FREEING, "FREEING" } 5084be0ffcSDave Chinner 5184be0ffcSDave Chinner /* 5284be0ffcSDave Chinner * We have the possibility of all three quota types being active at once, and 5384be0ffcSDave Chinner * hence free space modification requires modification of all three current 5484be0ffcSDave Chinner * dquots in a single transaction. For this case we need to have a reservation 5584be0ffcSDave Chinner * of at least 3 dquots. 5684be0ffcSDave Chinner * 5784be0ffcSDave Chinner * However, a chmod operation can change both UID and GID in a single 5884be0ffcSDave Chinner * transaction, resulting in requiring {old, new} x {uid, gid} dquots to be 5984be0ffcSDave Chinner * modified. Hence for this case we need to reserve space for at least 4 dquots. 6084be0ffcSDave Chinner * 6184be0ffcSDave Chinner * And in the worst case, there's a rename operation that can be modifying up to 6284be0ffcSDave Chinner * 4 inodes with dquots attached to them. In reality, the only inodes that can 6384be0ffcSDave Chinner * have their dquots modified are the source and destination directory inodes 6484be0ffcSDave Chinner * due to directory name creation and removal. That can require space allocation 6584be0ffcSDave Chinner * and/or freeing on both directory inodes, and hence all three dquots on each 6684be0ffcSDave Chinner * inode can be modified. And if the directories are world writeable, all the 6784be0ffcSDave Chinner * dquots can be unique and so 6 dquots can be modified.... 6884be0ffcSDave Chinner * 6984be0ffcSDave Chinner * And, of course, we also need to take into account the dquot log format item 7084be0ffcSDave Chinner * used to describe each dquot. 7184be0ffcSDave Chinner */ 7284be0ffcSDave Chinner #define XFS_DQUOT_LOGRES(mp) \ 7384be0ffcSDave Chinner ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6) 7484be0ffcSDave Chinner 7584be0ffcSDave Chinner #define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) 7684be0ffcSDave Chinner #define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) 7784be0ffcSDave Chinner #define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) 7884be0ffcSDave Chinner #define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) 7984be0ffcSDave Chinner #define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) 8084be0ffcSDave Chinner #define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD) 8184be0ffcSDave Chinner #define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) 8284be0ffcSDave Chinner 8384be0ffcSDave Chinner /* 8484be0ffcSDave Chinner * Incore only flags for quotaoff - these bits get cleared when quota(s) 8584be0ffcSDave Chinner * are in the process of getting turned off. These flags are in m_qflags but 8684be0ffcSDave Chinner * never in sb_qflags. 8784be0ffcSDave Chinner */ 8884be0ffcSDave Chinner #define XFS_UQUOTA_ACTIVE 0x1000 /* uquotas are being turned off */ 8984be0ffcSDave Chinner #define XFS_GQUOTA_ACTIVE 0x2000 /* gquotas are being turned off */ 9084be0ffcSDave Chinner #define XFS_PQUOTA_ACTIVE 0x4000 /* pquotas are being turned off */ 9184be0ffcSDave Chinner #define XFS_ALL_QUOTA_ACTIVE \ 9284be0ffcSDave Chinner (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE) 9384be0ffcSDave Chinner 9484be0ffcSDave Chinner /* 9584be0ffcSDave Chinner * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees 9684be0ffcSDave Chinner * quota will be not be switched off as long as that inode lock is held. 9784be0ffcSDave Chinner */ 9884be0ffcSDave Chinner #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ 9984be0ffcSDave Chinner XFS_GQUOTA_ACTIVE | \ 10084be0ffcSDave Chinner XFS_PQUOTA_ACTIVE)) 10184be0ffcSDave Chinner #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) 10284be0ffcSDave Chinner #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) 10384be0ffcSDave Chinner #define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE) 10484be0ffcSDave Chinner 10584be0ffcSDave Chinner /* 10684be0ffcSDave Chinner * Flags to tell various functions what to do. Not all of these are meaningful 10784be0ffcSDave Chinner * to a single function. None of these XFS_QMOPT_* flags are meant to have 10884be0ffcSDave Chinner * persistent values (ie. their values can and will change between versions) 10984be0ffcSDave Chinner */ 11084be0ffcSDave Chinner #define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */ 11184be0ffcSDave Chinner #define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */ 11284be0ffcSDave Chinner #define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */ 11384be0ffcSDave Chinner #define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */ 11484be0ffcSDave Chinner #define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */ 11584be0ffcSDave Chinner #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */ 11684be0ffcSDave Chinner #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */ 11784be0ffcSDave Chinner #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ 11884be0ffcSDave Chinner #define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */ 11984be0ffcSDave Chinner 12084be0ffcSDave Chinner /* 12184be0ffcSDave Chinner * flags to xfs_trans_mod_dquot to indicate which field needs to be 12284be0ffcSDave Chinner * modified. 12384be0ffcSDave Chinner */ 12484be0ffcSDave Chinner #define XFS_QMOPT_RES_REGBLKS 0x0010000 12584be0ffcSDave Chinner #define XFS_QMOPT_RES_RTBLKS 0x0020000 12684be0ffcSDave Chinner #define XFS_QMOPT_BCOUNT 0x0040000 12784be0ffcSDave Chinner #define XFS_QMOPT_ICOUNT 0x0080000 12884be0ffcSDave Chinner #define XFS_QMOPT_RTBCOUNT 0x0100000 12984be0ffcSDave Chinner #define XFS_QMOPT_DELBCOUNT 0x0200000 13084be0ffcSDave Chinner #define XFS_QMOPT_DELRTBCOUNT 0x0400000 13184be0ffcSDave Chinner #define XFS_QMOPT_RES_INOS 0x0800000 13284be0ffcSDave Chinner 13384be0ffcSDave Chinner /* 13484be0ffcSDave Chinner * flags for dqalloc. 13584be0ffcSDave Chinner */ 13684be0ffcSDave Chinner #define XFS_QMOPT_INHERIT 0x1000000 13784be0ffcSDave Chinner 13884be0ffcSDave Chinner /* 13984be0ffcSDave Chinner * flags to xfs_trans_mod_dquot. 14084be0ffcSDave Chinner */ 14184be0ffcSDave Chinner #define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS 14284be0ffcSDave Chinner #define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS 14384be0ffcSDave Chinner #define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS 14484be0ffcSDave Chinner #define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT 14584be0ffcSDave Chinner #define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT 14684be0ffcSDave Chinner #define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT 14784be0ffcSDave Chinner #define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT 14884be0ffcSDave Chinner #define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT 14984be0ffcSDave Chinner 15084be0ffcSDave Chinner 15184be0ffcSDave Chinner #define XFS_QMOPT_QUOTALL \ 15284be0ffcSDave Chinner (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA) 15384be0ffcSDave Chinner #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) 15484be0ffcSDave Chinner 15584be0ffcSDave Chinner extern int xfs_dqcheck(struct xfs_mount *mp, xfs_disk_dquot_t *ddq, 1567d6a13f0SDave Chinner xfs_dqid_t id, uint type, uint flags, const char *str); 15784be0ffcSDave Chinner extern int xfs_calc_dquots_per_chunk(unsigned int nbblks); 15884be0ffcSDave Chinner 15984be0ffcSDave Chinner #endif /* __XFS_QUOTA_H__ */ 160