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 21fcafb71bSChristoph Hellwig struct xfs_trans; 22fcafb71bSChristoph 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 */ 2009a2a7de2SNathan Scott #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */ 201c8ad20ffSNathan Scott #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ 2029a2a7de2SNathan Scott #define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */ 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; 249c41564b5SNathan 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 2841da177e4SLinus Torvalds 2851da177e4SLinus Torvalds /* 2861da177e4SLinus Torvalds * The structure kept inside the xfs_trans_t keep track of dquot changes 2871da177e4SLinus Torvalds * within a transaction and apply them later. 2881da177e4SLinus Torvalds */ 2891da177e4SLinus Torvalds typedef struct xfs_dqtrx { 2901da177e4SLinus Torvalds struct xfs_dquot *qt_dquot; /* the dquot this refers to */ 2911da177e4SLinus Torvalds ulong qt_blk_res; /* blks reserved on a dquot */ 2921da177e4SLinus Torvalds ulong qt_blk_res_used; /* blks used from the reservation */ 2931da177e4SLinus Torvalds ulong qt_ino_res; /* inode reserved on a dquot */ 2941da177e4SLinus Torvalds ulong qt_ino_res_used; /* inodes used from the reservation */ 2951da177e4SLinus Torvalds long qt_bcount_delta; /* dquot blk count changes */ 2961da177e4SLinus Torvalds long qt_delbcnt_delta; /* delayed dquot blk count changes */ 2971da177e4SLinus Torvalds long qt_icount_delta; /* dquot inode count changes */ 2981da177e4SLinus Torvalds ulong qt_rtblk_res; /* # blks reserved on a dquot */ 2991da177e4SLinus Torvalds ulong qt_rtblk_res_used;/* # blks used from reservation */ 3001da177e4SLinus Torvalds long qt_rtbcount_delta;/* dquot realtime blk changes */ 3011da177e4SLinus Torvalds long qt_delrtb_delta; /* delayed RT blk count changes */ 3021da177e4SLinus Torvalds } xfs_dqtrx_t; 3031da177e4SLinus Torvalds 304*7d095257SChristoph Hellwig #ifdef CONFIG_XFS_QUOTA 305*7d095257SChristoph Hellwig extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *); 306*7d095257SChristoph Hellwig extern void xfs_trans_free_dqinfo(struct xfs_trans *); 307*7d095257SChristoph Hellwig extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *, 308*7d095257SChristoph Hellwig uint, long); 309*7d095257SChristoph Hellwig extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *); 310*7d095257SChristoph Hellwig extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *); 311*7d095257SChristoph Hellwig extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, 3121da177e4SLinus Torvalds struct xfs_inode *, long, long, uint); 313*7d095257SChristoph Hellwig extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, 314*7d095257SChristoph Hellwig struct xfs_mount *, struct xfs_dquot *, 315*7d095257SChristoph Hellwig struct xfs_dquot *, long, long, uint); 3161da177e4SLinus Torvalds 317*7d095257SChristoph Hellwig extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, 318*7d095257SChristoph Hellwig struct xfs_dquot **, struct xfs_dquot **); 319*7d095257SChristoph Hellwig extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, 320*7d095257SChristoph Hellwig struct xfs_dquot *, struct xfs_dquot *); 321*7d095257SChristoph Hellwig extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); 322*7d095257SChristoph Hellwig extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, 323*7d095257SChristoph Hellwig struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); 324*7d095257SChristoph Hellwig extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, 325*7d095257SChristoph Hellwig struct xfs_dquot *, struct xfs_dquot *, uint); 326*7d095257SChristoph Hellwig extern int xfs_qm_dqattach(struct xfs_inode *, uint); 327*7d095257SChristoph Hellwig extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); 328*7d095257SChristoph Hellwig extern void xfs_qm_dqdetach(struct xfs_inode *); 329*7d095257SChristoph Hellwig extern void xfs_qm_dqrele(struct xfs_dquot *); 330*7d095257SChristoph Hellwig extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *); 331*7d095257SChristoph Hellwig extern int xfs_qm_sync(struct xfs_mount *, int); 332*7d095257SChristoph Hellwig extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *); 333*7d095257SChristoph Hellwig extern void xfs_qm_mount_quotas(struct xfs_mount *); 334*7d095257SChristoph Hellwig extern void xfs_qm_unmount(struct xfs_mount *); 335*7d095257SChristoph Hellwig extern void xfs_qm_unmount_quotas(struct xfs_mount *); 3361da177e4SLinus Torvalds 337*7d095257SChristoph Hellwig #else 338*7d095257SChristoph Hellwig #define xfs_trans_dup_dqinfo(tp, tp2) 339*7d095257SChristoph Hellwig #define xfs_trans_free_dqinfo(tp) 340*7d095257SChristoph Hellwig #define xfs_trans_mod_dquot_byino(tp, ip, fields, delta) 341*7d095257SChristoph Hellwig #define xfs_trans_apply_dquot_deltas(tp) 342*7d095257SChristoph Hellwig #define xfs_trans_unreserve_and_mod_dquots(tp) 343*7d095257SChristoph Hellwig #define xfs_trans_reserve_quota_nblks(tp, ip, nblks, ninos, flags) (0) 344*7d095257SChristoph Hellwig #define xfs_trans_reserve_quota_bydquots(tp, mp, u, g, nb, ni, fl) (0) 345*7d095257SChristoph Hellwig #define xfs_qm_vop_dqalloc(ip, uid, gid, prid, fl, ou, og) (0) 346*7d095257SChristoph Hellwig #define xfs_qm_vop_create_dqattach(tp, ip, u, g) 347*7d095257SChristoph Hellwig #define xfs_qm_vop_rename_dqattach(it) (0) 348*7d095257SChristoph Hellwig #define xfs_qm_vop_chown(tp, ip, old, new) (NULL) 349*7d095257SChristoph Hellwig #define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0) 350*7d095257SChristoph Hellwig #define xfs_qm_dqattach(ip, fl) (0) 351*7d095257SChristoph Hellwig #define xfs_qm_dqattach_locked(ip, fl) (0) 352*7d095257SChristoph Hellwig #define xfs_qm_dqdetach(ip) 353*7d095257SChristoph Hellwig #define xfs_qm_dqrele(d) 354*7d095257SChristoph Hellwig #define xfs_qm_statvfs(ip, s) 355*7d095257SChristoph Hellwig #define xfs_qm_sync(mp, fl) (0) 356*7d095257SChristoph Hellwig #define xfs_qm_newmount(mp, a, b) (0) 357*7d095257SChristoph Hellwig #define xfs_qm_mount_quotas(mp) 358*7d095257SChristoph Hellwig #define xfs_qm_unmount(mp) 359*7d095257SChristoph Hellwig #define xfs_qm_unmount_quotas(mp) (0) 360*7d095257SChristoph Hellwig #endif /* CONFIG_XFS_QUOTA */ 3611da177e4SLinus Torvalds 362*7d095257SChristoph Hellwig #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ 363*7d095257SChristoph Hellwig xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) 364*7d095257SChristoph Hellwig #define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \ 365*7d095257SChristoph Hellwig xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ 3661da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 3671da177e4SLinus Torvalds 3681da177e4SLinus Torvalds extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 3694cd4a034STim Shimmin extern int xfs_mount_reset_sbqflags(struct xfs_mount *); 3701da177e4SLinus Torvalds 3711da177e4SLinus Torvalds #endif /* __KERNEL__ */ 3721da177e4SLinus Torvalds #endif /* __XFS_QUOTA_H__ */ 373