11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify it 51da177e4SLinus Torvalds * under the terms of version 2 of the GNU General Public License as 61da177e4SLinus Torvalds * published by the Free Software Foundation. 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * This program is distributed in the hope that it would be useful, but 91da177e4SLinus Torvalds * WITHOUT ANY WARRANTY; without even the implied warranty of 101da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * Further, this software is distributed without any warranty that it is 131da177e4SLinus Torvalds * free of the rightful claim of any third person regarding infringement 141da177e4SLinus Torvalds * or the like. Any license provided herein, whether implied or 151da177e4SLinus Torvalds * otherwise, applies only to this software file. Patent licenses, if 161da177e4SLinus Torvalds * any, provided herein do not apply to combinations of this program with 171da177e4SLinus Torvalds * other software, or any other product whatsoever. 181da177e4SLinus Torvalds * 191da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License along 201da177e4SLinus Torvalds * with this program; if not, write the Free Software Foundation, Inc., 59 211da177e4SLinus Torvalds * Temple Place - Suite 330, Boston MA 02111-1307, USA. 221da177e4SLinus Torvalds * 231da177e4SLinus Torvalds * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 241da177e4SLinus Torvalds * Mountain View, CA 94043, or: 251da177e4SLinus Torvalds * 261da177e4SLinus Torvalds * http://www.sgi.com 271da177e4SLinus Torvalds * 281da177e4SLinus Torvalds * For further information regarding this notice, see: 291da177e4SLinus Torvalds * 301da177e4SLinus Torvalds * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ 311da177e4SLinus Torvalds */ 321da177e4SLinus Torvalds #ifndef __XFS_QUOTA_H__ 331da177e4SLinus Torvalds #define __XFS_QUOTA_H__ 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds /* 361da177e4SLinus Torvalds * The ondisk form of a dquot structure. 371da177e4SLinus Torvalds */ 381da177e4SLinus Torvalds #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ 391da177e4SLinus Torvalds #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */ 401da177e4SLinus Torvalds 411da177e4SLinus Torvalds /* 421da177e4SLinus Torvalds * uid_t and gid_t are hard-coded to 32 bits in the inode. 431da177e4SLinus Torvalds * Hence, an 'id' in a dquot is 32 bits.. 441da177e4SLinus Torvalds */ 451da177e4SLinus Torvalds typedef __int32_t xfs_dqid_t; 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds /* 481da177e4SLinus Torvalds * Eventhough users may not have quota limits occupying all 64-bits, 491da177e4SLinus Torvalds * they may need 64-bit accounting. Hence, 64-bit quota-counters, 501da177e4SLinus Torvalds * and quota-limits. This is a waste in the common case, but hey ... 511da177e4SLinus Torvalds */ 521da177e4SLinus Torvalds typedef __uint64_t xfs_qcnt_t; 531da177e4SLinus Torvalds typedef __uint16_t xfs_qwarncnt_t; 541da177e4SLinus Torvalds 551da177e4SLinus Torvalds /* 561da177e4SLinus Torvalds * This is the main portion of the on-disk representation of quota 571da177e4SLinus Torvalds * information for a user. This is the q_core of the xfs_dquot_t that 581da177e4SLinus Torvalds * is kept in kernel memory. We pad this with some more expansion room 591da177e4SLinus Torvalds * to construct the on disk structure. 601da177e4SLinus Torvalds */ 611da177e4SLinus Torvalds typedef struct xfs_disk_dquot { 621da177e4SLinus Torvalds /*16*/ u_int16_t d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ 631da177e4SLinus Torvalds /*8 */ u_int8_t d_version; /* dquot version */ 641da177e4SLinus Torvalds /*8 */ u_int8_t d_flags; /* XFS_DQ_USER/PROJ/GROUP */ 651da177e4SLinus Torvalds /*32*/ xfs_dqid_t d_id; /* user,project,group id */ 661da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_blk_hardlimit;/* absolute limit on disk blks */ 671da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_blk_softlimit;/* preferred limit on disk blks */ 681da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_ino_hardlimit;/* maximum # allocated inodes */ 691da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_ino_softlimit;/* preferred inode limit */ 701da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_bcount; /* disk blocks owned by the user */ 711da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_icount; /* inodes owned by the user */ 721da177e4SLinus Torvalds /*32*/ __int32_t d_itimer; /* zero if within inode limits if not, 731da177e4SLinus Torvalds this is when we refuse service */ 741da177e4SLinus Torvalds /*32*/ __int32_t d_btimer; /* similar to above; for disk blocks */ 751da177e4SLinus Torvalds /*16*/ xfs_qwarncnt_t d_iwarns; /* warnings issued wrt num inodes */ 761da177e4SLinus Torvalds /*16*/ xfs_qwarncnt_t d_bwarns; /* warnings issued wrt disk blocks */ 771da177e4SLinus Torvalds /*32*/ __int32_t d_pad0; /* 64 bit align */ 781da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_rtb_hardlimit;/* absolute limit on realtime blks */ 791da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_rtb_softlimit;/* preferred limit on RT disk blks */ 801da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_rtbcount; /* realtime blocks owned */ 811da177e4SLinus Torvalds /*32*/ __int32_t d_rtbtimer; /* similar to above; for RT disk blocks */ 821da177e4SLinus Torvalds /*16*/ xfs_qwarncnt_t d_rtbwarns; /* warnings issued wrt RT disk blocks */ 831da177e4SLinus Torvalds /*16*/ __uint16_t d_pad; 841da177e4SLinus Torvalds } xfs_disk_dquot_t; 851da177e4SLinus Torvalds 861da177e4SLinus Torvalds /* 871da177e4SLinus Torvalds * This is what goes on disk. This is separated from the xfs_disk_dquot because 881da177e4SLinus Torvalds * carrying the unnecessary padding would be a waste of memory. 891da177e4SLinus Torvalds */ 901da177e4SLinus Torvalds typedef struct xfs_dqblk { 911da177e4SLinus Torvalds xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ 921da177e4SLinus Torvalds char dd_fill[32]; /* filling for posterity */ 931da177e4SLinus Torvalds } xfs_dqblk_t; 941da177e4SLinus Torvalds 951da177e4SLinus Torvalds /* 961da177e4SLinus Torvalds * flags for q_flags field in the dquot. 971da177e4SLinus Torvalds */ 981da177e4SLinus Torvalds #define XFS_DQ_USER 0x0001 /* a user quota */ 99*c8ad20ffSNathan Scott #define XFS_DQ_PROJ 0x0002 /* project quota */ 1001da177e4SLinus Torvalds #define XFS_DQ_GROUP 0x0004 /* a group quota */ 1011da177e4SLinus Torvalds #define XFS_DQ_FLOCKED 0x0008 /* flush lock taken */ 1021da177e4SLinus Torvalds #define XFS_DQ_DIRTY 0x0010 /* dquot is dirty */ 1031da177e4SLinus Torvalds #define XFS_DQ_WANT 0x0020 /* for lookup/reclaim race */ 1041da177e4SLinus Torvalds #define XFS_DQ_INACTIVE 0x0040 /* dq off mplist & hashlist */ 1051da177e4SLinus Torvalds #define XFS_DQ_MARKER 0x0080 /* sentinel */ 1061da177e4SLinus Torvalds 107*c8ad20ffSNathan Scott #define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP) 108*c8ad20ffSNathan Scott 1091da177e4SLinus Torvalds /* 1101da177e4SLinus Torvalds * In the worst case, when both user and group quotas are on, 1111da177e4SLinus Torvalds * we can have a max of three dquots changing in a single transaction. 1121da177e4SLinus Torvalds */ 1131da177e4SLinus Torvalds #define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) 1141da177e4SLinus Torvalds 1151da177e4SLinus Torvalds 1161da177e4SLinus Torvalds /* 1171da177e4SLinus Torvalds * These are the structures used to lay out dquots and quotaoff 1181da177e4SLinus Torvalds * records on the log. Quite similar to those of inodes. 1191da177e4SLinus Torvalds */ 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds /* 1221da177e4SLinus Torvalds * log format struct for dquots. 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 */ 1261da177e4SLinus Torvalds typedef struct xfs_dq_logformat { 1271da177e4SLinus Torvalds __uint16_t qlf_type; /* dquot log item type */ 1281da177e4SLinus Torvalds __uint16_t qlf_size; /* size of this item */ 129*c8ad20ffSNathan Scott xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */ 1301da177e4SLinus Torvalds __int64_t qlf_blkno; /* blkno of dquot buffer */ 1311da177e4SLinus Torvalds __int32_t qlf_len; /* len of dquot buffer */ 1321da177e4SLinus Torvalds __uint32_t qlf_boffset; /* off of dquot in buffer */ 1331da177e4SLinus Torvalds } xfs_dq_logformat_t; 1341da177e4SLinus Torvalds 1351da177e4SLinus Torvalds /* 1361da177e4SLinus Torvalds * log format struct for QUOTAOFF records. 1371da177e4SLinus Torvalds * The first two fields must be the type and size fitting into 1381da177e4SLinus Torvalds * 32 bits : log_recovery code assumes that. 1391da177e4SLinus Torvalds * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer 1401da177e4SLinus Torvalds * to the first and ensures that the first logitem is taken out of the AIL 1411da177e4SLinus Torvalds * only when the last one is securely committed. 1421da177e4SLinus Torvalds */ 1431da177e4SLinus Torvalds typedef struct xfs_qoff_logformat { 1441da177e4SLinus Torvalds unsigned short qf_type; /* quotaoff log item type */ 1451da177e4SLinus Torvalds unsigned short qf_size; /* size of this item */ 1461da177e4SLinus Torvalds unsigned int qf_flags; /* USR and/or GRP */ 1471da177e4SLinus Torvalds char qf_pad[12]; /* padding for future */ 1481da177e4SLinus Torvalds } xfs_qoff_logformat_t; 1491da177e4SLinus Torvalds 1501da177e4SLinus Torvalds 1511da177e4SLinus Torvalds /* 1521da177e4SLinus Torvalds * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. 1531da177e4SLinus Torvalds */ 1541da177e4SLinus Torvalds #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */ 1551da177e4SLinus Torvalds #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */ 1561da177e4SLinus Torvalds #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */ 157*c8ad20ffSNathan Scott #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */ 158*c8ad20ffSNathan Scott #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */ 159*c8ad20ffSNathan Scott #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */ 1601da177e4SLinus Torvalds #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ 1611da177e4SLinus Torvalds 1621da177e4SLinus Torvalds /* 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 */ 167*c8ad20ffSNathan Scott #define XFS_UQUOTA_ACTIVE 0x0100 /* uquotas are being turned off */ 168*c8ad20ffSNathan Scott #define XFS_PQUOTA_ACTIVE 0x0200 /* pquotas are being turned off */ 169*c8ad20ffSNathan 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 | \ 176*c8ad20ffSNathan Scott XFS_GQUOTA_ACTIVE | \ 177*c8ad20ffSNathan Scott XFS_PQUOTA_ACTIVE)) 178*c8ad20ffSNathan Scott #define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \ 179*c8ad20ffSNathan 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) 182*c8ad20ffSNathan 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 */ 192*c8ad20ffSNathan 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. */ 202*c8ad20ffSNathan 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 242*c8ad20ffSNathan Scott #define XFS_QMOPT_QUOTALL \ 243*c8ad20ffSNathan 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; 2491da177e4SLinus Torvalds * that may seem racey, 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) || \ 258*c8ad20ffSNathan Scott (XFS_IS_OQUOTA_ON(mp) && \ 2591da177e4SLinus Torvalds (ip)->i_gdquot == NULL)) 2601da177e4SLinus Torvalds 261*c8ad20ffSNathan Scott #define XFS_QM_NEED_QUOTACHECK(mp) \ 262*c8ad20ffSNathan Scott ((XFS_IS_UQUOTA_ON(mp) && \ 263*c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \ 2641da177e4SLinus Torvalds (XFS_IS_GQUOTA_ON(mp) && \ 265*c8ad20ffSNathan Scott ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 266*c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \ 267*c8ad20ffSNathan Scott (XFS_IS_PQUOTA_ON(mp) && \ 268*c8ad20ffSNathan Scott ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 269*c8ad20ffSNathan Scott (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) 270*c8ad20ffSNathan Scott 271*c8ad20ffSNathan Scott #define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 272*c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ 273*c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) 274*c8ad20ffSNathan Scott 275*c8ad20ffSNathan Scott #define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 276*c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ 277*c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) 2781da177e4SLinus Torvalds 2791da177e4SLinus Torvalds #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 280*c8ad20ffSNathan Scott XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ 281*c8ad20ffSNathan Scott XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ 282*c8ad20ffSNathan Scott XFS_GQUOTA_ACCT) 2831da177e4SLinus Torvalds #define XFS_MOUNT_QUOTA_MASK (XFS_MOUNT_QUOTA_ALL | XFS_UQUOTA_ACTIVE | \ 284*c8ad20ffSNathan 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 3551da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_BLKQUOTA(mp, tp, ip, nblks) \ 3561da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \ 3571da177e4SLinus Torvalds XFS_QMOPT_RES_REGBLKS) 3581da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_BLKQUOTA_FORCE(mp, tp, ip, nblks) \ 3591da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \ 3601da177e4SLinus Torvalds XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES) 3611da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_BLKQUOTA(mp, tp, ip, nblks) \ 3621da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), 0, \ 3631da177e4SLinus Torvalds XFS_QMOPT_RES_REGBLKS) 3641da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 3651da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ 3661da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 3671da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 3681da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \ 3691da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 3701da177e4SLinus Torvalds 3711da177e4SLinus Torvalds extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 3721da177e4SLinus Torvalds 3731da177e4SLinus Torvalds extern struct bhv_vfsops xfs_qmops; 3741da177e4SLinus Torvalds 3751da177e4SLinus Torvalds #endif /* __KERNEL__ */ 3761da177e4SLinus Torvalds 3771da177e4SLinus Torvalds #endif /* __XFS_QUOTA_H__ */ 378