1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef __XFS_QUOTA_H__
19#define __XFS_QUOTA_H__
20
21
22
23
24#define XFS_DQUOT_MAGIC 0x4451
25#define XFS_DQUOT_VERSION (u_int8_t)0x01
26
27
28
29
30
31typedef __uint32_t xfs_dqid_t;
32
33
34
35
36
37
38typedef __uint64_t xfs_qcnt_t;
39typedef __uint16_t xfs_qwarncnt_t;
40
41
42
43
44
45
46
47typedef struct xfs_disk_dquot {
48 __be16 d_magic;
49 __u8 d_version;
50 __u8 d_flags;
51 __be32 d_id;
52 __be64 d_blk_hardlimit;
53 __be64 d_blk_softlimit;
54 __be64 d_ino_hardlimit;
55 __be64 d_ino_softlimit;
56 __be64 d_bcount;
57 __be64 d_icount;
58 __be32 d_itimer;
59
60 __be32 d_btimer;
61 __be16 d_iwarns;
62 __be16 d_bwarns;
63 __be32 d_pad0;
64 __be64 d_rtb_hardlimit;
65 __be64 d_rtb_softlimit;
66 __be64 d_rtbcount;
67 __be32 d_rtbtimer;
68 __be16 d_rtbwarns;
69 __be16 d_pad;
70} xfs_disk_dquot_t;
71
72
73
74
75
76typedef struct xfs_dqblk {
77 xfs_disk_dquot_t dd_diskdq;
78 char dd_fill[32];
79} xfs_dqblk_t;
80
81
82
83
84#define XFS_DQ_USER 0x0001
85#define XFS_DQ_PROJ 0x0002
86#define XFS_DQ_GROUP 0x0004
87#define XFS_DQ_FLOCKED 0x0008
88#define XFS_DQ_DIRTY 0x0010
89#define XFS_DQ_WANT 0x0020
90#define XFS_DQ_INACTIVE 0x0040
91#define XFS_DQ_MARKER 0x0080
92
93#define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
94
95
96
97
98
99#define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3)
100
101
102
103
104
105
106
107
108
109
110
111
112typedef struct xfs_dq_logformat {
113 __uint16_t qlf_type;
114 __uint16_t qlf_size;
115 xfs_dqid_t qlf_id;
116 __int64_t qlf_blkno;
117 __int32_t qlf_len;
118 __uint32_t qlf_boffset;
119} xfs_dq_logformat_t;
120
121
122
123
124
125
126
127
128
129typedef struct xfs_qoff_logformat {
130 unsigned short qf_type;
131 unsigned short qf_size;
132 unsigned int qf_flags;
133 char qf_pad[12];
134} xfs_qoff_logformat_t;
135
136
137
138
139
140#define XFS_UQUOTA_ACCT 0x0001
141#define XFS_UQUOTA_ENFD 0x0002
142#define XFS_UQUOTA_CHKD 0x0004
143#define XFS_PQUOTA_ACCT 0x0008
144#define XFS_OQUOTA_ENFD 0x0010
145#define XFS_OQUOTA_CHKD 0x0020
146#define XFS_GQUOTA_ACCT 0x0040
147
148
149
150
151#define XFS_ALL_QUOTA_ACCT \
152 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
153#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD)
154#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD)
155
156#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
157#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
158#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
159#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
160#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD)
161#define XFS_IS_OQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD)
162
163
164
165
166
167
168#define XFS_UQUOTA_ACTIVE 0x0100
169#define XFS_PQUOTA_ACTIVE 0x0200
170#define XFS_GQUOTA_ACTIVE 0x0400
171
172
173
174
175
176#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \
177 XFS_GQUOTA_ACTIVE | \
178 XFS_PQUOTA_ACTIVE))
179#define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \
180 XFS_PQUOTA_ACTIVE))
181#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE)
182#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE)
183#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE)
184
185
186
187
188
189
190#define XFS_QMOPT_DQLOCK 0x0000001
191#define XFS_QMOPT_DQALLOC 0x0000002
192#define XFS_QMOPT_UQUOTA 0x0000004
193#define XFS_QMOPT_PQUOTA 0x0000008
194#define XFS_QMOPT_FORCE_RES 0x0000010
195#define XFS_QMOPT_DQSUSER 0x0000020
196#define XFS_QMOPT_SBVERSION 0x0000040
197#define XFS_QMOPT_QUOTAOFF 0x0000080
198#define XFS_QMOPT_UMOUNTING 0x0000100
199#define XFS_QMOPT_DOLOG 0x0000200
200#define XFS_QMOPT_DOWARN 0x0000400
201#define XFS_QMOPT_ILOCKED 0x0000800
202#define XFS_QMOPT_DQREPAIR 0x0001000
203#define XFS_QMOPT_GQUOTA 0x0002000
204#define XFS_QMOPT_ENOSPC 0x0004000
205
206
207
208
209
210#define XFS_QMOPT_RES_REGBLKS 0x0010000
211#define XFS_QMOPT_RES_RTBLKS 0x0020000
212#define XFS_QMOPT_BCOUNT 0x0040000
213#define XFS_QMOPT_ICOUNT 0x0080000
214#define XFS_QMOPT_RTBCOUNT 0x0100000
215#define XFS_QMOPT_DELBCOUNT 0x0200000
216#define XFS_QMOPT_DELRTBCOUNT 0x0400000
217#define XFS_QMOPT_RES_INOS 0x0800000
218
219
220
221
222#define XFS_QMOPT_SYNC 0x1000000
223#define XFS_QMOPT_ASYNC 0x2000000
224#define XFS_QMOPT_DELWRI 0x4000000
225
226
227
228
229#define XFS_QMOPT_INHERIT 0x8000000
230
231
232
233
234#define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS
235#define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS
236#define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS
237#define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT
238#define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT
239#define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT
240#define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT
241#define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
242
243
244#define XFS_QMOPT_QUOTALL \
245 (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
246#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
247
248#ifdef __KERNEL__
249
250
251
252
253
254
255
256
257
258#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\
259 (ip)->i_udquot == NULL) || \
260 (XFS_IS_OQUOTA_ON(mp) && \
261 (ip)->i_gdquot == NULL))
262
263#define XFS_QM_NEED_QUOTACHECK(mp) \
264 ((XFS_IS_UQUOTA_ON(mp) && \
265 (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
266 (XFS_IS_GQUOTA_ON(mp) && \
267 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
268 (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \
269 (XFS_IS_PQUOTA_ON(mp) && \
270 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
271 (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT))))
272
273#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
274 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
275 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
276
277#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
278 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
279 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
280
281#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
282 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
283 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\
284 XFS_GQUOTA_ACCT)
285
286
287
288
289
290
291typedef struct xfs_dqtrx {
292 struct xfs_dquot *qt_dquot;
293 ulong qt_blk_res;
294 ulong qt_blk_res_used;
295 ulong qt_ino_res;
296 ulong qt_ino_res_used;
297 long qt_bcount_delta;
298 long qt_delbcnt_delta;
299 long qt_icount_delta;
300 ulong qt_rtblk_res;
301 ulong qt_rtblk_res_used;
302 long qt_rtbcount_delta;
303 long qt_delrtb_delta;
304} xfs_dqtrx_t;
305
306
307
308
309typedef void (*qo_dup_dqinfo_t)(struct xfs_trans *, struct xfs_trans *);
310typedef void (*qo_mod_dquot_byino_t)(struct xfs_trans *,
311 struct xfs_inode *, uint, long);
312typedef void (*qo_free_dqinfo_t)(struct xfs_trans *);
313typedef void (*qo_apply_dquot_deltas_t)(struct xfs_trans *);
314typedef void (*qo_unreserve_and_mod_dquots_t)(struct xfs_trans *);
315typedef int (*qo_reserve_quota_nblks_t)(
316 struct xfs_trans *, struct xfs_mount *,
317 struct xfs_inode *, long, long, uint);
318typedef int (*qo_reserve_quota_bydquots_t)(
319 struct xfs_trans *, struct xfs_mount *,
320 struct xfs_dquot *, struct xfs_dquot *,
321 long, long, uint);
322typedef struct xfs_dqtrxops {
323 qo_dup_dqinfo_t qo_dup_dqinfo;
324 qo_free_dqinfo_t qo_free_dqinfo;
325 qo_mod_dquot_byino_t qo_mod_dquot_byino;
326 qo_apply_dquot_deltas_t qo_apply_dquot_deltas;
327 qo_reserve_quota_nblks_t qo_reserve_quota_nblks;
328 qo_reserve_quota_bydquots_t qo_reserve_quota_bydquots;
329 qo_unreserve_and_mod_dquots_t qo_unreserve_and_mod_dquots;
330} xfs_dqtrxops_t;
331
332#define XFS_DQTRXOP(mp, tp, op, args...) \
333 ((mp)->m_qm_ops->xfs_dqtrxops ? \
334 ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : 0)
335
336#define XFS_DQTRXOP_VOID(mp, tp, op, args...) \
337 ((mp)->m_qm_ops->xfs_dqtrxops ? \
338 ((mp)->m_qm_ops->xfs_dqtrxops->op)(tp, ## args) : (void)0)
339
340#define XFS_TRANS_DUP_DQINFO(mp, otp, ntp) \
341 XFS_DQTRXOP_VOID(mp, otp, qo_dup_dqinfo, ntp)
342#define XFS_TRANS_FREE_DQINFO(mp, tp) \
343 XFS_DQTRXOP_VOID(mp, tp, qo_free_dqinfo)
344#define XFS_TRANS_MOD_DQUOT_BYINO(mp, tp, ip, field, delta) \
345 XFS_DQTRXOP_VOID(mp, tp, qo_mod_dquot_byino, ip, field, delta)
346#define XFS_TRANS_APPLY_DQUOT_DELTAS(mp, tp) \
347 XFS_DQTRXOP_VOID(mp, tp, qo_apply_dquot_deltas)
348#define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, fl) \
349 XFS_DQTRXOP(mp, tp, qo_reserve_quota_nblks, mp, ip, nblks, ninos, fl)
350#define XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, fl) \
351 XFS_DQTRXOP(mp, tp, qo_reserve_quota_bydquots, mp, ud, gd, nb, ni, fl)
352#define XFS_TRANS_UNRESERVE_AND_MOD_DQUOTS(mp, tp) \
353 XFS_DQTRXOP_VOID(mp, tp, qo_unreserve_and_mod_dquots)
354
355#define XFS_TRANS_UNRESERVE_QUOTA_NBLKS(mp, tp, ip, nblks, ninos, flags) \
356 XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, tp, ip, -(nblks), -(ninos), flags)
357#define XFS_TRANS_RESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \
358 XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, nb, ni, \
359 f | XFS_QMOPT_RES_REGBLKS)
360#define XFS_TRANS_UNRESERVE_QUOTA(mp, tp, ud, gd, nb, ni, f) \
361 XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp, ud, gd, -(nb), -(ni), \
362 f | XFS_QMOPT_RES_REGBLKS)
363
364extern int xfs_qm_dqcheck(xfs_disk_dquot_t *, xfs_dqid_t, uint, uint, char *);
365extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
366
367extern struct xfs_qmops xfs_qmcore_xfs;
368
369#endif
370
371#endif
372