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
21struct xfs_trans;
22
23
24
25
26#define XFS_DQUOT_MAGIC 0x4451
27#define XFS_DQUOT_VERSION (u_int8_t)0x01
28
29
30
31
32
33typedef __uint32_t xfs_dqid_t;
34
35
36
37
38
39
40typedef __uint64_t xfs_qcnt_t;
41typedef __uint16_t xfs_qwarncnt_t;
42
43
44
45
46
47
48
49typedef struct xfs_disk_dquot {
50 __be16 d_magic;
51 __u8 d_version;
52 __u8 d_flags;
53 __be32 d_id;
54 __be64 d_blk_hardlimit;
55 __be64 d_blk_softlimit;
56 __be64 d_ino_hardlimit;
57 __be64 d_ino_softlimit;
58 __be64 d_bcount;
59 __be64 d_icount;
60 __be32 d_itimer;
61
62 __be32 d_btimer;
63 __be16 d_iwarns;
64 __be16 d_bwarns;
65 __be32 d_pad0;
66 __be64 d_rtb_hardlimit;
67 __be64 d_rtb_softlimit;
68 __be64 d_rtbcount;
69 __be32 d_rtbtimer;
70 __be16 d_rtbwarns;
71 __be16 d_pad;
72} xfs_disk_dquot_t;
73
74
75
76
77
78typedef struct xfs_dqblk {
79 xfs_disk_dquot_t dd_diskdq;
80 char dd_fill[32];
81} xfs_dqblk_t;
82
83
84
85
86#define XFS_DQ_USER 0x0001
87#define XFS_DQ_PROJ 0x0002
88#define XFS_DQ_GROUP 0x0004
89#define XFS_DQ_DIRTY 0x0008
90#define XFS_DQ_FREEING 0x0010
91
92#define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
93
94#define XFS_DQ_FLAGS \
95 { XFS_DQ_USER, "USER" }, \
96 { XFS_DQ_PROJ, "PROJ" }, \
97 { XFS_DQ_GROUP, "GROUP" }, \
98 { XFS_DQ_DIRTY, "DIRTY" }, \
99 { XFS_DQ_FREEING, "FREEING" }
100
101
102
103
104
105#define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3)
106
107
108
109
110
111
112
113
114
115
116
117
118typedef struct xfs_dq_logformat {
119 __uint16_t qlf_type;
120 __uint16_t qlf_size;
121 xfs_dqid_t qlf_id;
122 __int64_t qlf_blkno;
123 __int32_t qlf_len;
124 __uint32_t qlf_boffset;
125} xfs_dq_logformat_t;
126
127
128
129
130
131
132
133
134
135typedef struct xfs_qoff_logformat {
136 unsigned short qf_type;
137 unsigned short qf_size;
138 unsigned int qf_flags;
139 char qf_pad[12];
140} xfs_qoff_logformat_t;
141
142
143
144
145
146#define XFS_UQUOTA_ACCT 0x0001
147#define XFS_UQUOTA_ENFD 0x0002
148#define XFS_UQUOTA_CHKD 0x0004
149#define XFS_PQUOTA_ACCT 0x0008
150#define XFS_OQUOTA_ENFD 0x0010
151#define XFS_OQUOTA_CHKD 0x0020
152#define XFS_GQUOTA_ACCT 0x0040
153
154
155
156
157#define XFS_ALL_QUOTA_ACCT \
158 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
159#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD)
160#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD)
161
162#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
163#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
164#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
165#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
166#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD)
167#define XFS_IS_OQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD)
168
169
170
171
172
173
174#define XFS_UQUOTA_ACTIVE 0x0100
175#define XFS_PQUOTA_ACTIVE 0x0200
176#define XFS_GQUOTA_ACTIVE 0x0400
177#define XFS_ALL_QUOTA_ACTIVE \
178 (XFS_UQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE)
179
180
181
182
183
184#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \
185 XFS_GQUOTA_ACTIVE | \
186 XFS_PQUOTA_ACTIVE))
187#define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \
188 XFS_PQUOTA_ACTIVE))
189#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE)
190#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE)
191#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE)
192
193
194
195
196
197
198#define XFS_QMOPT_DQALLOC 0x0000002
199#define XFS_QMOPT_UQUOTA 0x0000004
200#define XFS_QMOPT_PQUOTA 0x0000008
201#define XFS_QMOPT_FORCE_RES 0x0000010
202#define XFS_QMOPT_SBVERSION 0x0000040
203#define XFS_QMOPT_DOWARN 0x0000400
204#define XFS_QMOPT_DQREPAIR 0x0001000
205#define XFS_QMOPT_GQUOTA 0x0002000
206#define XFS_QMOPT_ENOSPC 0x0004000
207
208
209
210
211
212#define XFS_QMOPT_RES_REGBLKS 0x0010000
213#define XFS_QMOPT_RES_RTBLKS 0x0020000
214#define XFS_QMOPT_BCOUNT 0x0040000
215#define XFS_QMOPT_ICOUNT 0x0080000
216#define XFS_QMOPT_RTBCOUNT 0x0100000
217#define XFS_QMOPT_DELBCOUNT 0x0200000
218#define XFS_QMOPT_DELRTBCOUNT 0x0400000
219#define XFS_QMOPT_RES_INOS 0x0800000
220
221
222
223
224#define XFS_QMOPT_INHERIT 0x1000000
225
226
227
228
229#define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS
230#define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS
231#define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS
232#define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT
233#define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT
234#define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT
235#define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT
236#define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
237
238
239#define XFS_QMOPT_QUOTALL \
240 (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
241#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
242
243#ifdef __KERNEL__
244
245
246
247
248
249
250
251
252
253#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\
254 (ip)->i_udquot == NULL) || \
255 (XFS_IS_OQUOTA_ON(mp) && \
256 (ip)->i_gdquot == NULL))
257
258#define XFS_QM_NEED_QUOTACHECK(mp) \
259 ((XFS_IS_UQUOTA_ON(mp) && \
260 (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
261 (XFS_IS_GQUOTA_ON(mp) && \
262 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
263 (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \
264 (XFS_IS_PQUOTA_ON(mp) && \
265 ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
266 (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT))))
267
268#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
269 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
270 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
271
272#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
273 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
274 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
275
276#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
277 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
278 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\
279 XFS_GQUOTA_ACCT)
280
281
282
283
284
285
286typedef struct xfs_dqtrx {
287 struct xfs_dquot *qt_dquot;
288 ulong qt_blk_res;
289 ulong qt_blk_res_used;
290 ulong qt_ino_res;
291 ulong qt_ino_res_used;
292 long qt_bcount_delta;
293 long qt_delbcnt_delta;
294 long qt_icount_delta;
295 ulong qt_rtblk_res;
296 ulong qt_rtblk_res_used;
297 long qt_rtbcount_delta;
298 long qt_delrtb_delta;
299} xfs_dqtrx_t;
300
301#ifdef CONFIG_XFS_QUOTA
302extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *);
303extern void xfs_trans_free_dqinfo(struct xfs_trans *);
304extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *,
305 uint, long);
306extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *);
307extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *);
308extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
309 struct xfs_inode *, long, long, uint);
310extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
311 struct xfs_mount *, struct xfs_dquot *,
312 struct xfs_dquot *, long, long, uint);
313
314extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint,
315 struct xfs_dquot **, struct xfs_dquot **);
316extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
317 struct xfs_dquot *, struct xfs_dquot *);
318extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
319extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *,
320 struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *);
321extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *,
322 struct xfs_dquot *, struct xfs_dquot *, uint);
323extern int xfs_qm_dqattach(struct xfs_inode *, uint);
324extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint);
325extern void xfs_qm_dqdetach(struct xfs_inode *);
326extern void xfs_qm_dqrele(struct xfs_dquot *);
327extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *);
328extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *);
329extern void xfs_qm_mount_quotas(struct xfs_mount *);
330extern void xfs_qm_unmount(struct xfs_mount *);
331extern void xfs_qm_unmount_quotas(struct xfs_mount *);
332
333#else
334static inline int
335xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid,
336 uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp)
337{
338 *udqp = NULL;
339 *gdqp = NULL;
340 return 0;
341}
342#define xfs_trans_dup_dqinfo(tp, tp2)
343#define xfs_trans_free_dqinfo(tp)
344#define xfs_trans_mod_dquot_byino(tp, ip, fields, delta)
345#define xfs_trans_apply_dquot_deltas(tp)
346#define xfs_trans_unreserve_and_mod_dquots(tp)
347static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
348 struct xfs_inode *ip, long nblks, long ninos, uint flags)
349{
350 return 0;
351}
352static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
353 struct xfs_mount *mp, struct xfs_dquot *udqp,
354 struct xfs_dquot *gdqp, long nblks, long nions, uint flags)
355{
356 return 0;
357}
358#define xfs_qm_vop_create_dqattach(tp, ip, u, g)
359#define xfs_qm_vop_rename_dqattach(it) (0)
360#define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
361#define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0)
362#define xfs_qm_dqattach(ip, fl) (0)
363#define xfs_qm_dqattach_locked(ip, fl) (0)
364#define xfs_qm_dqdetach(ip)
365#define xfs_qm_dqrele(d)
366#define xfs_qm_statvfs(ip, s)
367#define xfs_qm_newmount(mp, a, b) (0)
368#define xfs_qm_mount_quotas(mp)
369#define xfs_qm_unmount(mp)
370#define xfs_qm_unmount_quotas(mp)
371#endif
372
373#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
374 xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
375#define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \
376 xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \
377 f | XFS_QMOPT_RES_REGBLKS)
378
379extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *,
380 xfs_dqid_t, uint, uint, char *);
381extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
382
383#endif
384#endif
385