1*1da177e4SLinus Torvalds /* 2*1da177e4SLinus Torvalds * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 3*1da177e4SLinus Torvalds * 4*1da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify it 5*1da177e4SLinus Torvalds * under the terms of version 2 of the GNU General Public License as 6*1da177e4SLinus Torvalds * published by the Free Software Foundation. 7*1da177e4SLinus Torvalds * 8*1da177e4SLinus Torvalds * This program is distributed in the hope that it would be useful, but 9*1da177e4SLinus Torvalds * WITHOUT ANY WARRANTY; without even the implied warranty of 10*1da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 11*1da177e4SLinus Torvalds * 12*1da177e4SLinus Torvalds * Further, this software is distributed without any warranty that it is 13*1da177e4SLinus Torvalds * free of the rightful claim of any third person regarding infringement 14*1da177e4SLinus Torvalds * or the like. Any license provided herein, whether implied or 15*1da177e4SLinus Torvalds * otherwise, applies only to this software file. Patent licenses, if 16*1da177e4SLinus Torvalds * any, provided herein do not apply to combinations of this program with 17*1da177e4SLinus Torvalds * other software, or any other product whatsoever. 18*1da177e4SLinus Torvalds * 19*1da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License along 20*1da177e4SLinus Torvalds * with this program; if not, write the Free Software Foundation, Inc., 59 21*1da177e4SLinus Torvalds * Temple Place - Suite 330, Boston MA 02111-1307, USA. 22*1da177e4SLinus Torvalds * 23*1da177e4SLinus Torvalds * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 24*1da177e4SLinus Torvalds * Mountain View, CA 94043, or: 25*1da177e4SLinus Torvalds * 26*1da177e4SLinus Torvalds * http://www.sgi.com 27*1da177e4SLinus Torvalds * 28*1da177e4SLinus Torvalds * For further information regarding this notice, see: 29*1da177e4SLinus Torvalds * 30*1da177e4SLinus Torvalds * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ 31*1da177e4SLinus Torvalds */ 32*1da177e4SLinus Torvalds #ifndef __XFS_QUOTA_H__ 33*1da177e4SLinus Torvalds #define __XFS_QUOTA_H__ 34*1da177e4SLinus Torvalds 35*1da177e4SLinus Torvalds /* 36*1da177e4SLinus Torvalds * The ondisk form of a dquot structure. 37*1da177e4SLinus Torvalds */ 38*1da177e4SLinus Torvalds #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ 39*1da177e4SLinus Torvalds #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */ 40*1da177e4SLinus Torvalds 41*1da177e4SLinus Torvalds /* 42*1da177e4SLinus Torvalds * uid_t and gid_t are hard-coded to 32 bits in the inode. 43*1da177e4SLinus Torvalds * Hence, an 'id' in a dquot is 32 bits.. 44*1da177e4SLinus Torvalds */ 45*1da177e4SLinus Torvalds typedef __int32_t xfs_dqid_t; 46*1da177e4SLinus Torvalds 47*1da177e4SLinus Torvalds /* 48*1da177e4SLinus Torvalds * Eventhough users may not have quota limits occupying all 64-bits, 49*1da177e4SLinus Torvalds * they may need 64-bit accounting. Hence, 64-bit quota-counters, 50*1da177e4SLinus Torvalds * and quota-limits. This is a waste in the common case, but hey ... 51*1da177e4SLinus Torvalds */ 52*1da177e4SLinus Torvalds typedef __uint64_t xfs_qcnt_t; 53*1da177e4SLinus Torvalds typedef __uint16_t xfs_qwarncnt_t; 54*1da177e4SLinus Torvalds 55*1da177e4SLinus Torvalds /* 56*1da177e4SLinus Torvalds * This is the main portion of the on-disk representation of quota 57*1da177e4SLinus Torvalds * information for a user. This is the q_core of the xfs_dquot_t that 58*1da177e4SLinus Torvalds * is kept in kernel memory. We pad this with some more expansion room 59*1da177e4SLinus Torvalds * to construct the on disk structure. 60*1da177e4SLinus Torvalds */ 61*1da177e4SLinus Torvalds typedef struct xfs_disk_dquot { 62*1da177e4SLinus Torvalds /*16*/ u_int16_t d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ 63*1da177e4SLinus Torvalds /*8 */ u_int8_t d_version; /* dquot version */ 64*1da177e4SLinus Torvalds /*8 */ u_int8_t d_flags; /* XFS_DQ_USER/PROJ/GROUP */ 65*1da177e4SLinus Torvalds /*32*/ xfs_dqid_t d_id; /* user,project,group id */ 66*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_blk_hardlimit;/* absolute limit on disk blks */ 67*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_blk_softlimit;/* preferred limit on disk blks */ 68*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_ino_hardlimit;/* maximum # allocated inodes */ 69*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_ino_softlimit;/* preferred inode limit */ 70*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_bcount; /* disk blocks owned by the user */ 71*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_icount; /* inodes owned by the user */ 72*1da177e4SLinus Torvalds /*32*/ __int32_t d_itimer; /* zero if within inode limits if not, 73*1da177e4SLinus Torvalds this is when we refuse service */ 74*1da177e4SLinus Torvalds /*32*/ __int32_t d_btimer; /* similar to above; for disk blocks */ 75*1da177e4SLinus Torvalds /*16*/ xfs_qwarncnt_t d_iwarns; /* warnings issued wrt num inodes */ 76*1da177e4SLinus Torvalds /*16*/ xfs_qwarncnt_t d_bwarns; /* warnings issued wrt disk blocks */ 77*1da177e4SLinus Torvalds /*32*/ __int32_t d_pad0; /* 64 bit align */ 78*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_rtb_hardlimit;/* absolute limit on realtime blks */ 79*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_rtb_softlimit;/* preferred limit on RT disk blks */ 80*1da177e4SLinus Torvalds /*64*/ xfs_qcnt_t d_rtbcount; /* realtime blocks owned */ 81*1da177e4SLinus Torvalds /*32*/ __int32_t d_rtbtimer; /* similar to above; for RT disk blocks */ 82*1da177e4SLinus Torvalds /*16*/ xfs_qwarncnt_t d_rtbwarns; /* warnings issued wrt RT disk blocks */ 83*1da177e4SLinus Torvalds /*16*/ __uint16_t d_pad; 84*1da177e4SLinus Torvalds } xfs_disk_dquot_t; 85*1da177e4SLinus Torvalds 86*1da177e4SLinus Torvalds /* 87*1da177e4SLinus Torvalds * This is what goes on disk. This is separated from the xfs_disk_dquot because 88*1da177e4SLinus Torvalds * carrying the unnecessary padding would be a waste of memory. 89*1da177e4SLinus Torvalds */ 90*1da177e4SLinus Torvalds typedef struct xfs_dqblk { 91*1da177e4SLinus Torvalds xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ 92*1da177e4SLinus Torvalds char dd_fill[32]; /* filling for posterity */ 93*1da177e4SLinus Torvalds } xfs_dqblk_t; 94*1da177e4SLinus Torvalds 95*1da177e4SLinus Torvalds /* 96*1da177e4SLinus Torvalds * flags for q_flags field in the dquot. 97*1da177e4SLinus Torvalds */ 98*1da177e4SLinus Torvalds #define XFS_DQ_USER 0x0001 /* a user quota */ 99*1da177e4SLinus Torvalds /* #define XFS_DQ_PROJ 0x0002 -- project quota (IRIX) */ 100*1da177e4SLinus Torvalds #define XFS_DQ_GROUP 0x0004 /* a group quota */ 101*1da177e4SLinus Torvalds #define XFS_DQ_FLOCKED 0x0008 /* flush lock taken */ 102*1da177e4SLinus Torvalds #define XFS_DQ_DIRTY 0x0010 /* dquot is dirty */ 103*1da177e4SLinus Torvalds #define XFS_DQ_WANT 0x0020 /* for lookup/reclaim race */ 104*1da177e4SLinus Torvalds #define XFS_DQ_INACTIVE 0x0040 /* dq off mplist & hashlist */ 105*1da177e4SLinus Torvalds #define XFS_DQ_MARKER 0x0080 /* sentinel */ 106*1da177e4SLinus Torvalds 107*1da177e4SLinus Torvalds /* 108*1da177e4SLinus Torvalds * In the worst case, when both user and group quotas are on, 109*1da177e4SLinus Torvalds * we can have a max of three dquots changing in a single transaction. 110*1da177e4SLinus Torvalds */ 111*1da177e4SLinus Torvalds #define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) 112*1da177e4SLinus Torvalds 113*1da177e4SLinus Torvalds 114*1da177e4SLinus Torvalds /* 115*1da177e4SLinus Torvalds * These are the structures used to lay out dquots and quotaoff 116*1da177e4SLinus Torvalds * records on the log. Quite similar to those of inodes. 117*1da177e4SLinus Torvalds */ 118*1da177e4SLinus Torvalds 119*1da177e4SLinus Torvalds /* 120*1da177e4SLinus Torvalds * log format struct for dquots. 121*1da177e4SLinus Torvalds * The first two fields must be the type and size fitting into 122*1da177e4SLinus Torvalds * 32 bits : log_recovery code assumes that. 123*1da177e4SLinus Torvalds */ 124*1da177e4SLinus Torvalds typedef struct xfs_dq_logformat { 125*1da177e4SLinus Torvalds __uint16_t qlf_type; /* dquot log item type */ 126*1da177e4SLinus Torvalds __uint16_t qlf_size; /* size of this item */ 127*1da177e4SLinus Torvalds xfs_dqid_t qlf_id; /* usr/grp id number : 32 bits */ 128*1da177e4SLinus Torvalds __int64_t qlf_blkno; /* blkno of dquot buffer */ 129*1da177e4SLinus Torvalds __int32_t qlf_len; /* len of dquot buffer */ 130*1da177e4SLinus Torvalds __uint32_t qlf_boffset; /* off of dquot in buffer */ 131*1da177e4SLinus Torvalds } xfs_dq_logformat_t; 132*1da177e4SLinus Torvalds 133*1da177e4SLinus Torvalds /* 134*1da177e4SLinus Torvalds * log format struct for QUOTAOFF records. 135*1da177e4SLinus Torvalds * The first two fields must be the type and size fitting into 136*1da177e4SLinus Torvalds * 32 bits : log_recovery code assumes that. 137*1da177e4SLinus Torvalds * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer 138*1da177e4SLinus Torvalds * to the first and ensures that the first logitem is taken out of the AIL 139*1da177e4SLinus Torvalds * only when the last one is securely committed. 140*1da177e4SLinus Torvalds */ 141*1da177e4SLinus Torvalds typedef struct xfs_qoff_logformat { 142*1da177e4SLinus Torvalds unsigned short qf_type; /* quotaoff log item type */ 143*1da177e4SLinus Torvalds unsigned short qf_size; /* size of this item */ 144*1da177e4SLinus Torvalds unsigned int qf_flags; /* USR and/or GRP */ 145*1da177e4SLinus Torvalds char qf_pad[12]; /* padding for future */ 146*1da177e4SLinus Torvalds } xfs_qoff_logformat_t; 147*1da177e4SLinus Torvalds 148*1da177e4SLinus Torvalds 149*1da177e4SLinus Torvalds /* 150*1da177e4SLinus Torvalds * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. 151*1da177e4SLinus Torvalds */ 152*1da177e4SLinus Torvalds #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */ 153*1da177e4SLinus Torvalds #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */ 154*1da177e4SLinus Torvalds #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */ 155*1da177e4SLinus Torvalds #define XFS_PQUOTA_ACCT 0x0008 /* (IRIX) project quota accounting ON */ 156*1da177e4SLinus Torvalds #define XFS_GQUOTA_ENFD 0x0010 /* group quota limits enforced */ 157*1da177e4SLinus Torvalds #define XFS_GQUOTA_CHKD 0x0020 /* quotacheck run on grp quotas */ 158*1da177e4SLinus Torvalds #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ 159*1da177e4SLinus Torvalds 160*1da177e4SLinus Torvalds /* 161*1da177e4SLinus Torvalds * Incore only flags for quotaoff - these bits get cleared when quota(s) 162*1da177e4SLinus Torvalds * are in the process of getting turned off. These flags are in m_qflags but 163*1da177e4SLinus Torvalds * never in sb_qflags. 164*1da177e4SLinus Torvalds */ 165*1da177e4SLinus Torvalds #define XFS_UQUOTA_ACTIVE 0x0080 /* uquotas are being turned off */ 166*1da177e4SLinus Torvalds #define XFS_GQUOTA_ACTIVE 0x0100 /* gquotas are being turned off */ 167*1da177e4SLinus Torvalds 168*1da177e4SLinus Torvalds /* 169*1da177e4SLinus Torvalds * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees 170*1da177e4SLinus Torvalds * quota will be not be switched off as long as that inode lock is held. 171*1da177e4SLinus Torvalds */ 172*1da177e4SLinus Torvalds #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ 173*1da177e4SLinus Torvalds XFS_GQUOTA_ACTIVE)) 174*1da177e4SLinus Torvalds #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) 175*1da177e4SLinus Torvalds #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) 176*1da177e4SLinus Torvalds 177*1da177e4SLinus Torvalds /* 178*1da177e4SLinus Torvalds * Flags to tell various functions what to do. Not all of these are meaningful 179*1da177e4SLinus Torvalds * to a single function. None of these XFS_QMOPT_* flags are meant to have 180*1da177e4SLinus Torvalds * persistent values (ie. their values can and will change between versions) 181*1da177e4SLinus Torvalds */ 182*1da177e4SLinus Torvalds #define XFS_QMOPT_DQLOCK 0x0000001 /* dqlock */ 183*1da177e4SLinus Torvalds #define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */ 184*1da177e4SLinus Torvalds #define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */ 185*1da177e4SLinus Torvalds #define XFS_QMOPT_GQUOTA 0x0000008 /* group dquot requested */ 186*1da177e4SLinus Torvalds #define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */ 187*1da177e4SLinus Torvalds #define XFS_QMOPT_DQSUSER 0x0000020 /* don't cache super users dquot */ 188*1da177e4SLinus Torvalds #define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */ 189*1da177e4SLinus Torvalds #define XFS_QMOPT_QUOTAOFF 0x0000080 /* quotas are being turned off */ 190*1da177e4SLinus Torvalds #define XFS_QMOPT_UMOUNTING 0x0000100 /* filesys is being unmounted */ 191*1da177e4SLinus Torvalds #define XFS_QMOPT_DOLOG 0x0000200 /* log buf changes (in quotacheck) */ 192*1da177e4SLinus Torvalds #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if necessary */ 193*1da177e4SLinus Torvalds #define XFS_QMOPT_ILOCKED 0x0000800 /* inode is already locked (excl) */ 194*1da177e4SLinus Torvalds #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot, if damaged. */ 195*1da177e4SLinus Torvalds 196*1da177e4SLinus Torvalds /* 197*1da177e4SLinus Torvalds * flags to xfs_trans_mod_dquot to indicate which field needs to be 198*1da177e4SLinus Torvalds * modified. 199*1da177e4SLinus Torvalds */ 200*1da177e4SLinus Torvalds #define XFS_QMOPT_RES_REGBLKS 0x0010000 201*1da177e4SLinus Torvalds #define XFS_QMOPT_RES_RTBLKS 0x0020000 202*1da177e4SLinus Torvalds #define XFS_QMOPT_BCOUNT 0x0040000 203*1da177e4SLinus Torvalds #define XFS_QMOPT_ICOUNT 0x0080000 204*1da177e4SLinus Torvalds #define XFS_QMOPT_RTBCOUNT 0x0100000 205*1da177e4SLinus Torvalds #define XFS_QMOPT_DELBCOUNT 0x0200000 206*1da177e4SLinus Torvalds #define XFS_QMOPT_DELRTBCOUNT 0x0400000 207*1da177e4SLinus Torvalds #define XFS_QMOPT_RES_INOS 0x0800000 208*1da177e4SLinus Torvalds 209*1da177e4SLinus Torvalds /* 210*1da177e4SLinus Torvalds * flags for dqflush and dqflush_all. 211*1da177e4SLinus Torvalds */ 212*1da177e4SLinus Torvalds #define XFS_QMOPT_SYNC 0x1000000 213*1da177e4SLinus Torvalds #define XFS_QMOPT_ASYNC 0x2000000 214*1da177e4SLinus Torvalds #define XFS_QMOPT_DELWRI 0x4000000 215*1da177e4SLinus Torvalds 216*1da177e4SLinus Torvalds /* 217*1da177e4SLinus Torvalds * flags for dqalloc. 218*1da177e4SLinus Torvalds */ 219*1da177e4SLinus Torvalds #define XFS_QMOPT_INHERIT 0x8000000 220*1da177e4SLinus Torvalds 221*1da177e4SLinus Torvalds /* 222*1da177e4SLinus Torvalds * flags to xfs_trans_mod_dquot. 223*1da177e4SLinus Torvalds */ 224*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS 225*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS 226*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS 227*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT 228*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT 229*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT 230*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT 231*1da177e4SLinus Torvalds #define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT 232*1da177e4SLinus Torvalds 233*1da177e4SLinus Torvalds 234*1da177e4SLinus Torvalds #define XFS_QMOPT_QUOTALL (XFS_QMOPT_UQUOTA|XFS_QMOPT_GQUOTA) 235*1da177e4SLinus Torvalds #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) 236*1da177e4SLinus Torvalds 237*1da177e4SLinus Torvalds #ifdef __KERNEL__ 238*1da177e4SLinus Torvalds /* 239*1da177e4SLinus Torvalds * This check is done typically without holding the inode lock; 240*1da177e4SLinus Torvalds * that may seem racey, but it is harmless in the context that it is used. 241*1da177e4SLinus Torvalds * The inode cannot go inactive as long a reference is kept, and 242*1da177e4SLinus Torvalds * therefore if dquot(s) were attached, they'll stay consistent. 243*1da177e4SLinus Torvalds * If, for example, the ownership of the inode changes while 244*1da177e4SLinus Torvalds * we didn't have the inode locked, the appropriate dquot(s) will be 245*1da177e4SLinus Torvalds * attached atomically. 246*1da177e4SLinus Torvalds */ 247*1da177e4SLinus Torvalds #define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ 248*1da177e4SLinus Torvalds (ip)->i_udquot == NULL) || \ 249*1da177e4SLinus Torvalds (XFS_IS_GQUOTA_ON(mp) && \ 250*1da177e4SLinus Torvalds (ip)->i_gdquot == NULL)) 251*1da177e4SLinus Torvalds 252*1da177e4SLinus Torvalds #define XFS_QM_NEED_QUOTACHECK(mp) ((XFS_IS_UQUOTA_ON(mp) && \ 253*1da177e4SLinus Torvalds (mp->m_sb.sb_qflags & \ 254*1da177e4SLinus Torvalds XFS_UQUOTA_CHKD) == 0) || \ 255*1da177e4SLinus Torvalds (XFS_IS_GQUOTA_ON(mp) && \ 256*1da177e4SLinus Torvalds (mp->m_sb.sb_qflags & \ 257*1da177e4SLinus Torvalds XFS_GQUOTA_CHKD) == 0)) 258*1da177e4SLinus Torvalds 259*1da177e4SLinus Torvalds #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 260*1da177e4SLinus Torvalds XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ 261*1da177e4SLinus Torvalds XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD) 262*1da177e4SLinus Torvalds #define XFS_MOUNT_QUOTA_MASK (XFS_MOUNT_QUOTA_ALL | XFS_UQUOTA_ACTIVE | \ 263*1da177e4SLinus Torvalds XFS_GQUOTA_ACTIVE) 264*1da177e4SLinus Torvalds 265*1da177e4SLinus Torvalds 266*1da177e4SLinus Torvalds /* 267*1da177e4SLinus Torvalds * The structure kept inside the xfs_trans_t keep track of dquot changes 268*1da177e4SLinus Torvalds * within a transaction and apply them later. 269*1da177e4SLinus Torvalds */ 270*1da177e4SLinus Torvalds typedef struct xfs_dqtrx { 271*1da177e4SLinus Torvalds struct xfs_dquot *qt_dquot; /* the dquot this refers to */ 272*1da177e4SLinus Torvalds ulong qt_blk_res; /* blks reserved on a dquot */ 273*1da177e4SLinus Torvalds ulong qt_blk_res_used; /* blks used from the reservation */ 274*1da177e4SLinus Torvalds ulong qt_ino_res; /* inode reserved on a dquot */ 275*1da177e4SLinus Torvalds ulong qt_ino_res_used; /* inodes used from the reservation */ 276*1da177e4SLinus Torvalds long qt_bcount_delta; /* dquot blk count changes */ 277*1da177e4SLinus Torvalds long qt_delbcnt_delta; /* delayed dquot blk count changes */ 278*1da177e4SLinus Torvalds long qt_icount_delta; /* dquot inode count changes */ 279*1da177e4SLinus Torvalds ulong qt_rtblk_res; /* # blks reserved on a dquot */ 280*1da177e4SLinus Torvalds ulong qt_rtblk_res_used;/* # blks used from reservation */ 281*1da177e4SLinus Torvalds long qt_rtbcount_delta;/* dquot realtime blk changes */ 282*1da177e4SLinus Torvalds long qt_delrtb_delta; /* delayed RT blk count changes */ 283*1da177e4SLinus Torvalds } xfs_dqtrx_t; 284*1da177e4SLinus Torvalds 285*1da177e4SLinus Torvalds /* 286*1da177e4SLinus Torvalds * Dquot transaction functions, used if quota is enabled. 287*1da177e4SLinus Torvalds */ 288*1da177e4SLinus Torvalds typedef void (*qo_dup_dqinfo_t)(struct xfs_trans *, struct xfs_trans *); 289*1da177e4SLinus Torvalds typedef void (*qo_mod_dquot_byino_t)(struct xfs_trans *, 290*1da177e4SLinus Torvalds struct xfs_inode *, uint, long); 291*1da177e4SLinus Torvalds typedef void (*qo_free_dqinfo_t)(struct xfs_trans *); 292*1da177e4SLinus Torvalds typedef void (*qo_apply_dquot_deltas_t)(struct xfs_trans *); 293*1da177e4SLinus Torvalds typedef void (*qo_unreserve_and_mod_dquots_t)(struct xfs_trans *); 294*1da177e4SLinus Torvalds typedef int (*qo_reserve_quota_nblks_t)( 295*1da177e4SLinus Torvalds struct xfs_trans *, struct xfs_mount *, 296*1da177e4SLinus Torvalds struct xfs_inode *, long, long, uint); 297*1da177e4SLinus Torvalds typedef int (*qo_reserve_quota_bydquots_t)( 298*1da177e4SLinus Torvalds struct xfs_trans *, struct xfs_mount *, 299*1da177e4SLinus Torvalds struct xfs_dquot *, struct xfs_dquot *, 300*1da177e4SLinus Torvalds long, long, uint); 301*1da177e4SLinus Torvalds typedef struct xfs_dqtrxops { 302*1da177e4SLinus Torvalds qo_dup_dqinfo_t qo_dup_dqinfo; 303*1da177e4SLinus Torvalds qo_free_dqinfo_t qo_free_dqinfo; 304*1da177e4SLinus Torvalds qo_mod_dquot_byino_t qo_mod_dquot_byino; 305*1da177e4SLinus Torvalds qo_apply_dquot_deltas_t qo_apply_dquot_deltas; 306*1da177e4SLinus Torvalds qo_reserve_quota_nblks_t qo_reserve_quota_nblks; 307*1da177e4SLinus Torvalds qo_reserve_quota_bydquots_t qo_reserve_quota_bydquots; 308*1da177e4SLinus Torvalds qo_unreserve_and_mod_dquots_t qo_unreserve_and_mod_dquots; 309*1da177e4SLinus Torvalds } xfs_dqtrxops_t; 310*1da177e4SLinus Torvalds 311*1da177e4SLinus Torvalds #define XFS_DQTRXOP(mp, tp, op, args...) \ 312*1da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops ? \ 313*1da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops->op)(tp, ## args) : 0) 314*1da177e4SLinus Torvalds 315*1da177e4SLinus Torvalds #define XFS_DQTRXOP_VOID(mp, tp, op, args...) \ 316*1da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops ? \ 317*1da177e4SLinus Torvalds ((mp)->m_qm_ops.xfs_dqtrxops->op)(tp, ## args) : (void)0) 318*1da177e4SLinus Torvalds 319*1da177e4SLinus Torvalds #define XFS_TRANS_DUP_DQINFO(mp, otp, ntp) \ 320*1da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, otp, qo_dup_dqinfo, ntp) 321*1da177e4SLinus Torvalds #define XFS_TRANS_FREE_DQINFO(mp, tp) \ 322*1da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_free_dqinfo) 323*1da177e4SLinus Torvalds #define XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, field, delta) \ 324*1da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_mod_dquot_byino, ip, field, delta) 325*1da177e4SLinus Torvalds #define XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp) \ 326*1da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_apply_dquot_deltas) 327*1da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, fl) \ 328*1da177e4SLinus Torvalds XFS_DQTRXOP(mp, tp, qo_reserve_quota_nblks, mp, ip, nblks, ninos, fl) 329*1da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, fl) \ 330*1da177e4SLinus Torvalds XFS_DQTRXOP(mp, tp, qo_reserve_quota_bydquots, mp, ud, gd, nb, ni, fl) 331*1da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \ 332*1da177e4SLinus Torvalds XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots) 333*1da177e4SLinus Torvalds 334*1da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_BLKQUOTA(mp, tp, ip, nblks) \ 335*1da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \ 336*1da177e4SLinus Torvalds XFS_QMOPT_RES_REGBLKS) 337*1da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_BLKQUOTA_FORCE(mp, tp, ip, nblks) \ 338*1da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, 0, \ 339*1da177e4SLinus Torvalds XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES) 340*1da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_BLKQUOTA(mp, tp, ip, nblks) \ 341*1da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), 0, \ 342*1da177e4SLinus Torvalds XFS_QMOPT_RES_REGBLKS) 343*1da177e4SLinus Torvalds #define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 344*1da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \ 345*1da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 346*1da177e4SLinus Torvalds #define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \ 347*1da177e4SLinus Torvalds XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \ 348*1da177e4SLinus Torvalds f | XFS_QMOPT_RES_REGBLKS) 349*1da177e4SLinus Torvalds 350*1da177e4SLinus Torvalds extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *); 351*1da177e4SLinus Torvalds 352*1da177e4SLinus Torvalds extern struct bhv_vfsops xfs_qmops; 353*1da177e4SLinus Torvalds 354*1da177e4SLinus Torvalds #endif /* __KERNEL__ */ 355*1da177e4SLinus Torvalds 356*1da177e4SLinus Torvalds #endif /* __XFS_QUOTA_H__ */ 357