Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write the Free Software Foundation, |
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #ifndef __XFS_QUOTA_H__ |
| 19 | #define __XFS_QUOTA_H__ |
| 20 | |
Christoph Hellwig | fcafb71 | 2009-02-09 08:47:34 +0100 | [diff] [blame] | 21 | struct xfs_trans; |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* |
| 24 | * The ondisk form of a dquot structure. |
| 25 | */ |
| 26 | #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ |
| 27 | #define XFS_DQUOT_VERSION (u_int8_t)0x01 /* latest version number */ |
| 28 | |
| 29 | /* |
| 30 | * uid_t and gid_t are hard-coded to 32 bits in the inode. |
| 31 | * Hence, an 'id' in a dquot is 32 bits.. |
| 32 | */ |
Nathan Scott | c310ab6 | 2005-11-02 10:31:41 +1100 | [diff] [blame] | 33 | typedef __uint32_t xfs_dqid_t; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | /* |
Nathan Scott | c41564b | 2006-03-29 08:55:14 +1000 | [diff] [blame] | 36 | * Even though users may not have quota limits occupying all 64-bits, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | * they may need 64-bit accounting. Hence, 64-bit quota-counters, |
| 38 | * and quota-limits. This is a waste in the common case, but hey ... |
| 39 | */ |
| 40 | typedef __uint64_t xfs_qcnt_t; |
| 41 | typedef __uint16_t xfs_qwarncnt_t; |
| 42 | |
| 43 | /* |
| 44 | * This is the main portion of the on-disk representation of quota |
| 45 | * information for a user. This is the q_core of the xfs_dquot_t that |
| 46 | * is kept in kernel memory. We pad this with some more expansion room |
| 47 | * to construct the on disk structure. |
| 48 | */ |
| 49 | typedef struct xfs_disk_dquot { |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 50 | __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ |
| 51 | __u8 d_version; /* dquot version */ |
| 52 | __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */ |
| 53 | __be32 d_id; /* user,project,group id */ |
| 54 | __be64 d_blk_hardlimit;/* absolute limit on disk blks */ |
| 55 | __be64 d_blk_softlimit;/* preferred limit on disk blks */ |
| 56 | __be64 d_ino_hardlimit;/* maximum # allocated inodes */ |
| 57 | __be64 d_ino_softlimit;/* preferred inode limit */ |
| 58 | __be64 d_bcount; /* disk blocks owned by the user */ |
| 59 | __be64 d_icount; /* inodes owned by the user */ |
| 60 | __be32 d_itimer; /* zero if within inode limits if not, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | this is when we refuse service */ |
Christoph Hellwig | 1149d96 | 2005-11-02 15:01:12 +1100 | [diff] [blame] | 62 | __be32 d_btimer; /* similar to above; for disk blocks */ |
| 63 | __be16 d_iwarns; /* warnings issued wrt num inodes */ |
| 64 | __be16 d_bwarns; /* warnings issued wrt disk blocks */ |
| 65 | __be32 d_pad0; /* 64 bit align */ |
| 66 | __be64 d_rtb_hardlimit;/* absolute limit on realtime blks */ |
| 67 | __be64 d_rtb_softlimit;/* preferred limit on RT disk blks */ |
| 68 | __be64 d_rtbcount; /* realtime blocks owned */ |
| 69 | __be32 d_rtbtimer; /* similar to above; for RT disk blocks */ |
| 70 | __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */ |
| 71 | __be16 d_pad; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | } xfs_disk_dquot_t; |
| 73 | |
| 74 | /* |
| 75 | * This is what goes on disk. This is separated from the xfs_disk_dquot because |
| 76 | * carrying the unnecessary padding would be a waste of memory. |
| 77 | */ |
| 78 | typedef struct xfs_dqblk { |
| 79 | xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ |
Christoph Hellwig | 3fe58f3 | 2013-04-03 16:11:16 +1100 | [diff] [blame] | 80 | char dd_fill[4]; /* filling for posterity */ |
| 81 | |
| 82 | /* |
| 83 | * These two are only present on filesystems with the CRC bits set. |
| 84 | */ |
| 85 | __be32 dd_crc; /* checksum */ |
| 86 | __be64 dd_lsn; /* last modification in log */ |
| 87 | uuid_t dd_uuid; /* location information */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 88 | } xfs_dqblk_t; |
| 89 | |
Dave Chinner | 6fcdc59 | 2013-06-03 15:28:46 +1000 | [diff] [blame] | 90 | #define XFS_DQUOT_CRC_OFF offsetof(struct xfs_dqblk, dd_crc) |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | /* |
| 93 | * flags for q_flags field in the dquot. |
| 94 | */ |
| 95 | #define XFS_DQ_USER 0x0001 /* a user quota */ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 96 | #define XFS_DQ_PROJ 0x0002 /* project quota */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | #define XFS_DQ_GROUP 0x0004 /* a group quota */ |
Christoph Hellwig | df6771b | 2008-12-03 12:20:30 +0100 | [diff] [blame] | 98 | #define XFS_DQ_DIRTY 0x0008 /* dquot is dirty */ |
Christoph Hellwig | 9267855 | 2011-12-06 21:58:18 +0000 | [diff] [blame] | 99 | #define XFS_DQ_FREEING 0x0010 /* dquot is beeing torn down */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 101 | #define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP) |
| 102 | |
Christoph Hellwig | 0b1b213 | 2009-12-14 23:14:59 +0000 | [diff] [blame] | 103 | #define XFS_DQ_FLAGS \ |
| 104 | { XFS_DQ_USER, "USER" }, \ |
| 105 | { XFS_DQ_PROJ, "PROJ" }, \ |
| 106 | { XFS_DQ_GROUP, "GROUP" }, \ |
Christoph Hellwig | 9267855 | 2011-12-06 21:58:18 +0000 | [diff] [blame] | 107 | { XFS_DQ_DIRTY, "DIRTY" }, \ |
| 108 | { XFS_DQ_FREEING, "FREEING" } |
Christoph Hellwig | 0b1b213 | 2009-12-14 23:14:59 +0000 | [diff] [blame] | 109 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | /* |
Dave Chinner | b0a9dab | 2013-07-10 07:04:01 +1000 | [diff] [blame] | 111 | * We have the possibility of all three quota types being active at once, and |
| 112 | * hence free space modification requires modification of all three current |
| 113 | * dquots in a single transaction. For this case we need to have a reservation |
| 114 | * of at least 3 dquots. |
| 115 | * |
| 116 | * However, a chmod operation can change both UID and GID in a single |
| 117 | * transaction, resulting in requiring {old, new} x {uid, gid} dquots to be |
| 118 | * modified. Hence for this case we need to reserve space for at least 4 dquots. |
| 119 | * |
| 120 | * And in the worst case, there's a rename operation that can be modifying up to |
| 121 | * 4 inodes with dquots attached to them. In reality, the only inodes that can |
| 122 | * have their dquots modified are the source and destination directory inodes |
| 123 | * due to directory name creation and removal. That can require space allocation |
| 124 | * and/or freeing on both directory inodes, and hence all three dquots on each |
| 125 | * inode can be modified. And if the directories are world writeable, all the |
| 126 | * dquots can be unique and so 6 dquots can be modified.... |
| 127 | * |
| 128 | * And, of course, we also need to take into account the dquot log format item |
| 129 | * used to describe each dquot. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | */ |
Dave Chinner | b0a9dab | 2013-07-10 07:04:01 +1000 | [diff] [blame] | 131 | #define XFS_DQUOT_LOGRES(mp) \ |
| 132 | ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | /* |
| 135 | * These are the structures used to lay out dquots and quotaoff |
| 136 | * records on the log. Quite similar to those of inodes. |
| 137 | */ |
| 138 | |
| 139 | /* |
| 140 | * log format struct for dquots. |
| 141 | * The first two fields must be the type and size fitting into |
| 142 | * 32 bits : log_recovery code assumes that. |
| 143 | */ |
| 144 | typedef struct xfs_dq_logformat { |
| 145 | __uint16_t qlf_type; /* dquot log item type */ |
| 146 | __uint16_t qlf_size; /* size of this item */ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 147 | xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | __int64_t qlf_blkno; /* blkno of dquot buffer */ |
| 149 | __int32_t qlf_len; /* len of dquot buffer */ |
| 150 | __uint32_t qlf_boffset; /* off of dquot in buffer */ |
| 151 | } xfs_dq_logformat_t; |
| 152 | |
| 153 | /* |
| 154 | * log format struct for QUOTAOFF records. |
| 155 | * The first two fields must be the type and size fitting into |
| 156 | * 32 bits : log_recovery code assumes that. |
| 157 | * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer |
| 158 | * to the first and ensures that the first logitem is taken out of the AIL |
| 159 | * only when the last one is securely committed. |
| 160 | */ |
| 161 | typedef struct xfs_qoff_logformat { |
| 162 | unsigned short qf_type; /* quotaoff log item type */ |
| 163 | unsigned short qf_size; /* size of this item */ |
| 164 | unsigned int qf_flags; /* USR and/or GRP */ |
| 165 | char qf_pad[12]; /* padding for future */ |
| 166 | } xfs_qoff_logformat_t; |
| 167 | |
| 168 | |
| 169 | /* |
| 170 | * Disk quotas status in m_qflags, and also sb_qflags. 16 bits. |
| 171 | */ |
| 172 | #define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */ |
| 173 | #define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */ |
| 174 | #define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 175 | #define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */ |
| 176 | #define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */ |
| 177 | #define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | #define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ |
| 179 | |
| 180 | /* |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 181 | * Conversion to and from the combined OQUOTA flag (if necessary) |
| 182 | * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk() |
| 183 | */ |
| 184 | #define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */ |
| 185 | #define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */ |
| 186 | #define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */ |
| 187 | #define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */ |
| 188 | |
| 189 | /* |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 190 | * Quota Accounting/Enforcement flags |
| 191 | */ |
| 192 | #define XFS_ALL_QUOTA_ACCT \ |
| 193 | (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 194 | #define XFS_ALL_QUOTA_ENFD \ |
| 195 | (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) |
| 196 | #define XFS_ALL_QUOTA_CHKD \ |
| 197 | (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD) |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 198 | |
| 199 | #define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 200 | #define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) |
| 201 | #define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) |
| 202 | #define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) |
Kouta Ooizumi | e6d2942 | 2007-05-08 13:49:33 +1000 | [diff] [blame] | 203 | #define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 204 | #define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD) |
| 205 | #define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 206 | |
| 207 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | * Incore only flags for quotaoff - these bits get cleared when quota(s) |
| 209 | * are in the process of getting turned off. These flags are in m_qflags but |
| 210 | * never in sb_qflags. |
| 211 | */ |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 212 | #define XFS_UQUOTA_ACTIVE 0x1000 /* uquotas are being turned off */ |
| 213 | #define XFS_GQUOTA_ACTIVE 0x2000 /* gquotas are being turned off */ |
| 214 | #define XFS_PQUOTA_ACTIVE 0x4000 /* pquotas are being turned off */ |
Chandra Seetharaman | 4177af3 | 2012-01-23 17:31:43 +0000 | [diff] [blame] | 215 | #define XFS_ALL_QUOTA_ACTIVE \ |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 216 | (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
| 218 | /* |
| 219 | * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees |
| 220 | * quota will be not be switched off as long as that inode lock is held. |
| 221 | */ |
| 222 | #define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 223 | XFS_GQUOTA_ACTIVE | \ |
| 224 | XFS_PQUOTA_ACTIVE)) |
| 225 | #define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \ |
| 226 | XFS_PQUOTA_ACTIVE)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | #define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE) |
| 228 | #define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE) |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 229 | #define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | |
| 231 | /* |
| 232 | * Flags to tell various functions what to do. Not all of these are meaningful |
| 233 | * to a single function. None of these XFS_QMOPT_* flags are meant to have |
| 234 | * persistent values (ie. their values can and will change between versions) |
| 235 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | #define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */ |
| 237 | #define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 238 | #define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | #define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | #define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */ |
Nathan Scott | 9a2a7de | 2006-03-31 13:04:49 +1000 | [diff] [blame] | 241 | #define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */ |
Nathan Scott | 9a2a7de | 2006-03-31 13:04:49 +1000 | [diff] [blame] | 242 | #define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 243 | #define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */ |
Nathan Scott | 9a2a7de | 2006-03-31 13:04:49 +1000 | [diff] [blame] | 244 | #define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | |
| 246 | /* |
| 247 | * flags to xfs_trans_mod_dquot to indicate which field needs to be |
| 248 | * modified. |
| 249 | */ |
| 250 | #define XFS_QMOPT_RES_REGBLKS 0x0010000 |
| 251 | #define XFS_QMOPT_RES_RTBLKS 0x0020000 |
| 252 | #define XFS_QMOPT_BCOUNT 0x0040000 |
| 253 | #define XFS_QMOPT_ICOUNT 0x0080000 |
| 254 | #define XFS_QMOPT_RTBCOUNT 0x0100000 |
| 255 | #define XFS_QMOPT_DELBCOUNT 0x0200000 |
| 256 | #define XFS_QMOPT_DELRTBCOUNT 0x0400000 |
| 257 | #define XFS_QMOPT_RES_INOS 0x0800000 |
| 258 | |
| 259 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | * flags for dqalloc. |
| 261 | */ |
Dave Chinner | 20026d9 | 2010-02-04 09:48:58 +1100 | [diff] [blame] | 262 | #define XFS_QMOPT_INHERIT 0x1000000 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
| 264 | /* |
| 265 | * flags to xfs_trans_mod_dquot. |
| 266 | */ |
| 267 | #define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS |
| 268 | #define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS |
| 269 | #define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS |
| 270 | #define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT |
| 271 | #define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT |
| 272 | #define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT |
| 273 | #define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT |
| 274 | #define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT |
| 275 | |
| 276 | |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 277 | #define XFS_QMOPT_QUOTALL \ |
| 278 | (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | #define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS) |
| 280 | |
| 281 | #ifdef __KERNEL__ |
| 282 | /* |
| 283 | * This check is done typically without holding the inode lock; |
Nathan Scott | c41564b | 2006-03-29 08:55:14 +1000 | [diff] [blame] | 284 | * that may seem racy, but it is harmless in the context that it is used. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | * The inode cannot go inactive as long a reference is kept, and |
| 286 | * therefore if dquot(s) were attached, they'll stay consistent. |
| 287 | * If, for example, the ownership of the inode changes while |
| 288 | * we didn't have the inode locked, the appropriate dquot(s) will be |
| 289 | * attached atomically. |
| 290 | */ |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 291 | #define XFS_NOT_DQATTACHED(mp, ip) \ |
| 292 | ((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \ |
| 293 | (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \ |
| 294 | (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 296 | #define XFS_QM_NEED_QUOTACHECK(mp) \ |
| 297 | ((XFS_IS_UQUOTA_ON(mp) && \ |
| 298 | (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \ |
| 299 | (XFS_IS_GQUOTA_ON(mp) && \ |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 300 | (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \ |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 301 | (XFS_IS_PQUOTA_ON(mp) && \ |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 302 | (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0)) |
Nathan Scott | c8ad20f | 2005-06-21 15:38:48 +1000 | [diff] [blame] | 303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | #define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ |
Chandra Seetharaman | 83e782e | 2013-06-27 17:25:10 -0500 | [diff] [blame] | 305 | XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ |
| 306 | XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\ |
| 307 | XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\ |
| 308 | XFS_PQUOTA_CHKD) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | |
| 310 | |
| 311 | /* |
| 312 | * The structure kept inside the xfs_trans_t keep track of dquot changes |
| 313 | * within a transaction and apply them later. |
| 314 | */ |
| 315 | typedef struct xfs_dqtrx { |
| 316 | struct xfs_dquot *qt_dquot; /* the dquot this refers to */ |
| 317 | ulong qt_blk_res; /* blks reserved on a dquot */ |
| 318 | ulong qt_blk_res_used; /* blks used from the reservation */ |
| 319 | ulong qt_ino_res; /* inode reserved on a dquot */ |
| 320 | ulong qt_ino_res_used; /* inodes used from the reservation */ |
| 321 | long qt_bcount_delta; /* dquot blk count changes */ |
| 322 | long qt_delbcnt_delta; /* delayed dquot blk count changes */ |
| 323 | long qt_icount_delta; /* dquot inode count changes */ |
| 324 | ulong qt_rtblk_res; /* # blks reserved on a dquot */ |
| 325 | ulong qt_rtblk_res_used;/* # blks used from reservation */ |
| 326 | long qt_rtbcount_delta;/* dquot realtime blk changes */ |
| 327 | long qt_delrtb_delta; /* delayed RT blk count changes */ |
| 328 | } xfs_dqtrx_t; |
| 329 | |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 330 | #ifdef CONFIG_XFS_QUOTA |
| 331 | extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *); |
| 332 | extern void xfs_trans_free_dqinfo(struct xfs_trans *); |
| 333 | extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *, |
| 334 | uint, long); |
| 335 | extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *); |
| 336 | extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *); |
| 337 | extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, |
| 338 | struct xfs_inode *, long, long, uint); |
| 339 | extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, |
| 340 | struct xfs_mount *, struct xfs_dquot *, |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 341 | struct xfs_dquot *, struct xfs_dquot *, long, long, uint); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 343 | extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 344 | struct xfs_dquot **, struct xfs_dquot **, struct xfs_dquot **); |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 345 | extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 346 | struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *); |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 347 | extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); |
| 348 | extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, |
| 349 | struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); |
| 350 | extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 351 | struct xfs_dquot *, struct xfs_dquot *, |
| 352 | struct xfs_dquot *, uint); |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 353 | extern int xfs_qm_dqattach(struct xfs_inode *, uint); |
| 354 | extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); |
| 355 | extern void xfs_qm_dqdetach(struct xfs_inode *); |
| 356 | extern void xfs_qm_dqrele(struct xfs_dquot *); |
| 357 | extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *); |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 358 | extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *); |
| 359 | extern void xfs_qm_mount_quotas(struct xfs_mount *); |
| 360 | extern void xfs_qm_unmount(struct xfs_mount *); |
| 361 | extern void xfs_qm_unmount_quotas(struct xfs_mount *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 363 | #else |
Christoph Hellwig | 493b87e | 2009-06-12 11:34:55 -0400 | [diff] [blame] | 364 | static inline int |
| 365 | xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid, |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 366 | uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp, |
| 367 | struct xfs_dquot **pdqp) |
Christoph Hellwig | 493b87e | 2009-06-12 11:34:55 -0400 | [diff] [blame] | 368 | { |
| 369 | *udqp = NULL; |
| 370 | *gdqp = NULL; |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 371 | *pdqp = NULL; |
Christoph Hellwig | 493b87e | 2009-06-12 11:34:55 -0400 | [diff] [blame] | 372 | return 0; |
| 373 | } |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 374 | #define xfs_trans_dup_dqinfo(tp, tp2) |
| 375 | #define xfs_trans_free_dqinfo(tp) |
| 376 | #define xfs_trans_mod_dquot_byino(tp, ip, fields, delta) |
| 377 | #define xfs_trans_apply_dquot_deltas(tp) |
| 378 | #define xfs_trans_unreserve_and_mod_dquots(tp) |
Christoph Hellwig | 5d2bf8a | 2010-11-06 11:42:56 +0000 | [diff] [blame] | 379 | static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp, |
| 380 | struct xfs_inode *ip, long nblks, long ninos, uint flags) |
| 381 | { |
| 382 | return 0; |
| 383 | } |
| 384 | static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, |
| 385 | struct xfs_mount *mp, struct xfs_dquot *udqp, |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 386 | struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, |
| 387 | long nblks, long nions, uint flags) |
Christoph Hellwig | 5d2bf8a | 2010-11-06 11:42:56 +0000 | [diff] [blame] | 388 | { |
| 389 | return 0; |
| 390 | } |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 391 | #define xfs_qm_vop_create_dqattach(tp, ip, u, g, p) |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 392 | #define xfs_qm_vop_rename_dqattach(it) (0) |
| 393 | #define xfs_qm_vop_chown(tp, ip, old, new) (NULL) |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 394 | #define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl) (0) |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 395 | #define xfs_qm_dqattach(ip, fl) (0) |
| 396 | #define xfs_qm_dqattach_locked(ip, fl) (0) |
| 397 | #define xfs_qm_dqdetach(ip) |
| 398 | #define xfs_qm_dqrele(d) |
| 399 | #define xfs_qm_statvfs(ip, s) |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 400 | #define xfs_qm_newmount(mp, a, b) (0) |
| 401 | #define xfs_qm_mount_quotas(mp) |
| 402 | #define xfs_qm_unmount(mp) |
Christoph Hellwig | 5d2bf8a | 2010-11-06 11:42:56 +0000 | [diff] [blame] | 403 | #define xfs_qm_unmount_quotas(mp) |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 404 | #endif /* CONFIG_XFS_QUOTA */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
Christoph Hellwig | 7d09525 | 2009-06-08 15:33:32 +0200 | [diff] [blame] | 406 | #define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ |
| 407 | xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) |
Chandra Seetharaman | 92f8ff7 | 2013-07-11 00:00:40 -0500 | [diff] [blame] | 408 | #define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \ |
| 409 | xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | f | XFS_QMOPT_RES_REGBLKS) |
| 411 | |
Dave Chinner | a0fa2b6 | 2011-03-07 10:01:35 +1100 | [diff] [blame] | 412 | extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *, |
| 413 | xfs_dqid_t, uint, uint, char *); |
Tim Shimmin | 4cd4a03 | 2005-09-05 08:24:10 +1000 | [diff] [blame] | 414 | extern int xfs_mount_reset_sbqflags(struct xfs_mount *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
Christoph Hellwig | 3fe58f3 | 2013-04-03 16:11:16 +1100 | [diff] [blame] | 416 | extern const struct xfs_buf_ops xfs_dquot_buf_ops; |
| 417 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 418 | #endif /* __KERNEL__ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | #endif /* __XFS_QUOTA_H__ */ |