Linux Audio

Check our new training course

Loading...
v3.1
 
  1/*
  2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3 * All Rights Reserved.
  4 *
  5 * This program is free software; you can redistribute it and/or
  6 * modify it under the terms of the GNU General Public License as
  7 * published by the Free Software Foundation.
  8 *
  9 * 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.
 13 *
 14 * 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
 17 */
 18#ifndef __XFS_QUOTA_H__
 19#define __XFS_QUOTA_H__
 20
 21struct xfs_trans;
 22
 23/*
 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 */
 33typedef __uint32_t	xfs_dqid_t;
 34
 35/*
 36 * Even though users may not have quota limits occupying all 64-bits,
 37 * 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 {
 50	__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,
 61					   this is when we refuse service */
 62	__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;
 72} 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 */
 80	char		  dd_fill[32];	/* filling for posterity */
 81} xfs_dqblk_t;
 82
 83/*
 84 * flags for q_flags field in the dquot.
 85 */
 86#define XFS_DQ_USER		0x0001		/* a user quota */
 87#define XFS_DQ_PROJ		0x0002		/* project quota */
 88#define XFS_DQ_GROUP		0x0004		/* a group quota */
 89#define XFS_DQ_DIRTY		0x0008		/* dquot is dirty */
 90#define XFS_DQ_WANT		0x0010		/* for lookup/reclaim race */
 91#define XFS_DQ_INACTIVE		0x0020		/* dq off mplist & hashlist */
 92
 93#define XFS_DQ_ALLTYPES		(XFS_DQ_USER|XFS_DQ_PROJ|XFS_DQ_GROUP)
 94
 95#define XFS_DQ_FLAGS \
 96	{ XFS_DQ_USER,		"USER" }, \
 97	{ XFS_DQ_PROJ,		"PROJ" }, \
 98	{ XFS_DQ_GROUP,		"GROUP" }, \
 99	{ XFS_DQ_DIRTY,		"DIRTY" }, \
100	{ XFS_DQ_WANT,		"WANT" }, \
101	{ XFS_DQ_INACTIVE,	"INACTIVE" }
102
103/*
104 * In the worst case, when both user and group quotas are on,
105 * we can have a max of three dquots changing in a single transaction.
106 */
107#define XFS_DQUOT_LOGRES(mp)	(sizeof(xfs_disk_dquot_t) * 3)
108
109
110/*
111 * These are the structures used to lay out dquots and quotaoff
112 * records on the log. Quite similar to those of inodes.
113 */
114
115/*
116 * log format struct for dquots.
117 * The first two fields must be the type and size fitting into
118 * 32 bits : log_recovery code assumes that.
119 */
120typedef struct xfs_dq_logformat {
121	__uint16_t		qlf_type;      /* dquot log item type */
122	__uint16_t		qlf_size;      /* size of this item */
123	xfs_dqid_t		qlf_id;	       /* usr/grp/proj id : 32 bits */
124	__int64_t		qlf_blkno;     /* blkno of dquot buffer */
125	__int32_t		qlf_len;       /* len of dquot buffer */
126	__uint32_t		qlf_boffset;   /* off of dquot in buffer */
127} xfs_dq_logformat_t;
128
129/*
130 * log format struct for QUOTAOFF records.
131 * The first two fields must be the type and size fitting into
132 * 32 bits : log_recovery code assumes that.
133 * We write two LI_QUOTAOFF logitems per quotaoff, the last one keeps a pointer
134 * to the first and ensures that the first logitem is taken out of the AIL
135 * only when the last one is securely committed.
136 */
137typedef struct xfs_qoff_logformat {
138	unsigned short		qf_type;	/* quotaoff log item type */
139	unsigned short		qf_size;	/* size of this item */
140	unsigned int		qf_flags;	/* USR and/or GRP */
141	char			qf_pad[12];	/* padding for future */
142} xfs_qoff_logformat_t;
143
144
145/*
146 * Disk quotas status in m_qflags, and also sb_qflags. 16 bits.
147 */
148#define XFS_UQUOTA_ACCT	0x0001  /* user quota accounting ON */
149#define XFS_UQUOTA_ENFD	0x0002  /* user quota limits enforced */
150#define XFS_UQUOTA_CHKD	0x0004  /* quotacheck run on usr quotas */
151#define XFS_PQUOTA_ACCT	0x0008  /* project quota accounting ON */
152#define XFS_OQUOTA_ENFD	0x0010  /* other (grp/prj) quota limits enforced */
153#define XFS_OQUOTA_CHKD	0x0020  /* quotacheck run on other (grp/prj) quotas */
154#define XFS_GQUOTA_ACCT	0x0040  /* group quota accounting ON */
155
156/*
157 * Quota Accounting/Enforcement flags
158 */
159#define XFS_ALL_QUOTA_ACCT	\
160		(XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
161#define XFS_ALL_QUOTA_ENFD	(XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD)
162#define XFS_ALL_QUOTA_CHKD	(XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD)
163
164#define XFS_IS_QUOTA_RUNNING(mp)	((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
165#define XFS_IS_UQUOTA_RUNNING(mp)	((mp)->m_qflags & XFS_UQUOTA_ACCT)
166#define XFS_IS_PQUOTA_RUNNING(mp)	((mp)->m_qflags & XFS_PQUOTA_ACCT)
167#define XFS_IS_GQUOTA_RUNNING(mp)	((mp)->m_qflags & XFS_GQUOTA_ACCT)
168#define XFS_IS_UQUOTA_ENFORCED(mp)	((mp)->m_qflags & XFS_UQUOTA_ENFD)
169#define XFS_IS_OQUOTA_ENFORCED(mp)	((mp)->m_qflags & XFS_OQUOTA_ENFD)
170
171/*
172 * Incore only flags for quotaoff - these bits get cleared when quota(s)
173 * are in the process of getting turned off. These flags are in m_qflags but
174 * never in sb_qflags.
175 */
176#define XFS_UQUOTA_ACTIVE	0x0100  /* uquotas are being turned off */
177#define XFS_PQUOTA_ACTIVE	0x0200  /* pquotas are being turned off */
178#define XFS_GQUOTA_ACTIVE	0x0400  /* gquotas are being turned off */
179
180/*
181 * Checking XFS_IS_*QUOTA_ON() while holding any inode lock guarantees
182 * quota will be not be switched off as long as that inode lock is held.
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 * Flags to tell various functions what to do. Not all of these are meaningful
195 * to a single function. None of these XFS_QMOPT_* flags are meant to have
196 * persistent values (ie. their values can and will change between versions)
197 */
198#define XFS_QMOPT_DQALLOC	0x0000002 /* alloc dquot ondisk if needed */
199#define XFS_QMOPT_UQUOTA	0x0000004 /* user dquot requested */
200#define XFS_QMOPT_PQUOTA	0x0000008 /* project dquot requested */
201#define XFS_QMOPT_FORCE_RES	0x0000010 /* ignore quota limits */
202#define XFS_QMOPT_DQSUSER	0x0000020 /* don't cache super users dquot */
203#define XFS_QMOPT_SBVERSION	0x0000040 /* change superblock version num */
204#define XFS_QMOPT_DOWARN        0x0000400 /* increase warning cnt if needed */
205#define XFS_QMOPT_DQREPAIR	0x0001000 /* repair dquot if damaged */
206#define XFS_QMOPT_GQUOTA	0x0002000 /* group dquot requested */
207#define XFS_QMOPT_ENOSPC	0x0004000 /* enospc instead of edquot (prj) */
208
209/*
210 * flags to xfs_trans_mod_dquot to indicate which field needs to be
211 * modified.
212 */
213#define XFS_QMOPT_RES_REGBLKS	0x0010000
214#define XFS_QMOPT_RES_RTBLKS	0x0020000
215#define XFS_QMOPT_BCOUNT	0x0040000
216#define XFS_QMOPT_ICOUNT	0x0080000
217#define XFS_QMOPT_RTBCOUNT	0x0100000
218#define XFS_QMOPT_DELBCOUNT	0x0200000
219#define XFS_QMOPT_DELRTBCOUNT	0x0400000
220#define XFS_QMOPT_RES_INOS	0x0800000
221
222/*
223 * flags for dqalloc.
224 */
225#define XFS_QMOPT_INHERIT	0x1000000
226
227/*
228 * flags to xfs_trans_mod_dquot.
229 */
230#define XFS_TRANS_DQ_RES_BLKS	XFS_QMOPT_RES_REGBLKS
231#define XFS_TRANS_DQ_RES_RTBLKS	XFS_QMOPT_RES_RTBLKS
232#define XFS_TRANS_DQ_RES_INOS	XFS_QMOPT_RES_INOS
233#define XFS_TRANS_DQ_BCOUNT	XFS_QMOPT_BCOUNT
234#define XFS_TRANS_DQ_DELBCOUNT	XFS_QMOPT_DELBCOUNT
235#define XFS_TRANS_DQ_ICOUNT	XFS_QMOPT_ICOUNT
236#define XFS_TRANS_DQ_RTBCOUNT	XFS_QMOPT_RTBCOUNT
237#define XFS_TRANS_DQ_DELRTBCOUNT XFS_QMOPT_DELRTBCOUNT
238
239
240#define XFS_QMOPT_QUOTALL	\
241		(XFS_QMOPT_UQUOTA | XFS_QMOPT_PQUOTA | XFS_QMOPT_GQUOTA)
242#define XFS_QMOPT_RESBLK_MASK	(XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_RES_RTBLKS)
243
244#ifdef __KERNEL__
245/*
246 * This check is done typically without holding the inode lock;
247 * that may seem racy, but it is harmless in the context that it is used.
248 * The inode cannot go inactive as long a reference is kept, and
249 * therefore if dquot(s) were attached, they'll stay consistent.
250 * If, for example, the ownership of the inode changes while
251 * we didn't have the inode locked, the appropriate dquot(s) will be
252 * attached atomically.
253 */
254#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\
255				     (ip)->i_udquot == NULL) || \
256				    (XFS_IS_OQUOTA_ON(mp) && \
257				     (ip)->i_gdquot == NULL))
258
259#define XFS_QM_NEED_QUOTACHECK(mp) \
260	((XFS_IS_UQUOTA_ON(mp) && \
261		(mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
262	 (XFS_IS_GQUOTA_ON(mp) && \
263		((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
264		 (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \
265	 (XFS_IS_PQUOTA_ON(mp) && \
266		((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
267		 (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT))))
268
269#define XFS_MOUNT_QUOTA_SET1	(XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
270				 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
271				 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
272
273#define XFS_MOUNT_QUOTA_SET2	(XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
274				 XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\
275				 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD)
276
277#define XFS_MOUNT_QUOTA_ALL	(XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
278				 XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\
279				 XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\
280				 XFS_GQUOTA_ACCT)
281
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
282
283/*
284 * The structure kept inside the xfs_trans_t keep track of dquot changes
285 * within a transaction and apply them later.
286 */
287typedef struct xfs_dqtrx {
288	struct xfs_dquot *qt_dquot;	  /* the dquot this refers to */
289	ulong		qt_blk_res;	  /* blks reserved on a dquot */
290	ulong		qt_blk_res_used;  /* blks used from the reservation */
291	ulong		qt_ino_res;	  /* inode reserved on a dquot */
292	ulong		qt_ino_res_used;  /* inodes used from the reservation */
293	long		qt_bcount_delta;  /* dquot blk count changes */
294	long		qt_delbcnt_delta; /* delayed dquot blk count changes */
295	long		qt_icount_delta;  /* dquot inode count changes */
296	ulong		qt_rtblk_res;	  /* # blks reserved on a dquot */
297	ulong		qt_rtblk_res_used;/* # blks used from reservation */
298	long		qt_rtbcount_delta;/* dquot realtime blk changes */
299	long		qt_delrtb_delta;  /* delayed RT blk count changes */
300} xfs_dqtrx_t;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
302#ifdef CONFIG_XFS_QUOTA
303extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *);
304extern void xfs_trans_free_dqinfo(struct xfs_trans *);
305extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *,
306		uint, long);
307extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *);
308extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *);
309extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *,
310		struct xfs_inode *, long, long, uint);
311extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
312		struct xfs_mount *, struct xfs_dquot *,
313		struct xfs_dquot *, long, long, uint);
314
315extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint,
316		struct xfs_dquot **, struct xfs_dquot **);
 
 
 
 
317extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
318		struct xfs_dquot *, struct xfs_dquot *);
319extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
320extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *,
321		struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *);
322extern int xfs_qm_vop_chown_reserve(struct xfs_trans *, struct xfs_inode *,
323		struct xfs_dquot *, struct xfs_dquot *, uint);
324extern int xfs_qm_dqattach(struct xfs_inode *, uint);
325extern int xfs_qm_dqattach_locked(struct xfs_inode *, uint);
326extern void xfs_qm_dqdetach(struct xfs_inode *);
327extern void xfs_qm_dqrele(struct xfs_dquot *);
328extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *);
329extern int xfs_qm_sync(struct xfs_mount *, int);
330extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *);
331extern void xfs_qm_mount_quotas(struct xfs_mount *);
332extern void xfs_qm_unmount(struct xfs_mount *);
333extern void xfs_qm_unmount_quotas(struct xfs_mount *);
334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335#else
336static inline int
337xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid,
338		uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp)
 
339{
340	*udqp = NULL;
341	*gdqp = NULL;
 
342	return 0;
343}
344#define xfs_trans_dup_dqinfo(tp, tp2)
345#define xfs_trans_free_dqinfo(tp)
346#define xfs_trans_mod_dquot_byino(tp, ip, fields, delta)
 
 
 
347#define xfs_trans_apply_dquot_deltas(tp)
348#define xfs_trans_unreserve_and_mod_dquots(tp)
349static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
350		struct xfs_inode *ip, long nblks, long ninos, uint flags)
 
351{
352	return 0;
353}
354static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
355		struct xfs_mount *mp, struct xfs_dquot *udqp,
356		struct xfs_dquot *gdqp, long nblks, long nions, uint flags)
 
357{
358	return 0;
359}
360#define xfs_qm_vop_create_dqattach(tp, ip, u, g)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361#define xfs_qm_vop_rename_dqattach(it)					(0)
362#define xfs_qm_vop_chown(tp, ip, old, new)				(NULL)
363#define xfs_qm_vop_chown_reserve(tp, ip, u, g, fl)			(0)
364#define xfs_qm_dqattach(ip, fl)						(0)
365#define xfs_qm_dqattach_locked(ip, fl)					(0)
366#define xfs_qm_dqdetach(ip)
367#define xfs_qm_dqrele(d)
368#define xfs_qm_statvfs(ip, s)
369static inline int xfs_qm_sync(struct xfs_mount *mp, int flags)
370{
371	return 0;
372}
373#define xfs_qm_newmount(mp, a, b)					(0)
374#define xfs_qm_mount_quotas(mp)
375#define xfs_qm_unmount(mp)
376#define xfs_qm_unmount_quotas(mp)
 
 
 
 
 
 
 
377#endif /* CONFIG_XFS_QUOTA */
378
379#define xfs_trans_unreserve_quota_nblks(tp, ip, nblks, ninos, flags) \
380	xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags)
381#define xfs_trans_reserve_quota(tp, mp, ud, gd, nb, ni, f) \
382	xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \
383				f | XFS_QMOPT_RES_REGBLKS)
384
385extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *,
386				xfs_dqid_t, uint, uint, char *);
387extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
388
389#endif	/* __KERNEL__ */
390#endif	/* __XFS_QUOTA_H__ */
v6.9.4
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  4 * All Rights Reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
  5 */
  6#ifndef __XFS_QUOTA_H__
  7#define __XFS_QUOTA_H__
  8
  9#include "xfs_quota_defs.h"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 10
 11/*
 12 * Kernel only quota definitions and functions
 13 */
 
 
 
 
 
 
 
 14
 15struct xfs_trans;
 16struct xfs_buf;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 17
 
 18/*
 19 * This check is done typically without holding the inode lock;
 20 * that may seem racy, but it is harmless in the context that it is used.
 21 * The inode cannot go inactive as long a reference is kept, and
 22 * therefore if dquot(s) were attached, they'll stay consistent.
 23 * If, for example, the ownership of the inode changes while
 24 * we didn't have the inode locked, the appropriate dquot(s) will be
 25 * attached atomically.
 26 */
 27#define XFS_NOT_DQATTACHED(mp, ip) \
 28	((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \
 29	 (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \
 30	 (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL))
 31
 32#define XFS_QM_NEED_QUOTACHECK(mp) \
 33	((XFS_IS_UQUOTA_ON(mp) && \
 34		(mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
 35	 (XFS_IS_GQUOTA_ON(mp) && \
 36		(mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
 
 37	 (XFS_IS_PQUOTA_ON(mp) && \
 38		(mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 39
 40static inline uint
 41xfs_quota_chkd_flag(
 42	xfs_dqtype_t		type)
 43{
 44	switch (type) {
 45	case XFS_DQTYPE_USER:
 46		return XFS_UQUOTA_CHKD;
 47	case XFS_DQTYPE_GROUP:
 48		return XFS_GQUOTA_CHKD;
 49	case XFS_DQTYPE_PROJ:
 50		return XFS_PQUOTA_CHKD;
 51	default:
 52		return 0;
 53	}
 54}
 55
 56/*
 57 * The structure kept inside the xfs_trans_t keep track of dquot changes
 58 * within a transaction and apply them later.
 59 */
 60struct xfs_dqtrx {
 61	struct xfs_dquot *qt_dquot;	  /* the dquot this refers to */
 62
 63	uint64_t	qt_blk_res;	  /* blks reserved on a dquot */
 64	int64_t		qt_bcount_delta;  /* dquot blk count changes */
 65	int64_t		qt_delbcnt_delta; /* delayed dquot blk count changes */
 66
 67	uint64_t	qt_rtblk_res;	  /* # blks reserved on a dquot */
 68	uint64_t	qt_rtblk_res_used;/* # blks used from reservation */
 69	int64_t		qt_rtbcount_delta;/* dquot realtime blk changes */
 70	int64_t		qt_delrtb_delta;  /* delayed RT blk count changes */
 71
 72	uint64_t	qt_ino_res;	  /* inode reserved on a dquot */
 73	uint64_t	qt_ino_res_used;  /* inodes used from the reservation */
 74	int64_t		qt_icount_delta;  /* dquot inode count changes */
 75};
 76
 77enum xfs_apply_dqtrx_type {
 78	XFS_APPLY_DQTRX_COMMIT = 0,
 79	XFS_APPLY_DQTRX_UNRESERVE,
 80};
 81
 82/*
 83 * Parameters for applying dqtrx changes to a dquot.  The hook function arg
 84 * parameter is enum xfs_apply_dqtrx_type.
 85 */
 86struct xfs_apply_dqtrx_params {
 87	uintptr_t		tx_id;
 88	xfs_ino_t		ino;
 89	xfs_dqtype_t		q_type;
 90	xfs_dqid_t		q_id;
 91};
 92
 93#ifdef CONFIG_XFS_QUOTA
 94extern void xfs_trans_dup_dqinfo(struct xfs_trans *, struct xfs_trans *);
 95extern void xfs_trans_free_dqinfo(struct xfs_trans *);
 96extern void xfs_trans_mod_dquot_byino(struct xfs_trans *, struct xfs_inode *,
 97		uint, int64_t);
 98extern void xfs_trans_apply_dquot_deltas(struct xfs_trans *);
 99extern void xfs_trans_unreserve_and_mod_dquots(struct xfs_trans *);
100int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp, struct xfs_inode *ip,
101		int64_t dblocks, int64_t rblocks, bool force);
102extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
103		struct xfs_mount *, struct xfs_dquot *,
104		struct xfs_dquot *, struct xfs_dquot *, int64_t, long, uint);
105int xfs_trans_reserve_quota_icreate(struct xfs_trans *tp,
106		struct xfs_dquot *udqp, struct xfs_dquot *gdqp,
107		struct xfs_dquot *pdqp, int64_t dblocks);
108
109extern int xfs_qm_vop_dqalloc(struct xfs_inode *, kuid_t, kgid_t,
110		prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
111		struct xfs_dquot **);
112extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
113		struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *);
114extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
115extern struct xfs_dquot *xfs_qm_vop_chown(struct xfs_trans *,
116		struct xfs_inode *, struct xfs_dquot **, struct xfs_dquot *);
117extern int xfs_qm_dqattach(struct xfs_inode *);
118extern int xfs_qm_dqattach_locked(struct xfs_inode *ip, bool doalloc);
 
 
119extern void xfs_qm_dqdetach(struct xfs_inode *);
120extern void xfs_qm_dqrele(struct xfs_dquot *);
121extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *);
 
122extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *);
123extern void xfs_qm_mount_quotas(struct xfs_mount *);
124extern void xfs_qm_unmount(struct xfs_mount *);
125extern void xfs_qm_unmount_quotas(struct xfs_mount *);
126
127static inline int
128xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
129{
130	return xfs_trans_reserve_quota_nblks(NULL, ip, blocks, 0, false);
131}
132bool xfs_inode_near_dquot_enforcement(struct xfs_inode *ip, xfs_dqtype_t type);
133
134# ifdef CONFIG_XFS_LIVE_HOOKS
135void xfs_trans_mod_ino_dquot(struct xfs_trans *tp, struct xfs_inode *ip,
136		struct xfs_dquot *dqp, unsigned int field, int64_t delta);
137
138struct xfs_quotainfo;
139
140struct xfs_dqtrx_hook {
141	struct xfs_hook		mod_hook;
142	struct xfs_hook		apply_hook;
143};
144
145void xfs_dqtrx_hook_disable(void);
146void xfs_dqtrx_hook_enable(void);
147
148int xfs_dqtrx_hook_add(struct xfs_quotainfo *qi, struct xfs_dqtrx_hook *hook);
149void xfs_dqtrx_hook_del(struct xfs_quotainfo *qi, struct xfs_dqtrx_hook *hook);
150void xfs_dqtrx_hook_setup(struct xfs_dqtrx_hook *hook, notifier_fn_t mod_fn,
151		notifier_fn_t apply_fn);
152# else
153#  define xfs_trans_mod_ino_dquot(tp, ip, dqp, field, delta) \
154		xfs_trans_mod_dquot((tp), (dqp), (field), (delta))
155# endif /* CONFIG_XFS_LIVE_HOOKS */
156
157#else
158static inline int
159xfs_qm_vop_dqalloc(struct xfs_inode *ip, kuid_t kuid, kgid_t kgid,
160		prid_t prid, uint flags, struct xfs_dquot **udqp,
161		struct xfs_dquot **gdqp, struct xfs_dquot **pdqp)
162{
163	*udqp = NULL;
164	*gdqp = NULL;
165	*pdqp = NULL;
166	return 0;
167}
168#define xfs_trans_dup_dqinfo(tp, tp2)
169#define xfs_trans_free_dqinfo(tp)
170static inline void xfs_trans_mod_dquot_byino(struct xfs_trans *tp,
171		struct xfs_inode *ip, uint field, int64_t delta)
172{
173}
174#define xfs_trans_apply_dquot_deltas(tp)
175#define xfs_trans_unreserve_and_mod_dquots(tp)
176static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp,
177		struct xfs_inode *ip, int64_t dblocks, int64_t rblocks,
178		bool force)
179{
180	return 0;
181}
182static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,
183		struct xfs_mount *mp, struct xfs_dquot *udqp,
184		struct xfs_dquot *gdqp, struct xfs_dquot *pdqp,
185		int64_t nblks, long nions, uint flags)
186{
187	return 0;
188}
189
190static inline int
191xfs_quota_reserve_blkres(struct xfs_inode *ip, int64_t blocks)
192{
193	return 0;
194}
195
196static inline int
197xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_dquot *udqp,
198		struct xfs_dquot *gdqp, struct xfs_dquot *pdqp, int64_t dblocks)
199{
200	return 0;
201}
202
203#define xfs_qm_vop_create_dqattach(tp, ip, u, g, p)
204#define xfs_qm_vop_rename_dqattach(it)					(0)
205#define xfs_qm_vop_chown(tp, ip, old, new)				(NULL)
206#define xfs_qm_dqattach(ip)						(0)
 
207#define xfs_qm_dqattach_locked(ip, fl)					(0)
208#define xfs_qm_dqdetach(ip)
209#define xfs_qm_dqrele(d)			do { (d) = (d); } while(0)
210#define xfs_qm_statvfs(ip, s)			do { } while(0)
 
 
 
 
211#define xfs_qm_newmount(mp, a, b)					(0)
212#define xfs_qm_mount_quotas(mp)
213#define xfs_qm_unmount(mp)
214#define xfs_qm_unmount_quotas(mp)
215#define xfs_inode_near_dquot_enforcement(ip, type)			(false)
216
217# ifdef CONFIG_XFS_LIVE_HOOKS
218#  define xfs_dqtrx_hook_enable()		((void)0)
219#  define xfs_dqtrx_hook_disable()		((void)0)
220# endif /* CONFIG_XFS_LIVE_HOOKS */
221
222#endif /* CONFIG_XFS_QUOTA */
223
224static inline int
225xfs_quota_unreserve_blkres(struct xfs_inode *ip, int64_t blocks)
226{
227	return xfs_quota_reserve_blkres(ip, -blocks);
228}
229
 
 
230extern int xfs_mount_reset_sbqflags(struct xfs_mount *);
231
 
232#endif	/* __XFS_QUOTA_H__ */