aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_quota.h
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-08-12 06:49:30 -0400
committerBen Myers <bpm@sgi.com>2013-08-12 17:20:18 -0400
commit76456fc2a6fe3a31c492a072413925eebc68cc98 (patch)
tree8c67da2f2a2d7f49394b4d1dee38a3b256c16afc /fs/xfs/xfs_quota.h
parentc7298202e5df6fad66c7c8146bf2ed55ba07aff0 (diff)
xfs: introduce xfs_quota_defs.h
There are a lot of quota flag definitions that are shared by user and kernel space. Move them all to xfs_quota_defs.h so we can unshare xfs_quota.h and remove the __KERNEL__ regions from it. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_quota.h')
-rw-r--r--fs/xfs/xfs_quota.h134
1 files changed, 3 insertions, 131 deletions
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index 16bde32f140e..fc2fed67a58d 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -18,141 +18,14 @@
18#ifndef __XFS_QUOTA_H__ 18#ifndef __XFS_QUOTA_H__
19#define __XFS_QUOTA_H__ 19#define __XFS_QUOTA_H__
20 20
21struct xfs_trans; 21#include "xfs_quota_defs.h"
22 22
23/* 23/*
24 * Even though users may not have quota limits occupying all 64-bits, 24 * Kernel only quota definitions and functions
25 * they may need 64-bit accounting. Hence, 64-bit quota-counters,
26 * and quota-limits. This is a waste in the common case, but hey ...
27 */ 25 */
28typedef __uint64_t xfs_qcnt_t;
29typedef __uint16_t xfs_qwarncnt_t;
30
31/*
32 * flags for q_flags field in the dquot.
33 */
34#define XFS_DQ_USER 0x0001 /* a user quota */
35#define XFS_DQ_PROJ 0x0002 /* project quota */
36#define XFS_DQ_GROUP 0x0004 /* a group quota */
37#define XFS_DQ_DIRTY 0x0008 /* dquot is dirty */
38#define XFS_DQ_FREEING 0x0010 /* dquot is beeing torn down */
39
40#define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
41 26
42#define XFS_DQ_FLAGS \ 27struct xfs_trans;
43 { XFS_DQ_USER, "USER" }, \
44 { XFS_DQ_PROJ, "PROJ" }, \
45 { XFS_DQ_GROUP, "GROUP" }, \
46 { XFS_DQ_DIRTY, "DIRTY" }, \
47 { XFS_DQ_FREEING, "FREEING" }
48
49/*
50 * We have the possibility of all three quota types being active at once, and
51 * hence free space modification requires modification of all three current
52 * dquots in a single transaction. For this case we need to have a reservation
53 * of at least 3 dquots.
54 *
55 * However, a chmod operation can change both UID and GID in a single
56 * transaction, resulting in requiring {old, new} x {uid, gid} dquots to be
57 * modified. Hence for this case we need to reserve space for at least 4 dquots.
58 *
59 * And in the worst case, there's a rename operation that can be modifying up to
60 * 4 inodes with dquots attached to them. In reality, the only inodes that can
61 * have their dquots modified are the source and destination directory inodes
62 * due to directory name creation and removal. That can require space allocation
63 * and/or freeing on both directory inodes, and hence all three dquots on each
64 * inode can be modified. And if the directories are world writeable, all the
65 * dquots can be unique and so 6 dquots can be modified....
66 *
67 * And, of course, we also need to take into account the dquot log format item
68 * used to describe each dquot.
69 */
70#define XFS_DQUOT_LOGRES(mp) \
71 ((sizeof(struct xfs_dq_logformat) + sizeof(struct xfs_disk_dquot)) * 6)
72
73#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
74#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
75#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
76#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
77#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD)
78#define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)
79#define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD)
80
81/*
82 * Incore only flags for quotaoff - these bits get cleared when quota(s)
83 * are in the process of getting turned off. These flags are in m_qflags but
84 * never in sb_qflags.
85 */
86#define XFS_UQUOTA_ACTIVE 0x1000 /* uquotas are being turned off */
87#define XFS_GQUOTA_ACTIVE 0x2000 /* gquotas are being turned off */
88#define XFS_PQUOTA_ACTIVE 0x4000 /* pquotas are being turned off */
89#define XFS_ALL_QUOTA_ACTIVE \
90 (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE)
91
92/*
93 * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees
94 * quota will be not be switched off as long as that inode lock is held.
95 */
96#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \
97 XFS_GQUOTA_ACTIVE | \
98 XFS_PQUOTA_ACTIVE))
99#define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \
100 XFS_PQUOTA_ACTIVE))
101#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE)
102#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE)
103#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE)
104
105/*
106 * Flags to tell various functions what to do. Not all of these are meaningful
107 * to a single function. None of these XFS_QMOPT_* flags are meant to have
108 * persistent values (ie. their values can and will change between versions)
109 */
110#define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */
111#define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */
112#define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */
113#define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */
114#define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */
115#define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */
116#define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */
117#define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */
118#define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */
119
120/*
121 * flags to xfs_trans_mod_dquot to indicate which field needs to be
122 * modified.
123 */
124#define XFS_QMOPT_RES_REGBLKS 0x0010000
125#define XFS_QMOPT_RES_RTBLKS 0x0020000
126#define XFS_QMOPT_BCOUNT 0x0040000
127#define XFS_QMOPT_ICOUNT 0x0080000
128#define XFS_QMOPT_RTBCOUNT 0x0100000
129#define XFS_QMOPT_DELBCOUNT 0x0200000
130#define XFS_QMOPT_DELRTBCOUNT 0x0400000
131#define XFS_QMOPT_RES_INOS 0x0800000
132
133/*
134 * flags for dqalloc.
135 */
136#define XFS_QMOPT_INHERIT 0x1000000
137
138/*
139 * flags to xfs_trans_mod_dquot.
140 */
141#define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS
142#define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS
143#define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS
144#define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT
145#define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT
146#define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT
147#define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT
148#define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
149
150
151#define XFS_QMOPT_QUOTALL \
152 (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
153#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
154 28
155#ifdef __KERNEL__
156/* 29/*
157 * This check is done typically without holding the inode lock; 30 * This check is done typically without holding the inode lock;
158 * that may seem racy, but it is harmless in the context that it is used. 31 * that may seem racy, but it is harmless in the context that it is used.
@@ -289,5 +162,4 @@ extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
289 162
290extern const struct xfs_buf_ops xfs_dquot_buf_ops; 163extern const struct xfs_buf_ops xfs_dquot_buf_ops;
291 164
292#endif /* __KERNEL__ */
293#endif /* __XFS_QUOTA_H__ */ 165#endif /* __XFS_QUOTA_H__ */