11da177e4SLinus Torvalds /* 27b718769SNathan Scott * Copyright (c) 2000-2005 Silicon Graphics, Inc. 37b718769SNathan Scott * All Rights Reserved. 41da177e4SLinus Torvalds * 57b718769SNathan Scott * This program is free software; you can redistribute it and/or 67b718769SNathan Scott * modify it under the terms of the GNU General Public License as 71da177e4SLinus Torvalds * published by the Free Software Foundation. 81da177e4SLinus Torvalds * 97b718769SNathan Scott * This program is distributed in the hope that it would be useful, 107b718769SNathan Scott * but WITHOUT ANY WARRANTY; without even the implied warranty of 117b718769SNathan Scott * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 127b718769SNathan Scott * GNU General Public License for more details. 131da177e4SLinus Torvalds * 147b718769SNathan Scott * You should have received a copy of the GNU General Public License 157b718769SNathan Scott * along with this program; if not, write the Free Software Foundation, 167b718769SNathan Scott * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 171da177e4SLinus Torvalds */ 181da177e4SLinus Torvalds #ifndef __XFS_QUOTA_H__ 191da177e4SLinus Torvalds #define __XFS_QUOTA_H__ 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds /* 221da177e4SLinus Torvalds * The ondisk form of a dquot structure. 231da177e4SLinus Torvalds */ 241da177e4SLinus Torvalds #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ 251da177e4SLinus Torvalds #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */ 261da177e4SLinus Torvalds 271da177e4SLinus Torvalds /* 281da177e4SLinus Torvalds * uid_t and gid_t are hard-coded to 32 bits in the inode. 291da177e4SLinus Torvalds * Hence, an 'id' in a dquot is 32 bits.. 301da177e4SLinus Torvalds */ 31c310ab6cSNathan Scott typedef __uint32_t xfs_dqid_t; 321da177e4SLinus Torvalds 331da177e4SLinus Torvalds /* 341da177e4SLinus Torvalds * Even though users may not have quota limits occupying all 64-bits, 351da177e4SLinus Torvalds * they may need 64-bit accounting. Hence, 64-bit quota-counters, 361da177e4SLinus Torvalds * and quota-limits. This is a waste in the common case, but hey ... 371da177e4SLinus Torvalds */ 381da177e4SLinus Torvalds typedef __uint64_t xfs_qcnt_t; 391da177e4SLinus Torvalds typedef __uint16_t xfs_qwarncnt_t; 401da177e4SLinus Torvalds 411da177e4SLinus Torvalds /* 421da177e4SLinus Torvalds * This is the main portion of the on-disk representation of quota 431da177e4SLinus Torvalds * information for a user. This is the q_core of the xfs_dquot_t that 441da177e4SLinus Torvalds * is kept in kernel memory. We pad this with some more expansion room 451da177e4SLinus Torvalds * to construct the on disk structure. 461da177e4SLinus Torvalds */ 471da177e4SLinus Torvalds typedef struct xfs_disk_dquot { 481149d96aSChristoph Hellwig __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ 491149d96aSChristoph Hellwig __u8 d_version; /* dquot version */ 501149d96aSChristoph Hellwig __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */ 511149d96aSChristoph Hellwig __be32 d_id; /* user,project,group id */ 521149d96aSChristoph Hellwig __be64 d_blk_hardlimit;/* absolute limit on disk blks */ 531149d96aSChristoph Hellwig __be64 d_blk_softlimit;/* preferred limit on disk blks */ 541149d96aSChristoph Hellwig __be64 d_ino_hardlimit;/* maximum # allocated inodes */ 551149d96aSChristoph Hellwig __be64 d_ino_softlimit;/* preferred inode limit */ 561149d96aSChristoph Hellwig __be64 d_bcount; /* disk blocks owned by the user */ 571149d96aSChristoph Hellwig __be64 d_icount; /* inodes owned by the user */ 581149d96aSChristoph Hellwig __be32 d_itimer; /* zero if within inode limits if not, 591da177e4SLinus Torvalds this is when we refuse service */ 601149d96aSChristoph Hellwig __be32 d_btimer; /* similar to above; for disk blocks */ 611149d96aSChristoph Hellwig __be16 d_iwarns; /* warnings issued wrt num inodes */ 621149d96aSChristoph Hellwig __be16 d_bwarns; /* warnings issued wrt disk blocks */ 631149d96aSChristoph Hellwig __be32 d_pad0; /* 64 bit align */ 641149d96aSChristoph Hellwig __be64 d_rtb_hardlimit;/* absolute limit on realtime blks */ 651149d96aSChristoph Hellwig __be64 d_rtb_softlimit;/* preferred limit on RT disk blks */ 661149d96aSChristoph Hellwig __be64 d_rtbcount; /* realtime blocks owned */ 671149d96aSChristoph Hellwig __be32 d_rtbtimer; /* similar to above; for RT disk blocks */ 681149d96aSChristoph Hellwig __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */ 691149d96aSChristoph Hellwig __be16 d_pad; 701da177e4SLinus Torvalds } xfs_disk_dquot_t; 711da177e4SLinus Torvalds 721da177e4SLinus Torvalds /* 731da177e4SLinus Torvalds * This is what goes on disk. This is separated from the xfs_disk_dquot because 741da177e4SLinus Torvalds * carrying the unnecessary padding would be a waste of memory. 751da177e4SLinus Torvalds */ 761da177e4SLinus Torvalds typedef struct xfs_dqblk { 771da177e4SLinus Torvalds xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ 781da177e4SLinus Torvalds char dd_fill[32]; /* filling for posterity */ 791da177e4SLinus Torvalds } xfs_dqblk_t; 801da177e4SLinus Torvalds 811da177e4SLinus Torvalds /* 821da177e4SLinus Torvalds * flags for q_flags field in the dquot. 831da177e4SLinus Torvalds */ 841da177e4SLinus Torvalds #define XFS_DQ_USER 0x0001 /* a user quota */ 85c8ad20ffSNathan Scott #define XFS_DQ_PROJ 0x0002 /* project quota */ 861da177e4SLinus Torvalds #define XFS_DQ_GROUP 0x0004 /* a group quota */ 871da177e4SLinus Torvalds #define XFS_DQ_FLOCKED 0x0008 /* flush lock taken */ 881da177e4SLinus Torvalds #define XFS_DQ_DIRTY 0x0010 /* dquot is dirty */ 891da177e4SLinus Torvalds #define XFS_DQ_WANT 0x0020 /* for lookup/reclaim race */ 901da177e4SLinus Torvalds #define XFS_DQ_INACTIVE 0x0040 /* dq off mplist & hashlist */ 911da177e4SLinus Torvalds #define XFS_DQ_MARKER 0x0080 /* sentinel */ 921da177e4SLinus Torvalds 93c8ad20ffSNathan Scott #define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP) 94c8ad20ffSNathan Scott 951da177e4SLinus Torvalds /* 961da177e4SLinus Torvalds * In the worst case, when both user and group quotas are on, 971da177e4SLinus Torvalds * we can have a max of three dquots changing in a single transaction. 981da177e4SLinus Torvalds */ 991da177e4SLinus Torvalds #define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds 1021da177e4SLinus Torvalds /* 1031da177e4SLinus Torvalds * These are the structures used to lay out dquots and quotaoff 1041da177e4SLinus Torvalds * records on the log. Quite similar to those of inodes. 1051da177e4SLinus Torvalds */ 1061da177e4SLinus Torvalds 1071da177e4SLinus Torvalds /* 1081da177e4SLinus Torvalds * log format struct for dquots. 1091da177e4SLinus Torvalds * The first two fields must be the type and size fitting into 1101da177e4SLinus Torvalds * 32 bits : log_recovery code assumes that. 1111da177e4SLinus Torvalds */ 1121da177e4SLinus Torvalds typedef struct xfs_dq_logformat { 1131da177e4SLinus Torvalds __uint16_t qlf_type; /* dquot log item type */ 1141da177e4SLinus Torvalds __uint16_t qlf_size; /* size of this item */ 115c8ad20ffSNathan Scott xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */ 1161da177e4SLinus Torvalds __int64_t qlf_blkno; /* blkno of dquot buffer */ 1171da177e4SLinus Torvalds __int32_t qlf_len; /* len of dquot buffer */ 1181da177e4SLinus Torvalds __uint32_t qlf_boffset; /* off of dquot in buffer */ 1191da177e4SLinus Torvalds } xfs_dq_logformat_t; 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds /* 1221da177e4SLinus Torvalds * log format struct for QUOTAOFF records. 1231da177e4SLinus Torvalds * The first two fields must be the type and size fitting into 1241da177e4SLinus Torvalds * 32 bits : log_recovery code assumes that. 1251da177e4SLinus Torvalds * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer 1261da177e4SLinus Torvalds * to the first and ensures that the first logitem is taken out of the AIL 1271da177e4SLinus Torvalds * only when the last one is securely committed. 1281da177e4SLinus Torvalds */ 1291da177e4SLinus Torvalds typedef struct xfs_qoff_logformat { 1301da177e4SLinus Torvalds unsigned short qf_type; /* quotaoff log item type */ 1311da177e4SLinus Torvalds unsigned short qf_size; /* size of this item */ 1321da177e4SLinus Torvalds unsigned int qf_flags; /* USR and/or GRP */ 1331da177e4SLinus Torvalds char qf_pad[12]; /* padding for future */ 1341da177e4SLinus Torvalds } xfs_qoff_logformat_t; 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds 1371da177e4SLinus Torvalds /* 1381da177e4SLinus Torvalds * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. 1391da177e4SLinus Torvalds */ 1401da177e4SLinus Torvalds #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */ 1411da177e4SLinus Torvalds #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */ 1421da177e4SLinus Torvalds #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */ 143c8ad20ffSNathan Scott #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */ 144c8ad20ffSNathan Scott #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */ 145c8ad20ffSNathan Scott #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */ 1461da177e4SLinus Torvalds #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ 1471da177e4SLinus Torvalds 1481da177e4SLinus Torvalds /* 1494cd4a034STim Shimmin * Quota Accounting/Enforcement flags 1504cd4a034STim Shimmin */ 1514cd4a034STim Shimmin #define XFS_ALL_QUOTA_ACCT \ 1524cd4a034STim Shimmin (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) 1534cd4a034STim Shimmin #define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) 1544cd4a034STim Shimmin #define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) 1554cd4a034STim Shimmin 1564cd4a034STim Shimmin #define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) 1574cd4a034STim Shimmin #define XFS_IS_QUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ENFD) 1584cd4a034STim Shimmin #define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) 1594cd4a034STim Shimmin #define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) 1604cd4a034STim Shimmin #define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) 1614cd4a034STim Shimmin 1624cd4a034STim Shimmin /* 1631da177e4SLinus Torvalds * Incore only flags for quotaoff - these bits get cleared when quota(s) 1641da177e4SLinus Torvalds * are in the process of getting turned off. These flags are in m_qflags but 1651da177e4SLinus Torvalds * never in sb_qflags. 1661da177e4SLinus Torvalds */ 167c8ad20ffSNathan Scott #define XFS_UQUOTA_ACTIVE 0x0100 /* uquotas are being turned off */ 168c8ad20ffSNathan Scott #define XFS_PQUOTA_ACTIVE 0x0200 /* pquotas are being turned off */ 169c8ad20ffSNathan Scott #define XFS_GQUOTA_ACTIVE 0x0400 /* gquotas are being turned off */ 1701da177e4SLinus Torvalds 1711da177e4SLinus Torvalds /* 1721da177e4SLinus Torvalds * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees 1731da177e4SLinus Torvalds * quota will be not be switched off as long as that inode lock is held. 1741da177e4SLinus Torvalds */ 1751da177e4SLinus Torvalds #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ 176c8ad20ffSNathan Scott XFS_GQUOTA_ACTIVE | \ 177c8ad20ffSNathan Scott XFS_PQUOTA_ACTIVE)) 178c8ad20ffSNathan Scott #define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \ 179c8ad20ffSNathan Scott XFS_PQUOTA_ACTIVE)) 1801da177e4SLinus Torvalds #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) 1811da177e4SLinus Torvalds #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) 182c8ad20ffSNathan Scott #define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE) 1831da177e4SLinus Torvalds 1841da177e4SLinus Torvalds /* 1851da177e4SLinus Torvalds * Flags to tell various functions what to do. Not all of these are meaningful 1861da177e4SLinus Torvalds * to a single function. None of these XFS_QMOPT_* flags are meant to have 1871da177e4SLinus Torvalds * persistent values (ie. their values can and will change between versions) 1881da177e4SLinus Torvalds */ 1891da177e4SLinus Torvalds #define XFS_QMOPT_DQLOCK 0x0000001 /* dqlock */ 1901da177e4SLinus Torvalds #define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */ 1911da177e4SLinus Torvalds #define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */ 192c8ad20ffSNathan Scott #define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */ 1931da177e4SLinus Torvalds #define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */ 1941da177e4SLinus Torvalds #define XFS_QMOPT_DQSUSER 0x0000020 /* don't cache super users dquot */ 1951da177e4SLinus Torvalds #define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */ 1961da177e4SLinus Torvalds #define XFS_QMOPT_QUOTAOFF 0x0000080 /* quotas are being turned off */ 1971da177e4SLinus Torvalds #define XFS_QMOPT_UMOUNTING 0x0000100 /* filesys is being unmounted */ 1981da177e4SLinus Torvalds #define XFS_QMOPT_DOLOG 0x0000200 /* log buf changes (in quotacheck) */ 1991da177e4SLinus Torvalds #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if necessary */ 2001da177e4SLinus Torvalds #define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */ 2011da177e4SLinus Torvalds #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot, if damaged. */ 202c8ad20ffSNathan Scott #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ 2031da177e4SLinus Torvalds 2041da177e4SLinus Torvalds /* 2051da177e4SLinus Torvalds * flags to xfs_trans_mod_dquot to indicate which field needs to be 2061da177e4SLinus Torvalds * modified. 2071da177e4SLinus Torvalds */ 2081da177e4SLinus Torvalds #define XFS_QMOPT_RES_REGBLKS 0x0010000 2091da177e4SLinus Torvalds #define XFS_QMOPT_RES_RTBLKS 0x0020000 2101da177e4SLinus Torvalds #define XFS_QMOPT_BCOUNT 0x0040000 2111da177e4SLinus Torvalds #define XFS_QMOPT_ICOUNT 0x0080000 2121da177e4SLinus Torvalds #define XFS_QMOPT_RTBCOUNT 0x0100000 2131da177e4SLinus Torvalds #define XFS_QMOPT_DELBCOUNT 0x0200000 2141da177e4SLinus Torvalds #define XFS_QMOPT_DELRTBCOUNT 0x0400000 2151da177e4SLinus Torvalds #define XFS_QMOPT_RES_INOS 0x0800000 2161da177e4SLinus Torvalds 2171da177e4SLinus Torvalds /* 2181da177e4SLinus Torvalds * flags for dqflush and dqflush_all. 2191da177e4SLinus Torvalds */ 2201da177e4SLinus Torvalds #define XFS_QMOPT_SYNC 0x1000000 2211da177e4SLinus Torvalds #define XFS_QMOPT_ASYNC 0x2000000 2221da177e4SLinus Torvalds #define XFS_QMOPT_DELWRI 0x4000000 2231da177e4SLinus Torvalds 2241da177e4SLinus Torvalds /* 2251da177e4SLinus Torvalds * flags for dqalloc. 2261da177e4SLinus Torvalds */ 2271da177e4SLinus Torvalds #define XFS_QMOPT_INHERIT 0x8000000 2281da177e4SLinus Torvalds 2291da177e4SLinus Torvalds /* 2301da177e4SLinus Torvalds * flags to xfs_trans_mod_dquot. 2311da177e4SLinus Torvalds */ 2321da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS 2331da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS 2341da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS 2351da177e4SLinus Torvalds #define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT 2361da177e4SLinus Torvalds #define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT 2371da177e4SLinus Torvalds #define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT 2381da177e4SLinus Torvalds #define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT 2391da177e4SLinus Torvalds #define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT 2401da177e4SLinus Torvalds 2411da177e4SLinus Torvalds 242c8ad20ffSNathan Scott #define XFS_QMOPT_QUOTALL \ 243c8ad20ffSNathan Scott (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA) 2441da177e4SLinus Torvalds #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) 2451da177e4SLinus Torvalds 2461da177e4SLinus Torvalds #ifdef __KERNEL__ 2471da177e4SLinus Torvalds /* 2481da177e4SLinus Torvalds * This check is done typically without holding the inode lock; 249*c41564b5SNathan Scott * that may seem racy, but it is harmless in the context that it is used. 2501da177e4SLinus Torvalds * The inode cannot go inactive as long a reference is kept, and 2511da177e4SLinus Torvalds * therefore if dquot(s) were attached, they'll stay consistent. 2521da177e4SLinus Torvalds * If, for example, the ownership of the inode changes while 2531da177e4SLinus Torvalds * we didn't have the inode locked, the appropriate dquot(s) will be 2541da177e4SLinus Torvalds * attached atomically. 2551da177e4SLinus Torvalds */ 2561da177e4SLinus Torvalds #define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ 2571da177e4SLinus Torvalds (ip)->i_udquot == NULL) || \ 258c8ad20ffSNathan Scott (XFS_IS_OQUOTA_ON(mp) && \ 2591da177e4SLinus Torvalds (ip)->i_gdquot == NULL)) 2601da177e4SLinus Torvalds 261c8ad20ffSNathan Scott #define XFS_QM_NEED_QUOTACHECK(mp) \ 262c8ad20ffSNathan Scott ((XFS_IS_UQUOTA_ON(mp) && \ 263c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \ 2641da177e4SLinus Torvalds (XFS_IS_GQUOTA_ON(mp) && \ 265c8ad20ffSNathan Scott ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 266c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \ 267c8ad20ffSNathan Scott (XFS_IS_PQUOTA_ON(mp) && \ 268c8ad20ffSNathan Scott ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 269c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) 270c8ad20ffSNathan Scott 271c8ad20ffSNathan Scott #define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 272c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ 273c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) 274c8ad20ffSNathan Scott 275c8ad20ffSNathan Scott #define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 276c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ 277c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) 2781da177e4SLinus Torvalds 2791da177e4SLinus Torvalds #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 280c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ 281c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ 282c8ad20ffSNathan Scott XFS_GQUOTA_ACCT) 2831da177e4SLinus Torvalds #define XFS_MOUNT_QUOTA_MASK (XFS_MOUNT_QUOTA_ALL | XFS_UQUOTA_ACTIVE | \ 284c8ad20ffSNathan Scott XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE) 2851da177e4SLinus Torvalds 2861da177e4SLinus Torvalds 2871da177e4SLinus Torvalds /* 2881da177e4SLinus Torvalds * The structure kept inside the xfs_trans_t keep track of dquot changes 2891da177e4SLinus Torvalds * within a transaction and apply them later. 2901da177e4SLinus Torvalds */ 2911da177e4SLinus Torvalds typedef struct xfs_dqtrx { 2921da177e4SLinus Torvalds struct xfs_dquot *qt_dquot; /* the dquot this refers to */ 2931da177e4SLinus Torvalds ulong qt_blk_res; /* blks reserved on a dquot */ 2941da177e4SLinus Torvalds ulong qt_blk_res_used; /* blks used from the reservation */ 2951da177e4SLinus Torvalds ulong qt_ino_res; /* inode reserved on a dquot */ 2961da177e4SLinus Torvalds ulong qt_ino_res_used; /* inodes used from the reservation */ 2971da177e4SLinus Torvalds long qt_bcount_delta; /* dquot blk count changes */ 2981da177e4SLinus Torvalds long qt_delbcnt_delta; /* delayed dquot blk count changes */ 2991da177e4SLinus Torvalds long qt_icount_delta; /* dquot inode count changes */ 3001da177e4SLinus Torvalds ulong qt_rtblk_res; /* # blks reserved on a dquot */ 3011da177e4SLinus Torvalds ulong qt_rtblk_res_used;/* # blks used from reservation */ 3021da177e4SLinus Torvalds long qt_rtbcount_delta;/* dquot realtime blk changes */ 3031da177e4SLinus Torvalds long qt_delrtb_delta; /* delayed RT blk count changes */ 3041da177e4SLinus Torvalds } xfs_dqtrx_t; 3051da177e4SLinus Torvalds 3061da177e4SLinus Torvalds /* 3071da177e4SLinus Torvalds * Dquot transaction functions, used if quota is enabled. 3081da177e4SLinus Torvalds */ 3091da177e4SLinus Torvalds typedef void (*qo_dup_dqinfo_t)(struct xfs_trans *, struct xfs_trans *); 3101da177e4SLinus Torvalds typedef void (*qo_mod_dquot_byino_t)(struct xfs_trans *, 3111da177e4SLinus Torvalds struct xfs_inode *, uint, long); 3121da177e4SLinus Torvalds typedef void (*qo_free_dqinfo_t)(struct xfs_trans *); 3131da177e4SLinus Torvalds typedef void (*qo_apply_dquot_deltas_t)(struct xfs_trans *); 3141da177e4SLinus Torvalds typedef void (*qo_unreserve_and_mod_dquots_t)(struct xfs_trans *); 3151da177e4SLinus Torvalds typedef int (*qo_reserve_quota_nblks_t)( 3161da177e4SLinus Torvalds struct xfs_trans *, struct xfs_mount *, 3171da177e4SLinus Torvalds struct xfs_inode *, long, long, uint); 3181da177e4SLinus Torvalds typedef int (*qo_reserve_quota_bydquots_t)( 3191da177e4SLinus Torvalds struct xfs_trans *, struct xfs_mount *, 3201da177e4SLinus Torvalds struct xfs_dquot *, struct xfs_dquot *, 3211da177e4SLinus Torvalds long, long, uint); 3221da177e4SLinus Torvalds typedef struct xfs_dqtrxops { 3231da177e4SLinus Torvalds qo_dup_dqinfo_t qo_dup_dqinfo; 3241da177e4SLinus Torvalds qo_free_dqinfo_t qo_free_dqinfo; 3251da177e4SLinus Torvalds qo_mod_dquot_byino_t qo_mod_dquot_byino; 3261da177e4SLinus Torvalds qo_apply_dquot_deltas_t qo_apply_dquot_deltas; 3271da177e4SLinus Torvalds qo_reserve_quota_nblks_t qo_reserve_quota_nblks; 3281da177e4SLinus Torvalds qo_reserve_quota_bydquots_t qo_reserve_quota_bydquots; 3291da177e4SLinus Torvalds qo_unreserve_and_mod_dquots_t qo_unreserve_and_mod_dquots; 3301da177e4SLinus Torvalds } xfs_dqtrxops_t; 3311da177e4SLinus Torvalds 3321da177e4SLinus Torvalds #define XFS_DQTRXOP(mp, tp, op, args...) \ 3331da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops ? \ 3341da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops->op)(tp, ## args) : 0) 3351da177e4SLinus Torvalds 3361da177e4SLinus Torvalds #define XFS_DQTRXOP_VOID(mp, tp, op, args...) \ 3371da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops ? \ 3381da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops->op)(tp, ## args) : (void)0) 3391da177e4SLinus Torvalds 3401da177e4SLinus Torvalds #define XFS_TRANS_DUP_DQINFO(mp, otp, ntp) \ 3411da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, otp, qo_dup_dqinfo, ntp) 3421da177e4SLinus Torvalds #define XFS_TRANS_FREE_DQINFO(mp, tp) \ 3431da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_free_dqinfo) 3441da177e4SLinus Torvalds #define XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, field, delta) \ 3451da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_mod_dquot_byino, ip, field, delta) 3461da177e4SLinus Torvalds #define XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp) \ 3471da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_apply_dquot_deltas) 3481da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, fl) \ 3491da177e4SLinus Torvalds XFS_DQTRXOP(mp, tp, qo_reserve_quota_nblks, mp, ip, nblks, ninos, fl) 3501da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, fl) \ 3511da177e4SLinus Torvalds XFS_DQTRXOP(mp, tp, qo_reserve_quota_bydquots, mp, ud, gd, nb, ni, fl) 3521da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \ 3531da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots) 3541da177e4SLinus Torvalds 35506d10dd9SNathan Scott #define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, flags) \ 35606d10dd9SNathan Scott XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), -(ninos), flags) 3571da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 3581da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ 3591da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 3601da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 3611da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \ 3621da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 3631da177e4SLinus Torvalds 3641da177e4SLinus Torvalds extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 3654cd4a034STim Shimmin extern int xfs_mount_reset_sbqflags(struct xfs_mount *); 3661da177e4SLinus Torvalds 3671da177e4SLinus Torvalds extern struct bhv_vfsops xfs_qmops; 3681da177e4SLinus Torvalds 3691da177e4SLinus Torvalds #endif /* __KERNEL__ */ 3701da177e4SLinus Torvalds 3711da177e4SLinus Torvalds #endif /* __XFS_QUOTA_H__ */ 372