blob: c3483bab9cde162f87e069af51f24c19ecbbb005 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * 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 Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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 Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_QUOTA_H__
19#define __XFS_QUOTA_H__
20
Christoph Hellwigfcafb712009-02-09 08:47:34 +010021struct xfs_trans;
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023/*
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 Scottc310ab62005-11-02 10:31:41 +110033typedef __uint32_t xfs_dqid_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35/*
Nathan Scottc41564b2006-03-29 08:55:14 +100036 * Even though users may not have quota limits occupying all 64-bits,
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 * 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 */
40typedef __uint64_t xfs_qcnt_t;
41typedef __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 */
49typedef struct xfs_disk_dquot {
Christoph Hellwig1149d962005-11-02 15:01:12 +110050 __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 Torvalds1da177e2005-04-16 15:20:36 -070061 this is when we refuse service */
Christoph Hellwig1149d962005-11-02 15:01:12 +110062 __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 Torvalds1da177e2005-04-16 15:20:36 -070072} 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 */
78typedef struct xfs_dqblk {
79 xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */
Christoph Hellwig3fe58f32013-04-03 16:11:16 +110080 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 Torvalds1da177e2005-04-16 15:20:36 -070088} xfs_dqblk_t;
89
Dave Chinner6fcdc592013-06-03 15:28:46 +100090#define XFS_DQUOT_CRC_OFF offsetof(struct xfs_dqblk, dd_crc)
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092/*
93 * flags for q_flags field in the dquot.
94 */
95#define XFS_DQ_USER 0x0001 /* a user quota */
Nathan Scottc8ad20f2005-06-21 15:38:48 +100096#define XFS_DQ_PROJ 0x0002 /* project quota */
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#define XFS_DQ_GROUP 0x0004 /* a group quota */
Christoph Hellwigdf6771b2008-12-03 12:20:30 +010098#define XFS_DQ_DIRTY 0x0008 /* dquot is dirty */
Christoph Hellwig92678552011-12-06 21:58:18 +000099#define XFS_DQ_FREEING 0x0010 /* dquot is beeing torn down */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000101#define XFS_DQ_ALLTYPES (XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
102
Christoph Hellwig0b1b2132009-12-14 23:14:59 +0000103#define XFS_DQ_FLAGS \
104 { XFS_DQ_USER, "USER" }, \
105 { XFS_DQ_PROJ, "PROJ" }, \
106 { XFS_DQ_GROUP, "GROUP" }, \
Christoph Hellwig92678552011-12-06 21:58:18 +0000107 { XFS_DQ_DIRTY, "DIRTY" }, \
108 { XFS_DQ_FREEING, "FREEING" }
Christoph Hellwig0b1b2132009-12-14 23:14:59 +0000109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/*
111 * In the worst case, when both user and group quotas are on,
112 * we can have a max of three dquots changing in a single transaction.
113 */
114#define XFS_DQUOT_LOGRES(mp) (sizeof(xfs_disk_dquot_t) * 3)
115
116
117/*
118 * These are the structures used to lay out dquots and quotaoff
119 * records on the log. Quite similar to those of inodes.
120 */
121
122/*
123 * log format struct for dquots.
124 * The first two fields must be the type and size fitting into
125 * 32 bits : log_recovery code assumes that.
126 */
127typedef struct xfs_dq_logformat {
128 __uint16_t qlf_type; /* dquot log item type */
129 __uint16_t qlf_size; /* size of this item */
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000130 xfs_dqid_t qlf_id; /* usr/grp/proj id : 32 bits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 __int64_t qlf_blkno; /* blkno of dquot buffer */
132 __int32_t qlf_len; /* len of dquot buffer */
133 __uint32_t qlf_boffset; /* off of dquot in buffer */
134} xfs_dq_logformat_t;
135
136/*
137 * log format struct for QUOTAOFF records.
138 * The first two fields must be the type and size fitting into
139 * 32 bits : log_recovery code assumes that.
140 * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer
141 * to the first and ensures that the first logitem is taken out of the AIL
142 * only when the last one is securely committed.
143 */
144typedef struct xfs_qoff_logformat {
145 unsigned short qf_type; /* quotaoff log item type */
146 unsigned short qf_size; /* size of this item */
147 unsigned int qf_flags; /* USR and/or GRP */
148 char qf_pad[12]; /* padding for future */
149} xfs_qoff_logformat_t;
150
151
152/*
153 * Disk quotas status in m_qflags, and also sb_qflags. 16 bits.
154 */
155#define XFS_UQUOTA_ACCT 0x0001 /* user quota accounting ON */
156#define XFS_UQUOTA_ENFD 0x0002 /* user quota limits enforced */
157#define XFS_UQUOTA_CHKD 0x0004 /* quotacheck run on usr quotas */
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000158#define XFS_PQUOTA_ACCT 0x0008 /* project quota accounting ON */
159#define XFS_OQUOTA_ENFD 0x0010 /* other (grp/prj) quota limits enforced */
160#define XFS_OQUOTA_CHKD 0x0020 /* quotacheck run on other (grp/prj) quotas */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161#define XFS_GQUOTA_ACCT 0x0040 /* group quota accounting ON */
162
163/*
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500164 * Conversion to and from the combined OQUOTA flag (if necessary)
165 * is done only in xfs_sb_qflags_to_disk() and xfs_sb_qflags_from_disk()
166 */
167#define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */
168#define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */
169#define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */
170#define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */
171
172/*
Tim Shimmin4cd4a032005-09-05 08:24:10 +1000173 * Quota Accounting/Enforcement flags
174 */
175#define XFS_ALL_QUOTA_ACCT \
176 (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500177#define XFS_ALL_QUOTA_ENFD \
178 (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD)
179#define XFS_ALL_QUOTA_CHKD \
180 (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)
Tim Shimmin4cd4a032005-09-05 08:24:10 +1000181
182#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
Tim Shimmin4cd4a032005-09-05 08:24:10 +1000183#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
184#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
185#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
Kouta Ooizumie6d29422007-05-08 13:49:33 +1000186#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD)
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500187#define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)
188#define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD)
Tim Shimmin4cd4a032005-09-05 08:24:10 +1000189
190/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 * Incore only flags for quotaoff - these bits get cleared when quota(s)
192 * are in the process of getting turned off. These flags are in m_qflags but
193 * never in sb_qflags.
194 */
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500195#define XFS_UQUOTA_ACTIVE 0x1000 /* uquotas are being turned off */
196#define XFS_GQUOTA_ACTIVE 0x2000 /* gquotas are being turned off */
197#define XFS_PQUOTA_ACTIVE 0x4000 /* pquotas are being turned off */
Chandra Seetharaman4177af32012-01-23 17:31:43 +0000198#define XFS_ALL_QUOTA_ACTIVE \
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500199 (XFS_UQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201/*
202 * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees
203 * quota will be not be switched off as long as that inode lock is held.
204 */
205#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000206 XFS_GQUOTA_ACTIVE | \
207 XFS_PQUOTA_ACTIVE))
208#define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \
209 XFS_PQUOTA_ACTIVE))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE)
211#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE)
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000212#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213
214/*
215 * Flags to tell various functions what to do. Not all of these are meaningful
216 * to a single function. None of these XFS_QMOPT_* flags are meant to have
217 * persistent values (ie. their values can and will change between versions)
218 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219#define XFS_QMOPT_DQALLOC 0x0000002 /* alloc dquot ondisk if needed */
220#define XFS_QMOPT_UQUOTA 0x0000004 /* user dquot requested */
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000221#define XFS_QMOPT_PQUOTA 0x0000008 /* project dquot requested */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222#define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223#define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000224#define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000225#define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000226#define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */
Nathan Scott9a2a7de2006-03-31 13:04:49 +1000227#define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229/*
230 * flags to xfs_trans_mod_dquot to indicate which field needs to be
231 * modified.
232 */
233#define XFS_QMOPT_RES_REGBLKS 0x0010000
234#define XFS_QMOPT_RES_RTBLKS 0x0020000
235#define XFS_QMOPT_BCOUNT 0x0040000
236#define XFS_QMOPT_ICOUNT 0x0080000
237#define XFS_QMOPT_RTBCOUNT 0x0100000
238#define XFS_QMOPT_DELBCOUNT 0x0200000
239#define XFS_QMOPT_DELRTBCOUNT 0x0400000
240#define XFS_QMOPT_RES_INOS 0x0800000
241
242/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 * flags for dqalloc.
244 */
Dave Chinner20026d92010-02-04 09:48:58 +1100245#define XFS_QMOPT_INHERIT 0x1000000
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
247/*
248 * flags to xfs_trans_mod_dquot.
249 */
250#define XFS_TRANS_DQ_RES_BLKS XFS_QMOPT_RES_REGBLKS
251#define XFS_TRANS_DQ_RES_RTBLKS XFS_QMOPT_RES_RTBLKS
252#define XFS_TRANS_DQ_RES_INOS XFS_QMOPT_RES_INOS
253#define XFS_TRANS_DQ_BCOUNT XFS_QMOPT_BCOUNT
254#define XFS_TRANS_DQ_DELBCOUNT XFS_QMOPT_DELBCOUNT
255#define XFS_TRANS_DQ_ICOUNT XFS_QMOPT_ICOUNT
256#define XFS_TRANS_DQ_RTBCOUNT XFS_QMOPT_RTBCOUNT
257#define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
258
259
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000260#define XFS_QMOPT_QUOTALL \
261 (XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262#define XFS_QMOPT_RESBLK_MASK (XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
263
264#ifdef __KERNEL__
265/*
266 * This check is done typically without holding the inode lock;
Nathan Scottc41564b2006-03-29 08:55:14 +1000267 * that may seem racy, but it is harmless in the context that it is used.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 * The inode cannot go inactive as long a reference is kept, and
269 * therefore if dquot(s) were attached, they'll stay consistent.
270 * If, for example, the ownership of the inode changes while
271 * we didn't have the inode locked, the appropriate dquot(s) will be
272 * attached atomically.
273 */
274#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\
275 (ip)->i_udquot == NULL) || \
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000276 (XFS_IS_OQUOTA_ON(mp) && \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 (ip)->i_gdquot == NULL))
278
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000279#define XFS_QM_NEED_QUOTACHECK(mp) \
280 ((XFS_IS_UQUOTA_ON(mp) && \
281 (mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
282 (XFS_IS_GQUOTA_ON(mp) && \
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500283 (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000284 (XFS_IS_PQUOTA_ON(mp) && \
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500285 (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000286
287#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500288 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
289 XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD)
Nathan Scottc8ad20f2005-06-21 15:38:48 +1000290
291#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500292 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
293 XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
295#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
Chandra Seetharaman83e782e2013-06-27 17:25:10 -0500296 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
297 XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD|\
298 XFS_PQUOTA_ACCT|XFS_PQUOTA_ENFD|\
299 XFS_PQUOTA_CHKD)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300
301
302/*
303 * The structure kept inside the xfs_trans_t keep track of dquot changes
304 * within a transaction and apply them later.
305 */
306typedef struct xfs_dqtrx {
307 struct xfs_dquot *qt_dquot; /* the dquot this refers to */
308 ulong qt_blk_res; /* blks reserved on a dquot */
309 ulong qt_blk_res_used; /* blks used from the reservation */
310 ulong qt_ino_res; /* inode reserved on a dquot */
311 ulong qt_ino_res_used; /* inodes used from the reservation */
312 long qt_bcount_delta; /* dquot blk count changes */
313 long qt_delbcnt_delta; /* delayed dquot blk count changes */
314 long qt_icount_delta; /* dquot inode count changes */
315 ulong qt_rtblk_res; /* # blks reserved on a dquot */
316 ulong qt_rtblk_res_used;/* # blks used from reservation */
317 long qt_rtbcount_delta;/* dquot realtime blk changes */
318 long qt_delrtb_delta; /* delayed RT blk count changes */
319} xfs_dqtrx_t;
320
Christoph Hellwig7d095252009-06-08 15:33:32 +0200321#ifdef CONFIG_XFS_QUOTA
322extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *);
323extern void xfs_trans_free_dqinfo(struct xfs_trans *);
324extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *,
325 uint, long);
326extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *);
327extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *);
328extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
329 struct xfs_inode *, long, long, uint);
330extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
331 struct xfs_mount *, struct xfs_dquot *,
332 struct xfs_dquot *, long, long, uint);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
Christoph Hellwig7d095252009-06-08 15:33:32 +0200334extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint,
335 struct xfs_dquot **, struct xfs_dquot **);
336extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
337 struct xfs_dquot *, struct xfs_dquot *);
338extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
339extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *,
340 struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *);
341extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *,
342 struct xfs_dquot *, struct xfs_dquot *, uint);
343extern int xfs_qm_dqattach(struct xfs_inode *, uint);
344extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint);
345extern void xfs_qm_dqdetach(struct xfs_inode *);
346extern void xfs_qm_dqrele(struct xfs_dquot *);
347extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *);
Christoph Hellwig7d095252009-06-08 15:33:32 +0200348extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *);
349extern void xfs_qm_mount_quotas(struct xfs_mount *);
350extern void xfs_qm_unmount(struct xfs_mount *);
351extern void xfs_qm_unmount_quotas(struct xfs_mount *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
Christoph Hellwig7d095252009-06-08 15:33:32 +0200353#else
Christoph Hellwig493b87e2009-06-12 11:34:55 -0400354static inline int
355xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid,
356 uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp)
357{
358 *udqp = NULL;
359 *gdqp = NULL;
360 return 0;
361}
Christoph Hellwig7d095252009-06-08 15:33:32 +0200362#define xfs_trans_dup_dqinfo(tp, tp2)
363#define xfs_trans_free_dqinfo(tp)
364#define xfs_trans_mod_dquot_byino(tp, ip, fields, delta)
365#define xfs_trans_apply_dquot_deltas(tp)
366#define xfs_trans_unreserve_and_mod_dquots(tp)
Christoph Hellwig5d2bf8a2010-11-06 11:42:56 +0000367static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
368 struct xfs_inode *ip, long nblks, long ninos, uint flags)
369{
370 return 0;
371}
372static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
373 struct xfs_mount *mp, struct xfs_dquot *udqp,
374 struct xfs_dquot *gdqp, long nblks, long nions, uint flags)
375{
376 return 0;
377}
Christoph Hellwig7d095252009-06-08 15:33:32 +0200378#define xfs_qm_vop_create_dqattach(tp, ip, u, g)
379#define xfs_qm_vop_rename_dqattach(it) (0)
380#define xfs_qm_vop_chown(tp, ip, old, new) (NULL)
381#define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl) (0)
382#define xfs_qm_dqattach(ip, fl) (0)
383#define xfs_qm_dqattach_locked(ip, fl) (0)
384#define xfs_qm_dqdetach(ip)
385#define xfs_qm_dqrele(d)
386#define xfs_qm_statvfs(ip, s)
Christoph Hellwig7d095252009-06-08 15:33:32 +0200387#define xfs_qm_newmount(mp, a, b) (0)
388#define xfs_qm_mount_quotas(mp)
389#define xfs_qm_unmount(mp)
Christoph Hellwig5d2bf8a2010-11-06 11:42:56 +0000390#define xfs_qm_unmount_quotas(mp)
Christoph Hellwig7d095252009-06-08 15:33:32 +0200391#endif /* CONFIG_XFS_QUOTA */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Christoph Hellwig7d095252009-06-08 15:33:32 +0200393#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
394 xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
395#define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \
396 xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 f | XFS_QMOPT_RES_REGBLKS)
398
Dave Chinnera0fa2b62011-03-07 10:01:35 +1100399extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *,
400 xfs_dqid_t, uint, uint, char *);
Tim Shimmin4cd4a032005-09-05 08:24:10 +1000401extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402
Christoph Hellwig3fe58f32013-04-03 16:11:16 +1100403extern const struct xfs_buf_ops xfs_dquot_buf_ops;
404
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405#endif /* __KERNEL__ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406#endif /* __XFS_QUOTA_H__ */