Blame view

include/linux/quota.h 14.2 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  /*
   * Copyright (c) 1982, 1986 Regents of the University of California.
   * All rights reserved.
   *
   * This code is derived from software contributed to Berkeley by
   * Robert Elz at The University of Melbourne.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in the
   *    documentation and/or other materials provided with the distribution.
   * 3. Neither the name of the University nor the names of its contributors
   *    may be used to endorse or promote products derived from this software
   *    without specific prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31
32
33
34
35
36
37
   */
  
  #ifndef _LINUX_QUOTA_
  #define _LINUX_QUOTA_
  
  #include <linux/errno.h>
  #include <linux/types.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
38

571b46e40   Jan Kara   quota: Update ver...
39
  #define __DQUOT_VERSION__	"dquot_6.5.2"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
  #define MAXQUOTAS 2
  #define USRQUOTA  0		/* element used for user quotas */
  #define GRPQUOTA  1		/* element used for group quotas */
  
  /*
   * Definitions for the default names of the quotas files.
   */
  #define INITQFNAMES { \
  	"user",    /* USRQUOTA */ \
  	"group",   /* GRPQUOTA */ \
  	"undefined", \
  };
  
  /*
   * Command definitions for the 'quotactl' system call.
   * The commands are broken into a main command defined below
   * and a subcommand that is used to convey the type of
   * quota that is being manipulated (see above).
   */
  #define SUBCMDMASK  0x00ff
  #define SUBCMDSHIFT 8
  #define QCMD(cmd, type)  (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
  
  #define Q_SYNC     0x800001	/* sync disk copy of a filesystems quotas */
  #define Q_QUOTAON  0x800002	/* turn quotas on */
  #define Q_QUOTAOFF 0x800003	/* turn quotas off */
  #define Q_GETFMT   0x800004	/* get quota format used on given filesystem */
  #define Q_GETINFO  0x800005	/* get information about quota files */
  #define Q_SETINFO  0x800006	/* set information about quota files */
  #define Q_GETQUOTA 0x800007	/* get user quota structure */
  #define Q_SETQUOTA 0x800008	/* set user quota structure */
5cd9d5bb8   Jan Kara   quota: Unexport d...
72
73
74
  /* Quota format type IDs */
  #define	QFMT_VFS_OLD 1
  #define	QFMT_VFS_V0 2
306739300   Jan Kara   quota: Move defin...
75
  #define QFMT_OCFS2 3
498c60153   Jan Kara   quota: Implement ...
76
  #define	QFMT_VFS_V1 4
5cd9d5bb8   Jan Kara   quota: Unexport d...
77

12095460f   Jan Kara   quota: Increase s...
78
79
80
81
  /* Size of block in which space limits are passed through the quota
   * interface */
  #define QIF_DQBLKSIZE_BITS 10
  #define QIF_DQBLKSIZE (1 << QIF_DQBLKSIZE_BITS)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
83
84
85
  /*
   * Quota structure used for communication with userspace via quotactl
   * Following flags are used to specify which fields are valid
   */
4d59bce4f   Jan Kara   quota: Keep which...
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
  enum {
  	QIF_BLIMITS_B = 0,
  	QIF_SPACE_B,
  	QIF_ILIMITS_B,
  	QIF_INODES_B,
  	QIF_BTIME_B,
  	QIF_ITIME_B,
  };
  
  #define QIF_BLIMITS	(1 << QIF_BLIMITS_B)
  #define QIF_SPACE	(1 << QIF_SPACE_B)
  #define QIF_ILIMITS	(1 << QIF_ILIMITS_B)
  #define QIF_INODES	(1 << QIF_INODES_B)
  #define QIF_BTIME	(1 << QIF_BTIME_B)
  #define QIF_ITIME	(1 << QIF_ITIME_B)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
  #define QIF_LIMITS	(QIF_BLIMITS | QIF_ILIMITS)
  #define QIF_USAGE	(QIF_SPACE | QIF_INODES)
  #define QIF_TIMES	(QIF_BTIME | QIF_ITIME)
  #define QIF_ALL		(QIF_LIMITS | QIF_USAGE | QIF_TIMES)
  
  struct if_dqblk {
  	__u64 dqb_bhardlimit;
  	__u64 dqb_bsoftlimit;
  	__u64 dqb_curspace;
  	__u64 dqb_ihardlimit;
  	__u64 dqb_isoftlimit;
  	__u64 dqb_curinodes;
  	__u64 dqb_btime;
  	__u64 dqb_itime;
  	__u32 dqb_valid;
  };
  
  /*
   * Structure used for setting quota information about file via quotactl
   * Following flags are used to specify which fields are valid
   */
  #define IIF_BGRACE	1
  #define IIF_IGRACE	2
  #define IIF_FLAGS	4
  #define IIF_ALL		(IIF_BGRACE | IIF_IGRACE | IIF_FLAGS)
  
  struct if_dqinfo {
  	__u64 dqi_bgrace;
  	__u64 dqi_igrace;
  	__u32 dqi_flags;
  	__u32 dqi_valid;
  };
8e8934695   Jan Kara   quota: send messa...
133
134
135
136
137
138
139
140
141
142
  /*
   * Definitions for quota netlink interface
   */
  #define QUOTA_NL_NOWARN 0
  #define QUOTA_NL_IHARDWARN 1		/* Inode hardlimit reached */
  #define QUOTA_NL_ISOFTLONGWARN 2 	/* Inode grace time expired */
  #define QUOTA_NL_ISOFTWARN 3		/* Inode softlimit reached */
  #define QUOTA_NL_BHARDWARN 4		/* Block hardlimit reached */
  #define QUOTA_NL_BSOFTLONGWARN 5	/* Block grace time expired */
  #define QUOTA_NL_BSOFTWARN 6		/* Block softlimit reached */
657d3bfa9   Jan Kara   quota: implement ...
143
144
145
146
  #define QUOTA_NL_IHARDBELOW 7		/* Usage got below inode hardlimit */
  #define QUOTA_NL_ISOFTBELOW 8		/* Usage got below inode softlimit */
  #define QUOTA_NL_BHARDBELOW 9		/* Usage got below block hardlimit */
  #define QUOTA_NL_BSOFTBELOW 10		/* Usage got below block softlimit */
8e8934695   Jan Kara   quota: send messa...
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
  
  enum {
  	QUOTA_NL_C_UNSPEC,
  	QUOTA_NL_C_WARNING,
  	__QUOTA_NL_C_MAX,
  };
  #define QUOTA_NL_C_MAX (__QUOTA_NL_C_MAX - 1)
  
  enum {
  	QUOTA_NL_A_UNSPEC,
  	QUOTA_NL_A_QTYPE,
  	QUOTA_NL_A_EXCESS_ID,
  	QUOTA_NL_A_WARNING,
  	QUOTA_NL_A_DEV_MAJOR,
  	QUOTA_NL_A_DEV_MINOR,
  	QUOTA_NL_A_CAUSED_ID,
  	__QUOTA_NL_A_MAX,
  };
  #define QUOTA_NL_A_MAX (__QUOTA_NL_A_MAX - 1)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
166
  #ifdef __KERNEL__
8b91de2e5   Matthew Wilcox   Fix quota.h includes
167
  #include <linux/list.h>
0409d3a33   David Woodhouse   Don't include pri...
168
  #include <linux/mutex.h>
8b91de2e5   Matthew Wilcox   Fix quota.h includes
169
170
171
  #include <linux/rwsem.h>
  #include <linux/spinlock.h>
  #include <linux/wait.h>
f32764bd2   Dmitry Monakhov   quota: Convert qu...
172
  #include <linux/percpu_counter.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
173
174
175
176
  
  #include <linux/dqblk_xfs.h>
  #include <linux/dqblk_v1.h>
  #include <linux/dqblk_v2.h>
60063497a   Arun Sharma   atomic: use <linu...
177
  #include <linux/atomic.h>
8b91de2e5   Matthew Wilcox   Fix quota.h includes
178

74abb9890   Jan Kara   quota: move funct...
179
  typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
db49d2df4   Jan Kara   quota: Allow nega...
180
  typedef long long qsize_t;	/* Type in which we store sizes */
74abb9890   Jan Kara   quota: move funct...
181

acd64b737   Mike Frysinger   hide spinlock in ...
182
  extern spinlock_t dq_data_lock;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
183
  /* Maximal numbers of writes for quota operation (insert/delete/update)
4e5117ba0   Jan Kara   [PATCH] quota: im...
184
185
186
187
188
   * (over VFS all formats) */
  #define DQUOT_INIT_ALLOC max(V1_INIT_ALLOC, V2_INIT_ALLOC)
  #define DQUOT_INIT_REWRITE max(V1_INIT_REWRITE, V2_INIT_REWRITE)
  #define DQUOT_DEL_ALLOC max(V1_DEL_ALLOC, V2_DEL_ALLOC)
  #define DQUOT_DEL_REWRITE max(V1_DEL_REWRITE, V2_DEL_REWRITE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
189
190
191
192
193
  
  /*
   * Data for one user/group kept in memory
   */
  struct mem_dqblk {
12095460f   Jan Kara   quota: Increase s...
194
195
  	qsize_t dqb_bhardlimit;	/* absolute limit on disk blks alloc */
  	qsize_t dqb_bsoftlimit;	/* preferred limit on disk blks */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
196
  	qsize_t dqb_curspace;	/* current used space */
f18df2289   Mingming Cao   quota: Add quota ...
197
  	qsize_t dqb_rsvspace;   /* current reserved space for delalloc*/
12095460f   Jan Kara   quota: Increase s...
198
199
200
  	qsize_t dqb_ihardlimit;	/* absolute limit on allocated inodes */
  	qsize_t dqb_isoftlimit;	/* preferred inode limit */
  	qsize_t dqb_curinodes;	/* current # allocated inodes */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
201
202
203
204
205
206
207
208
209
210
211
  	time_t dqb_btime;	/* time limit for excessive disk use */
  	time_t dqb_itime;	/* time limit for excessive inode use */
  };
  
  /*
   * Data for one quotafile kept in memory
   */
  struct quota_format_type;
  
  struct mem_dqinfo {
  	struct quota_format_type *dqi_format;
0ff5af834   Jan Kara   quota: quota core...
212
213
  	int dqi_fmt_id;		/* Id of the dqi_format - used when turning
  				 * quotas on after remount RW */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
214
215
216
217
  	struct list_head dqi_dirty_list;	/* List of dirty dquots */
  	unsigned long dqi_flags;
  	unsigned int dqi_bgrace;
  	unsigned int dqi_igrace;
338bf9afd   Andrew Perepechko   quota: do not all...
218
219
  	qsize_t dqi_maxblimit;
  	qsize_t dqi_maxilimit;
e3d4d56b9   Jan Kara   quota: Convert un...
220
  	void *dqi_priv;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
221
222
223
224
225
226
227
228
229
  };
  
  struct super_block;
  
  #define DQF_MASK 0xffff		/* Mask for format specific flags */
  #define DQF_INFO_DIRTY_B 16
  #define DQF_INFO_DIRTY (1 << DQF_INFO_DIRTY_B)	/* Is info dirty? */
  
  extern void mark_info_dirty(struct super_block *sb, int type);
03b063436   Jan Kara   quota: convert ma...
230
231
232
233
  static inline int info_dirty(struct mem_dqinfo *info)
  {
  	return test_bit(DQF_INFO_DIRTY_B, &info->dqi_flags);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
234

dde958885   Dmitry Monakhov   quota: Make quota...
235
236
237
238
239
240
241
242
243
244
245
  enum {
  	DQST_LOOKUPS,
  	DQST_DROPS,
  	DQST_READS,
  	DQST_WRITES,
  	DQST_CACHE_HITS,
  	DQST_ALLOC_DQUOTS,
  	DQST_FREE_DQUOTS,
  	DQST_SYNCS,
  	_DQST_DQSTAT_LAST
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
246
  struct dqstats {
dde958885   Dmitry Monakhov   quota: Make quota...
247
  	int stat[_DQST_DQSTAT_LAST];
f32764bd2   Dmitry Monakhov   quota: Convert qu...
248
  	struct percpu_counter counter[_DQST_DQSTAT_LAST];
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
249
  };
dde958885   Dmitry Monakhov   quota: Make quota...
250
  extern struct dqstats *dqstats_pcpu;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
251
  extern struct dqstats dqstats;
dde958885   Dmitry Monakhov   quota: Make quota...
252
253
  static inline void dqstats_inc(unsigned int type)
  {
f32764bd2   Dmitry Monakhov   quota: Convert qu...
254
  	percpu_counter_inc(&dqstats.counter[type]);
dde958885   Dmitry Monakhov   quota: Make quota...
255
256
257
258
  }
  
  static inline void dqstats_dec(unsigned int type)
  {
f32764bd2   Dmitry Monakhov   quota: Convert qu...
259
  	percpu_counter_dec(&dqstats.counter[type]);
dde958885   Dmitry Monakhov   quota: Make quota...
260
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
261
262
263
264
265
266
  #define DQ_MOD_B	0	/* dquot modified since read */
  #define DQ_BLKS_B	1	/* uid/gid has been warned about blk limit */
  #define DQ_INODES_B	2	/* uid/gid has been warned about inode limit */
  #define DQ_FAKE_B	3	/* no limits only usage */
  #define DQ_READ_B	4	/* dquot was read into memory */
  #define DQ_ACTIVE_B	5	/* dquot is active (dquot_release not called) */
4d59bce4f   Jan Kara   quota: Keep which...
267
268
269
270
271
  #define DQ_LASTSET_B	6	/* Following 6 bits (see QIF_) are reserved\
  				 * for the mask of entries set via SETQUOTA\
  				 * quotactl. They are set under dq_data_lock\
  				 * and the quota format handling dquot can\
  				 * clear them when it sees fit. */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
272
273
274
275
276
277
  
  struct dquot {
  	struct hlist_node dq_hash;	/* Hash list in memory */
  	struct list_head dq_inuse;	/* List of all quotas */
  	struct list_head dq_free;	/* Free list element */
  	struct list_head dq_dirty;	/* List of dirty dquots */
d3be915fc   Ingo Molnar   [PATCH] sem2mutex...
278
  	struct mutex dq_lock;		/* dquot IO lock */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
279
280
281
282
283
284
285
286
287
  	atomic_t dq_count;		/* Use count */
  	wait_queue_head_t dq_wait_unused;	/* Wait queue for dquot to become unused */
  	struct super_block *dq_sb;	/* superblock this applies to */
  	unsigned int dq_id;		/* ID this applies to (uid, gid) */
  	loff_t dq_off;			/* Offset of dquot on disk */
  	unsigned long dq_flags;		/* See DQ_* */
  	short dq_type;			/* Type of quota */
  	struct mem_dqblk dq_dqb;	/* Diskquota usage */
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
288
289
290
291
292
293
294
295
296
297
298
299
300
  /* Operations which must be implemented by each quota format */
  struct quota_format_ops {
  	int (*check_quota_file)(struct super_block *sb, int type);	/* Detect whether file is in our format */
  	int (*read_file_info)(struct super_block *sb, int type);	/* Read main info about file - called on quotaon() */
  	int (*write_file_info)(struct super_block *sb, int type);	/* Write main info about file */
  	int (*free_file_info)(struct super_block *sb, int type);	/* Called on quotaoff() */
  	int (*read_dqblk)(struct dquot *dquot);		/* Read structure for one user */
  	int (*commit_dqblk)(struct dquot *dquot);	/* Write structure for one user */
  	int (*release_dqblk)(struct dquot *dquot);	/* Called when last reference to dquot is being dropped */
  };
  
  /* Operations working with dquots */
  struct dquot_operations {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
301
  	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
74f783af9   Jan Kara   quota: Add callba...
302
303
  	struct dquot *(*alloc_dquot)(struct super_block *, int);	/* Allocate memory for new dquot */
  	void (*destroy_dquot)(struct dquot *);		/* Free memory for dquot */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
304
305
306
307
  	int (*acquire_dquot) (struct dquot *);		/* Quota is going to be created on disk */
  	int (*release_dquot) (struct dquot *);		/* Quota is going to be deleted from disk */
  	int (*mark_dirty) (struct dquot *);		/* Dquot is marked dirty */
  	int (*write_info) (struct super_block *, int);	/* Write of quota "superblock" */
fd8fbfc17   Dmitry Monakhov   quota: decouple f...
308
309
310
  	/* get reserved quota for delayed alloc, value returned is managed by
  	 * quota code only */
  	qsize_t *(*get_reserved_space) (struct inode *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
311
  };
f00c9e44a   Jan Kara   quota: Fix deadlo...
312
  struct path;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
313
314
  /* Operations handling requests from userspace */
  struct quotactl_ops {
f00c9e44a   Jan Kara   quota: Fix deadlo...
315
316
  	int (*quota_on)(struct super_block *, int, int, struct path *);
  	int (*quota_on_meta)(struct super_block *, int, int);
307ae18a5   Christoph Hellwig   quota: drop remou...
317
  	int (*quota_off)(struct super_block *, int);
5fb324ad2   Christoph Hellwig   quota: move code ...
318
  	int (*quota_sync)(struct super_block *, int, int);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
319
320
  	int (*get_info)(struct super_block *, int, struct if_dqinfo *);
  	int (*set_info)(struct super_block *, int, struct if_dqinfo *);
b9b2dd36c   Christoph Hellwig   quota: unify ->ge...
321
  	int (*get_dqblk)(struct super_block *, int, qid_t, struct fs_disk_quota *);
c472b4327   Christoph Hellwig   quota: unify ->se...
322
  	int (*set_dqblk)(struct super_block *, int, qid_t, struct fs_disk_quota *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
323
324
  	int (*get_xstate)(struct super_block *, struct fs_quota_stat *);
  	int (*set_xstate)(struct super_block *, unsigned int, int);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
325
326
327
328
  };
  
  struct quota_format_type {
  	int qf_fmt_id;	/* Quota format id */
1472da5fd   Alexey Dobriyan   const: struct quo...
329
  	const struct quota_format_ops *qf_ops;	/* Operations of format */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
330
331
332
  	struct module *qf_owner;		/* Module implementing quota format */
  	struct quota_format_type *qf_next;
  };
f55abc0fb   Jan Kara   quota: Allow to s...
333
334
335
336
337
  /* Quota state flags - they actually come in two flavors - for users and groups */
  enum {
  	_DQUOT_USAGE_ENABLED = 0,		/* Track disk usage for users */
  	_DQUOT_LIMITS_ENABLED,			/* Enforce quota limits for users */
  	_DQUOT_SUSPENDED,			/* User diskquotas are off, but
0ff5af834   Jan Kara   quota: quota core...
338
339
  						 * we have necessary info in
  						 * memory to turn them on */
f55abc0fb   Jan Kara   quota: Allow to s...
340
341
342
343
344
345
346
  	_DQUOT_STATE_FLAGS
  };
  #define DQUOT_USAGE_ENABLED	(1 << _DQUOT_USAGE_ENABLED)
  #define DQUOT_LIMITS_ENABLED	(1 << _DQUOT_LIMITS_ENABLED)
  #define DQUOT_SUSPENDED		(1 << _DQUOT_SUSPENDED)
  #define DQUOT_STATE_FLAGS	(DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \
  				 DQUOT_SUSPENDED)
ca785ec66   Jan Kara   quota: Introduce ...
347
  /* Other quota flags */
ad1e6e8da   Dmitry Monakhov   quota: sb_quota s...
348
349
350
  #define DQUOT_STATE_LAST	(_DQUOT_STATE_FLAGS * MAXQUOTAS)
  #define DQUOT_QUOTA_SYS_FILE	(1 << DQUOT_STATE_LAST)
  						/* Quota file is a special
ca785ec66   Jan Kara   quota: Introduce ...
351
352
353
354
355
  						 * system file and user cannot
  						 * touch it. Filesystem is
  						 * responsible for setting
  						 * S_NOQUOTA, S_NOATIME flags
  						 */
ad1e6e8da   Dmitry Monakhov   quota: sb_quota s...
356
357
  #define DQUOT_NEGATIVE_USAGE	(1 << (DQUOT_STATE_LAST + 1))
  					       /* Allow negative quota usage */
f55abc0fb   Jan Kara   quota: Allow to s...
358
359
360
  
  static inline unsigned int dquot_state_flag(unsigned int flags, int type)
  {
ad1e6e8da   Dmitry Monakhov   quota: sb_quota s...
361
  	return flags << _DQUOT_STATE_FLAGS * type;
f55abc0fb   Jan Kara   quota: Allow to s...
362
363
364
365
  }
  
  static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
  {
ad1e6e8da   Dmitry Monakhov   quota: sb_quota s...
366
  	return (flags >> _DQUOT_STATE_FLAGS * type) & DQUOT_STATE_FLAGS;
f55abc0fb   Jan Kara   quota: Allow to s...
367
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
368

86e931a35   Steven Whitehouse   VFS: Export dquot...
369
370
371
372
373
374
375
376
377
378
  #ifdef CONFIG_QUOTA_NETLINK_INTERFACE
  extern void quota_send_warning(short type, unsigned int id, dev_t dev,
  			       const char warntype);
  #else
  static inline void quota_send_warning(short type, unsigned int id, dev_t dev,
  				      const char warntype)
  {
  	return;
  }
  #endif /* CONFIG_QUOTA_NETLINK_INTERFACE */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
379
380
  struct quota_info {
  	unsigned int flags;			/* Flags for diskquotas on this device */
d3be915fc   Ingo Molnar   [PATCH] sem2mutex...
381
382
  	struct mutex dqio_mutex;		/* lock device while I/O in progress */
  	struct mutex dqonoff_mutex;		/* Serialize quotaon & quotaoff */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
383
384
  	struct rw_semaphore dqptr_sem;		/* serialize ops using quota_info struct, pointers from inode to dquots */
  	struct inode *files[MAXQUOTAS];		/* inodes of quotafiles */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
385
  	struct mem_dqinfo info[MAXQUOTAS];	/* Information for each quota type */
1472da5fd   Alexey Dobriyan   const: struct quo...
386
  	const struct quota_format_ops *ops[MAXQUOTAS];	/* Operations for each type */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
387
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
388
389
390
391
392
393
394
395
396
397
398
399
  int register_quota_format(struct quota_format_type *fmt);
  void unregister_quota_format(struct quota_format_type *fmt);
  
  struct quota_module_name {
  	int qm_fmt_id;
  	char *qm_mod_name;
  };
  
  #define INIT_QUOTA_MODULE_NAMES {\
  	{QFMT_VFS_OLD, "quota_v1"},\
  	{QFMT_VFS_V0, "quota_v2"},\
  	{0, NULL}}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
400
401
  #endif /* __KERNEL__ */
  #endif /* _QUOTA_ */