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 21*fcafb71bSChristoph Hellwig struct xfs_trans; 22*fcafb71bSChristoph Hellwig 231da177e4SLinus Torvalds /* 241da177e4SLinus Torvalds * The ondisk form of a dquot structure. 251da177e4SLinus Torvalds */ 261da177e4SLinus Torvalds #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ 271da177e4SLinus Torvalds #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */ 281da177e4SLinus Torvalds 291da177e4SLinus Torvalds /* 301da177e4SLinus Torvalds * uid_t and gid_t are hard-coded to 32 bits in the inode. 311da177e4SLinus Torvalds * Hence, an 'id' in a dquot is 32 bits.. 321da177e4SLinus Torvalds */ 33c310ab6cSNathan Scott typedef __uint32_t xfs_dqid_t; 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds /* 361da177e4SLinus Torvalds * Even though users may not have quota limits occupying all 64-bits, 371da177e4SLinus Torvalds * they may need 64-bit accounting. Hence, 64-bit quota-counters, 381da177e4SLinus Torvalds * and quota-limits. This is a waste in the common case, but hey ... 391da177e4SLinus Torvalds */ 401da177e4SLinus Torvalds typedef __uint64_t xfs_qcnt_t; 411da177e4SLinus Torvalds typedef __uint16_t xfs_qwarncnt_t; 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds /* 441da177e4SLinus Torvalds * This is the main portion of the on-disk representation of quota 451da177e4SLinus Torvalds * information for a user. This is the q_core of the xfs_dquot_t that 461da177e4SLinus Torvalds * is kept in kernel memory. We pad this with some more expansion room 471da177e4SLinus Torvalds * to construct the on disk structure. 481da177e4SLinus Torvalds */ 491da177e4SLinus Torvalds typedef struct xfs_disk_dquot { 501149d96aSChristoph Hellwig __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ 511149d96aSChristoph Hellwig __u8 d_version; /* dquot version */ 521149d96aSChristoph Hellwig __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */ 531149d96aSChristoph Hellwig __be32 d_id; /* user,project,group id */ 541149d96aSChristoph Hellwig __be64 d_blk_hardlimit;/* absolute limit on disk blks */ 551149d96aSChristoph Hellwig __be64 d_blk_softlimit;/* preferred limit on disk blks */ 561149d96aSChristoph Hellwig __be64 d_ino_hardlimit;/* maximum # allocated inodes */ 571149d96aSChristoph Hellwig __be64 d_ino_softlimit;/* preferred inode limit */ 581149d96aSChristoph Hellwig __be64 d_bcount; /* disk blocks owned by the user */ 591149d96aSChristoph Hellwig __be64 d_icount; /* inodes owned by the user */ 601149d96aSChristoph Hellwig __be32 d_itimer; /* zero if within inode limits if not, 611da177e4SLinus Torvalds this is when we refuse service */ 621149d96aSChristoph Hellwig __be32 d_btimer; /* similar to above; for disk blocks */ 631149d96aSChristoph Hellwig __be16 d_iwarns; /* warnings issued wrt num inodes */ 641149d96aSChristoph Hellwig __be16 d_bwarns; /* warnings issued wrt disk blocks */ 651149d96aSChristoph Hellwig __be32 d_pad0; /* 64 bit align */ 661149d96aSChristoph Hellwig __be64 d_rtb_hardlimit;/* absolute limit on realtime blks */ 671149d96aSChristoph Hellwig __be64 d_rtb_softlimit;/* preferred limit on RT disk blks */ 681149d96aSChristoph Hellwig __be64 d_rtbcount; /* realtime blocks owned */ 691149d96aSChristoph Hellwig __be32 d_rtbtimer; /* similar to above; for RT disk blocks */ 701149d96aSChristoph Hellwig __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */ 711149d96aSChristoph Hellwig __be16 d_pad; 721da177e4SLinus Torvalds } xfs_disk_dquot_t; 731da177e4SLinus Torvalds 741da177e4SLinus Torvalds /* 751da177e4SLinus Torvalds * This is what goes on disk. This is separated from the xfs_disk_dquot because 761da177e4SLinus Torvalds * carrying the unnecessary padding would be a waste of memory. 771da177e4SLinus Torvalds */ 781da177e4SLinus Torvalds typedef struct xfs_dqblk { 791da177e4SLinus Torvalds xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ 801da177e4SLinus Torvalds char dd_fill[32]; /* filling for posterity */ 811da177e4SLinus Torvalds } xfs_dqblk_t; 821da177e4SLinus Torvalds 831da177e4SLinus Torvalds /* 841da177e4SLinus Torvalds * flags for q_flags field in the dquot. 851da177e4SLinus Torvalds */ 861da177e4SLinus Torvalds #define XFS_DQ_USER 0x0001 /* a user quota */ 87c8ad20ffSNathan Scott #define XFS_DQ_PROJ 0x0002 /* project quota */ 881da177e4SLinus Torvalds #define XFS_DQ_GROUP 0x0004 /* a group quota */ 89df6771bdSChristoph Hellwig #define XFS_DQ_DIRTY 0x0008 /* dquot is dirty */ 90df6771bdSChristoph Hellwig #define XFS_DQ_WANT 0x0010 /* for lookup/reclaim race */ 91df6771bdSChristoph Hellwig #define XFS_DQ_INACTIVE 0x0020 /* dq off mplist & hashlist */ 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_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) 1584cd4a034STim Shimmin #define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) 1594cd4a034STim Shimmin #define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) 160e6d29426SKouta Ooizumi #define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) 161e6d29426SKouta Ooizumi #define XFS_IS_OQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD) 1624cd4a034STim Shimmin 1634cd4a034STim Shimmin /* 1641da177e4SLinus Torvalds * Incore only flags for quotaoff - these bits get cleared when quota(s) 1651da177e4SLinus Torvalds * are in the process of getting turned off. These flags are in m_qflags but 1661da177e4SLinus Torvalds * never in sb_qflags. 1671da177e4SLinus Torvalds */ 168c8ad20ffSNathan Scott #define XFS_UQUOTA_ACTIVE 0x0100 /* uquotas are being turned off */ 169c8ad20ffSNathan Scott #define XFS_PQUOTA_ACTIVE 0x0200 /* pquotas are being turned off */ 170c8ad20ffSNathan Scott #define XFS_GQUOTA_ACTIVE 0x0400 /* gquotas are being turned off */ 1711da177e4SLinus Torvalds 1721da177e4SLinus Torvalds /* 1731da177e4SLinus Torvalds * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees 1741da177e4SLinus Torvalds * quota will be not be switched off as long as that inode lock is held. 1751da177e4SLinus Torvalds */ 1761da177e4SLinus Torvalds #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ 177c8ad20ffSNathan Scott XFS_GQUOTA_ACTIVE | \ 178c8ad20ffSNathan Scott XFS_PQUOTA_ACTIVE)) 179c8ad20ffSNathan Scott #define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \ 180c8ad20ffSNathan Scott XFS_PQUOTA_ACTIVE)) 1811da177e4SLinus Torvalds #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) 1821da177e4SLinus Torvalds #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) 183c8ad20ffSNathan Scott #define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE) 1841da177e4SLinus Torvalds 1851da177e4SLinus Torvalds /* 1861da177e4SLinus Torvalds * Flags to tell various functions what to do. Not all of these are meaningful 1871da177e4SLinus Torvalds * to a single function. None of these XFS_QMOPT_* flags are meant to have 1881da177e4SLinus Torvalds * persistent values (ie. their values can and will change between versions) 1891da177e4SLinus Torvalds */ 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) */ 1999a2a7de2SNathan Scott #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */ 2001da177e4SLinus Torvalds #define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */ 2019a2a7de2SNathan Scott #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */ 202c8ad20ffSNathan Scott #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ 2039a2a7de2SNathan Scott #define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */ 2041da177e4SLinus Torvalds 2051da177e4SLinus Torvalds /* 2061da177e4SLinus Torvalds * flags to xfs_trans_mod_dquot to indicate which field needs to be 2071da177e4SLinus Torvalds * modified. 2081da177e4SLinus Torvalds */ 2091da177e4SLinus Torvalds #define XFS_QMOPT_RES_REGBLKS 0x0010000 2101da177e4SLinus Torvalds #define XFS_QMOPT_RES_RTBLKS 0x0020000 2111da177e4SLinus Torvalds #define XFS_QMOPT_BCOUNT 0x0040000 2121da177e4SLinus Torvalds #define XFS_QMOPT_ICOUNT 0x0080000 2131da177e4SLinus Torvalds #define XFS_QMOPT_RTBCOUNT 0x0100000 2141da177e4SLinus Torvalds #define XFS_QMOPT_DELBCOUNT 0x0200000 2151da177e4SLinus Torvalds #define XFS_QMOPT_DELRTBCOUNT 0x0400000 2161da177e4SLinus Torvalds #define XFS_QMOPT_RES_INOS 0x0800000 2171da177e4SLinus Torvalds 2181da177e4SLinus Torvalds /* 2191da177e4SLinus Torvalds * flags for dqflush and dqflush_all. 2201da177e4SLinus Torvalds */ 2211da177e4SLinus Torvalds #define XFS_QMOPT_SYNC 0x1000000 2221da177e4SLinus Torvalds #define XFS_QMOPT_ASYNC 0x2000000 2231da177e4SLinus Torvalds #define XFS_QMOPT_DELWRI 0x4000000 2241da177e4SLinus Torvalds 2251da177e4SLinus Torvalds /* 2261da177e4SLinus Torvalds * flags for dqalloc. 2271da177e4SLinus Torvalds */ 2281da177e4SLinus Torvalds #define XFS_QMOPT_INHERIT 0x8000000 2291da177e4SLinus Torvalds 2301da177e4SLinus Torvalds /* 2311da177e4SLinus Torvalds * flags to xfs_trans_mod_dquot. 2321da177e4SLinus Torvalds */ 2331da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS 2341da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS 2351da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS 2361da177e4SLinus Torvalds #define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT 2371da177e4SLinus Torvalds #define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT 2381da177e4SLinus Torvalds #define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT 2391da177e4SLinus Torvalds #define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT 2401da177e4SLinus Torvalds #define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT 2411da177e4SLinus Torvalds 2421da177e4SLinus Torvalds 243c8ad20ffSNathan Scott #define XFS_QMOPT_QUOTALL \ 244c8ad20ffSNathan Scott (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA) 2451da177e4SLinus Torvalds #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) 2461da177e4SLinus Torvalds 2471da177e4SLinus Torvalds #ifdef __KERNEL__ 2481da177e4SLinus Torvalds /* 2491da177e4SLinus Torvalds * This check is done typically without holding the inode lock; 250c41564b5SNathan Scott * that may seem racy, but it is harmless in the context that it is used. 2511da177e4SLinus Torvalds * The inode cannot go inactive as long a reference is kept, and 2521da177e4SLinus Torvalds * therefore if dquot(s) were attached, they'll stay consistent. 2531da177e4SLinus Torvalds * If, for example, the ownership of the inode changes while 2541da177e4SLinus Torvalds * we didn't have the inode locked, the appropriate dquot(s) will be 2551da177e4SLinus Torvalds * attached atomically. 2561da177e4SLinus Torvalds */ 2571da177e4SLinus Torvalds #define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ 2581da177e4SLinus Torvalds (ip)->i_udquot == NULL) || \ 259c8ad20ffSNathan Scott (XFS_IS_OQUOTA_ON(mp) && \ 2601da177e4SLinus Torvalds (ip)->i_gdquot == NULL)) 2611da177e4SLinus Torvalds 262c8ad20ffSNathan Scott #define XFS_QM_NEED_QUOTACHECK(mp) \ 263c8ad20ffSNathan Scott ((XFS_IS_UQUOTA_ON(mp) && \ 264c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \ 2651da177e4SLinus Torvalds (XFS_IS_GQUOTA_ON(mp) && \ 266c8ad20ffSNathan Scott ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 267c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \ 268c8ad20ffSNathan Scott (XFS_IS_PQUOTA_ON(mp) && \ 269c8ad20ffSNathan Scott ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 270c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) 271c8ad20ffSNathan Scott 272c8ad20ffSNathan Scott #define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 273c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ 274c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) 275c8ad20ffSNathan Scott 276c8ad20ffSNathan Scott #define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 277c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ 278c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) 2791da177e4SLinus Torvalds 2801da177e4SLinus Torvalds #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 281c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ 282c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ 283c8ad20ffSNathan Scott XFS_GQUOTA_ACCT) 2841da177e4SLinus Torvalds 2851da177e4SLinus Torvalds 2861da177e4SLinus Torvalds /* 2871da177e4SLinus Torvalds * The structure kept inside the xfs_trans_t keep track of dquot changes 2881da177e4SLinus Torvalds * within a transaction and apply them later. 2891da177e4SLinus Torvalds */ 2901da177e4SLinus Torvalds typedef struct xfs_dqtrx { 2911da177e4SLinus Torvalds struct xfs_dquot *qt_dquot; /* the dquot this refers to */ 2921da177e4SLinus Torvalds ulong qt_blk_res; /* blks reserved on a dquot */ 2931da177e4SLinus Torvalds ulong qt_blk_res_used; /* blks used from the reservation */ 2941da177e4SLinus Torvalds ulong qt_ino_res; /* inode reserved on a dquot */ 2951da177e4SLinus Torvalds ulong qt_ino_res_used; /* inodes used from the reservation */ 2961da177e4SLinus Torvalds long qt_bcount_delta; /* dquot blk count changes */ 2971da177e4SLinus Torvalds long qt_delbcnt_delta; /* delayed dquot blk count changes */ 2981da177e4SLinus Torvalds long qt_icount_delta; /* dquot inode count changes */ 2991da177e4SLinus Torvalds ulong qt_rtblk_res; /* # blks reserved on a dquot */ 3001da177e4SLinus Torvalds ulong qt_rtblk_res_used;/* # blks used from reservation */ 3011da177e4SLinus Torvalds long qt_rtbcount_delta;/* dquot realtime blk changes */ 3021da177e4SLinus Torvalds long qt_delrtb_delta; /* delayed RT blk count changes */ 3031da177e4SLinus Torvalds } xfs_dqtrx_t; 3041da177e4SLinus Torvalds 3051da177e4SLinus Torvalds /* 3061da177e4SLinus Torvalds * Dquot transaction functions, used if quota is enabled. 3071da177e4SLinus Torvalds */ 3081da177e4SLinus Torvalds typedef void (*qo_dup_dqinfo_t)(struct xfs_trans *, struct xfs_trans *); 3091da177e4SLinus Torvalds typedef void (*qo_mod_dquot_byino_t)(struct xfs_trans *, 3101da177e4SLinus Torvalds struct xfs_inode *, uint, long); 3111da177e4SLinus Torvalds typedef void (*qo_free_dqinfo_t)(struct xfs_trans *); 3121da177e4SLinus Torvalds typedef void (*qo_apply_dquot_deltas_t)(struct xfs_trans *); 3131da177e4SLinus Torvalds typedef void (*qo_unreserve_and_mod_dquots_t)(struct xfs_trans *); 3141da177e4SLinus Torvalds typedef int (*qo_reserve_quota_nblks_t)( 3151da177e4SLinus Torvalds struct xfs_trans *, struct xfs_mount *, 3161da177e4SLinus Torvalds struct xfs_inode *, long, long, uint); 3171da177e4SLinus Torvalds typedef int (*qo_reserve_quota_bydquots_t)( 3181da177e4SLinus Torvalds struct xfs_trans *, struct xfs_mount *, 3191da177e4SLinus Torvalds struct xfs_dquot *, struct xfs_dquot *, 3201da177e4SLinus Torvalds long, long, uint); 3211da177e4SLinus Torvalds typedef struct xfs_dqtrxops { 3221da177e4SLinus Torvalds qo_dup_dqinfo_t qo_dup_dqinfo; 3231da177e4SLinus Torvalds qo_free_dqinfo_t qo_free_dqinfo; 3241da177e4SLinus Torvalds qo_mod_dquot_byino_t qo_mod_dquot_byino; 3251da177e4SLinus Torvalds qo_apply_dquot_deltas_t qo_apply_dquot_deltas; 3261da177e4SLinus Torvalds qo_reserve_quota_nblks_t qo_reserve_quota_nblks; 3271da177e4SLinus Torvalds qo_reserve_quota_bydquots_t qo_reserve_quota_bydquots; 3281da177e4SLinus Torvalds qo_unreserve_and_mod_dquots_t qo_unreserve_and_mod_dquots; 3291da177e4SLinus Torvalds } xfs_dqtrxops_t; 3301da177e4SLinus Torvalds 3311da177e4SLinus Torvalds #define XFS_DQTRXOP(mp, tp, op, args...) \ 332b09cc771SChristoph Hellwig ((mp)->m_qm_ops->xfs_dqtrxops ? \ 333b09cc771SChristoph Hellwig ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : 0) 3341da177e4SLinus Torvalds 3351da177e4SLinus Torvalds #define XFS_DQTRXOP_VOID(mp, tp, op, args...) \ 336b09cc771SChristoph Hellwig ((mp)->m_qm_ops->xfs_dqtrxops ? \ 337b09cc771SChristoph Hellwig ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : (void)0) 3381da177e4SLinus Torvalds 3391da177e4SLinus Torvalds #define XFS_TRANS_DUP_DQINFO(mp, otp, ntp) \ 3401da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, otp, qo_dup_dqinfo, ntp) 3411da177e4SLinus Torvalds #define XFS_TRANS_FREE_DQINFO(mp, tp) \ 3421da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_free_dqinfo) 3431da177e4SLinus Torvalds #define XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, field, delta) \ 3441da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_mod_dquot_byino, ip, field, delta) 3451da177e4SLinus Torvalds #define XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp) \ 3461da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_apply_dquot_deltas) 3471da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, fl) \ 3481da177e4SLinus Torvalds XFS_DQTRXOP(mp, tp, qo_reserve_quota_nblks, mp, ip, nblks, ninos, fl) 3491da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, fl) \ 3501da177e4SLinus Torvalds XFS_DQTRXOP(mp, tp, qo_reserve_quota_bydquots, mp, ud, gd, nb, ni, fl) 3511da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \ 3521da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots) 3531da177e4SLinus Torvalds 35406d10dd9SNathan Scott #define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, flags) \ 35506d10dd9SNathan Scott XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), -(ninos), flags) 3561da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 3571da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ 3581da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 3591da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 3601da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \ 3611da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 3621da177e4SLinus Torvalds 3631da177e4SLinus Torvalds extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 3644cd4a034STim Shimmin extern int xfs_mount_reset_sbqflags(struct xfs_mount *); 3651da177e4SLinus Torvalds 366b09cc771SChristoph Hellwig extern struct xfs_qmops xfs_qmcore_xfs; 3671da177e4SLinus Torvalds 3681da177e4SLinus Torvalds #endif /* __KERNEL__ */ 3691da177e4SLinus Torvalds 3701da177e4SLinus Torvalds #endif /* __XFS_QUOTA_H__ */ 371