aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_quota.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_quota.h')
-rw-r--r--fs/xfs/xfs_quota.h104
1 files changed, 64 insertions, 40 deletions
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index c38068f26c55..b14f42c714b6 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -108,11 +108,28 @@ typedef struct xfs_dqblk {
108 { XFS_DQ_FREEING, "FREEING" } 108 { XFS_DQ_FREEING, "FREEING" }
109 109
110/* 110/*
111 * In the worst case, when both user and group quotas are on, 111 * We have the possibility of all three quota types being active at once, and
112 * we can have a max of three dquots changing in a single transaction. 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.
113 */ 130 */
114#define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3) 131#define XFS_DQUOT_LOGRES(mp) \
115 132 ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6)
116 133
117/* 134/*
118 * These are the structures used to lay out dquots and quotaoff 135 * These are the structures used to lay out dquots and quotaoff
@@ -161,30 +178,42 @@ typedef struct xfs_qoff_logformat {
161#define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */ 178#define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */
162 179
163/* 180/*
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/*
164 * Quota Accounting/Enforcement flags 190 * Quota Accounting/Enforcement flags
165 */ 191 */
166#define XFS_ALL_QUOTA_ACCT \ 192#define XFS_ALL_QUOTA_ACCT \
167 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) 193 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
168#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) 194#define XFS_ALL_QUOTA_ENFD \
169#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) 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)
170 198
171#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT) 199#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
172#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT) 200#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
173#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT) 201#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
174#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT) 202#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
175#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) 203#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD)
176#define XFS_IS_OQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD) 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)
177 206
178/* 207/*
179 * Incore only flags for quotaoff - these bits get cleared when quota(s) 208 * Incore only flags for quotaoff - these bits get cleared when quota(s)
180 * are in the process of getting turned off. These flags are in m_qflags but 209 * are in the process of getting turned off. These flags are in m_qflags but
181 * never in sb_qflags. 210 * never in sb_qflags.
182 */ 211 */
183#define XFS_UQUOTA_ACTIVE 0x0100 /* uquotas are being turned off */ 212#define XFS_UQUOTA_ACTIVE 0x1000 /* uquotas are being turned off */
184#define XFS_PQUOTA_ACTIVE 0x0200 /* pquotas are being turned off */ 213#define XFS_GQUOTA_ACTIVE 0x2000 /* gquotas are being turned off */
185#define XFS_GQUOTA_ACTIVE 0x0400 /* gquotas are being turned off */ 214#define XFS_PQUOTA_ACTIVE 0x4000 /* pquotas are being turned off */
186#define XFS_ALL_QUOTA_ACTIVE \ 215#define XFS_ALL_QUOTA_ACTIVE \
187 (XFS_UQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE) 216 (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE)
188 217
189/* 218/*
190 * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees 219 * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees
@@ -259,33 +288,24 @@ typedef struct xfs_qoff_logformat {
259 * we didn't have the inode locked, the appropriate dquot(s) will be 288 * we didn't have the inode locked, the appropriate dquot(s) will be
260 * attached atomically. 289 * attached atomically.
261 */ 290 */
262#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ 291#define XFS_NOT_DQATTACHED(mp, ip) \
263 (ip)->i_udquot == NULL) || \ 292 ((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \
264 (XFS_IS_OQUOTA_ON(mp) && \ 293 (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \
265 (ip)->i_gdquot == NULL)) 294 (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL))
266 295
267#define XFS_QM_NEED_QUOTACHECK(mp) \ 296#define XFS_QM_NEED_QUOTACHECK(mp) \
268 ((XFS_IS_UQUOTA_ON(mp) && \ 297 ((XFS_IS_UQUOTA_ON(mp) && \
269 (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \ 298 (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
270 (XFS_IS_GQUOTA_ON(mp) && \ 299 (XFS_IS_GQUOTA_ON(mp) && \
271 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 300 (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
272 (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \
273 (XFS_IS_PQUOTA_ON(mp) && \ 301 (XFS_IS_PQUOTA_ON(mp) && \
274 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \ 302 (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
275 (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT))))
276
277#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
278 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
279 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
280
281#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
282 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
283 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
284 303
285#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ 304#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
286 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ 305 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
287 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ 306 XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\
288 XFS_GQUOTA_ACCT) 307 XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\
308 XFS_PQUOTA_CHKD)
289 309
290 310
291/* 311/*
@@ -318,17 +338,18 @@ extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
318 struct xfs_inode *, long, long, uint); 338 struct xfs_inode *, long, long, uint);
319extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, 339extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
320 struct xfs_mount *, struct xfs_dquot *, 340 struct xfs_mount *, struct xfs_dquot *,
321 struct xfs_dquot *, long, long, uint); 341 struct xfs_dquot *, struct xfs_dquot *, long, long, uint);
322 342
323extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, 343extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint,
324 struct xfs_dquot **, struct xfs_dquot **); 344 struct xfs_dquot **, struct xfs_dquot **, struct xfs_dquot **);
325extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, 345extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
326 struct xfs_dquot *, struct xfs_dquot *); 346 struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *);
327extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); 347extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
328extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *, 348extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *,
329 struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *); 349 struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *);
330extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *, 350extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *,
331 struct xfs_dquot *, struct xfs_dquot *, uint); 351 struct xfs_dquot *, struct xfs_dquot *,
352 struct xfs_dquot *, uint);
332extern int xfs_qm_dqattach(struct xfs_inode *, uint); 353extern int xfs_qm_dqattach(struct xfs_inode *, uint);
333extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint); 354extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint);
334extern void xfs_qm_dqdetach(struct xfs_inode *); 355extern void xfs_qm_dqdetach(struct xfs_inode *);
@@ -342,10 +363,12 @@ extern void xfs_qm_unmount_quotas(struct xfs_mount *);
342#else 363#else
343static inline int 364static inline int
344xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid, 365xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid,
345 uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp) 366 uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp,
367 struct xfs_dquot **pdqp)
346{ 368{
347 *udqp = NULL; 369 *udqp = NULL;
348 *gdqp = NULL; 370 *gdqp = NULL;
371 *pdqp = NULL;
349 return 0; 372 return 0;
350} 373}
351#define xfs_trans_dup_dqinfo(tp, tp2) 374#define xfs_trans_dup_dqinfo(tp, tp2)
@@ -360,14 +383,15 @@ static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
360} 383}
361static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp, 384static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
362 struct xfs_mount *mp, struct xfs_dquot *udqp, 385 struct xfs_mount *mp, struct xfs_dquot *udqp,
363 struct xfs_dquot *gdqp, long nblks, long nions, uint flags) 386 struct xfs_dquot *gdqp, struct xfs_dquot *pdqp,
387 long nblks, long nions, uint flags)
364{ 388{
365 return 0; 389 return 0;
366} 390}
367#define xfs_qm_vop_create_dqattach(tp, ip, u, g) 391#define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
368#define xfs_qm_vop_rename_dqattach(it) (0) 392#define xfs_qm_vop_rename_dqattach(it) (0)
369#define xfs_qm_vop_chown(tp, ip, old, new) (NULL) 393#define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
370#define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0) 394#define xfs_qm_vop_chown_reserve(tp, ip, u, g, p, fl) (0)
371#define xfs_qm_dqattach(ip, fl) (0) 395#define xfs_qm_dqattach(ip, fl) (0)
372#define xfs_qm_dqattach_locked(ip, fl) (0) 396#define xfs_qm_dqattach_locked(ip, fl) (0)
373#define xfs_qm_dqdetach(ip) 397#define xfs_qm_dqdetach(ip)
@@ -381,8 +405,8 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
381 405
382#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \ 406#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
383 xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) 407 xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
384#define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \ 408#define xfs_trans_reserve_quota(tp, mp, ud, gd, pd, nb, ni, f) \
385 xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ 409 xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \
386 f | XFS_QMOPT_RES_REGBLKS) 410 f | XFS_QMOPT_RES_REGBLKS)
387 411
388extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *, 412extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *,