]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/quotaops.h
quota: rename quota functions from upper case, make bigger ones non-inline
[mirror_ubuntu-bionic-kernel.git] / include / linux / quotaops.h
CommitLineData
1da177e4
LT
1/*
2 * Definitions for diskquota-operations. When diskquota is configured these
3 * macros expand to the right source-code.
4 *
5 * Author: Marco van Wieringen <mvw@planets.elm.net>
6 *
7 * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $
8 *
9 */
10#ifndef _LINUX_QUOTAOPS_
11#define _LINUX_QUOTAOPS_
12
1da177e4
LT
13#include <linux/smp_lock.h>
14
15#include <linux/fs.h>
16
17#if defined(CONFIG_QUOTA)
18
19/*
20 * declaration of quota_function calls in kernel.
21 */
b85f4b87
JK
22void sync_dquots(struct super_block *sb, int type);
23
24int dquot_initialize(struct inode *inode, int type);
25int dquot_drop(struct inode *inode);
26
27int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
28int dquot_alloc_inode(const struct inode *inode, unsigned long number);
29
30int dquot_free_space(struct inode *inode, qsize_t number);
31int dquot_free_inode(const struct inode *inode, unsigned long number);
32
33int dquot_transfer(struct inode *inode, struct iattr *iattr);
34int dquot_commit(struct dquot *dquot);
35int dquot_acquire(struct dquot *dquot);
36int dquot_release(struct dquot *dquot);
37int dquot_commit_info(struct super_block *sb, int type);
38int dquot_mark_dquot_dirty(struct dquot *dquot);
39
40int vfs_quota_on(struct super_block *sb, int type, int format_id,
41 char *path, int remount);
42int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
43 int format_id, int type);
44int vfs_quota_off(struct super_block *sb, int type, int remount);
45int vfs_quota_sync(struct super_block *sb, int type);
46int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
47int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
48int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
49int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
50
51void vfs_dq_drop(struct inode *inode);
52int vfs_dq_transfer(struct inode *inode, struct iattr *iattr);
53int vfs_dq_quota_on_remount(struct super_block *sb);
1da177e4
LT
54
55/*
56 * Operations supported for diskquotas.
57 */
58extern struct dquot_operations dquot_operations;
59extern struct quotactl_ops vfs_quotactl_ops;
60
61#define sb_dquot_ops (&dquot_operations)
62#define sb_quotactl_ops (&vfs_quotactl_ops)
63
64/* It is better to call this function outside of any transaction as it might
65 * need a lot of space in journal for dquot structure allocation. */
b85f4b87 66static inline void vfs_dq_init(struct inode *inode)
1da177e4
LT
67{
68 BUG_ON(!inode->i_sb);
69 if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode))
70 inode->i_sb->dq_op->initialize(inode, -1);
71}
72
1da177e4
LT
73/* The following allocation/freeing/transfer functions *must* be called inside
74 * a transaction (deadlocks possible otherwise) */
b85f4b87 75static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
1da177e4
LT
76{
77 if (sb_any_quota_enabled(inode->i_sb)) {
78 /* Used space is updated in alloc_space() */
79 if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
80 return 1;
81 }
82 else
83 inode_add_bytes(inode, nr);
84 return 0;
85}
86
b85f4b87 87static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
1da177e4
LT
88{
89 int ret;
b85f4b87 90 if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr)))
1da177e4
LT
91 mark_inode_dirty(inode);
92 return ret;
93}
94
b85f4b87 95static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
1da177e4
LT
96{
97 if (sb_any_quota_enabled(inode->i_sb)) {
98 /* Used space is updated in alloc_space() */
99 if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
100 return 1;
101 }
102 else
103 inode_add_bytes(inode, nr);
104 return 0;
105}
106
b85f4b87 107static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
1da177e4
LT
108{
109 int ret;
b85f4b87 110 if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr)))
1da177e4
LT
111 mark_inode_dirty(inode);
112 return ret;
113}
114
b85f4b87 115static inline int vfs_dq_alloc_inode(struct inode *inode)
1da177e4
LT
116{
117 if (sb_any_quota_enabled(inode->i_sb)) {
b85f4b87 118 vfs_dq_init(inode);
1da177e4
LT
119 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
120 return 1;
121 }
122 return 0;
123}
124
b85f4b87 125static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
1da177e4
LT
126{
127 if (sb_any_quota_enabled(inode->i_sb))
128 inode->i_sb->dq_op->free_space(inode, nr);
129 else
130 inode_sub_bytes(inode, nr);
131}
132
b85f4b87 133static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
1da177e4 134{
b85f4b87 135 vfs_dq_free_space_nodirty(inode, nr);
1da177e4
LT
136 mark_inode_dirty(inode);
137}
138
b85f4b87 139static inline void vfs_dq_free_inode(struct inode *inode)
1da177e4
LT
140{
141 if (sb_any_quota_enabled(inode->i_sb))
142 inode->i_sb->dq_op->free_inode(inode, 1);
143}
144
1da177e4 145/* The following two functions cannot be called inside a transaction */
b85f4b87 146static inline void vfs_dq_sync(struct super_block *sb)
03f6e92b
JK
147{
148 sync_dquots(sb, -1);
149}
1da177e4 150
b85f4b87 151static inline int vfs_dq_off(struct super_block *sb, int remount)
1da177e4
LT
152{
153 int ret = -ENOSYS;
154
0ff5af83
JK
155 if (sb->s_qcop && sb->s_qcop->quota_off)
156 ret = sb->s_qcop->quota_off(sb, -1, remount);
157 return ret;
158}
159
1da177e4
LT
160#else
161
162/*
163 * NO-OP when quota not configured.
164 */
165#define sb_dquot_ops (NULL)
166#define sb_quotactl_ops (NULL)
50f8c370 167
b85f4b87 168static inline void vfs_dq_init(struct inode *inode)
50f8c370
AM
169{
170}
171
b85f4b87 172static inline void vfs_dq_drop(struct inode *inode)
50f8c370
AM
173{
174}
175
b85f4b87 176static inline int vfs_dq_alloc_inode(struct inode *inode)
50f8c370
AM
177{
178 return 0;
179}
180
b85f4b87 181static inline void vfs_dq_free_inode(struct inode *inode)
50f8c370
AM
182{
183}
184
b85f4b87 185static inline void vfs_dq_sync(struct super_block *sb)
50f8c370
AM
186{
187}
188
b85f4b87 189static inline int vfs_dq_off(struct super_block *sb, int remount)
50f8c370
AM
190{
191 return 0;
192}
193
b85f4b87 194static inline int vfs_dq_quota_on_remount(struct super_block *sb)
50f8c370
AM
195{
196 return 0;
197}
198
b85f4b87 199static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
50f8c370
AM
200{
201 return 0;
202}
203
b85f4b87 204static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
1da177e4
LT
205{
206 inode_add_bytes(inode, nr);
207 return 0;
208}
209
b85f4b87 210static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
1da177e4 211{
b85f4b87 212 vfs_dq_prealloc_space_nodirty(inode, nr);
1da177e4
LT
213 mark_inode_dirty(inode);
214 return 0;
215}
216
b85f4b87 217static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
1da177e4
LT
218{
219 inode_add_bytes(inode, nr);
220 return 0;
221}
222
b85f4b87 223static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
1da177e4 224{
b85f4b87 225 vfs_dq_alloc_space_nodirty(inode, nr);
1da177e4
LT
226 mark_inode_dirty(inode);
227 return 0;
228}
229
b85f4b87 230static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
1da177e4
LT
231{
232 inode_sub_bytes(inode, nr);
233}
234
b85f4b87 235static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
1da177e4 236{
b85f4b87 237 vfs_dq_free_space_nodirty(inode, nr);
1da177e4
LT
238 mark_inode_dirty(inode);
239}
240
241#endif /* CONFIG_QUOTA */
242
b85f4b87 243static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
03f6e92b 244{
b85f4b87 245 return vfs_dq_prealloc_space_nodirty(inode,
03f6e92b
JK
246 nr << inode->i_sb->s_blocksize_bits);
247}
248
b85f4b87 249static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr)
03f6e92b 250{
b85f4b87 251 return vfs_dq_prealloc_space(inode,
03f6e92b
JK
252 nr << inode->i_sb->s_blocksize_bits);
253}
254
b85f4b87 255static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr)
03f6e92b 256{
b85f4b87 257 return vfs_dq_alloc_space_nodirty(inode,
03f6e92b
JK
258 nr << inode->i_sb->s_blocksize_bits);
259}
260
b85f4b87 261static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr)
03f6e92b 262{
b85f4b87 263 return vfs_dq_alloc_space(inode,
03f6e92b
JK
264 nr << inode->i_sb->s_blocksize_bits);
265}
266
b85f4b87 267static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr)
03f6e92b 268{
b85f4b87 269 vfs_dq_free_space_nodirty(inode, nr << inode->i_sb->s_blocksize_bits);
03f6e92b
JK
270}
271
b85f4b87 272static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr)
03f6e92b 273{
b85f4b87 274 vfs_dq_free_space(inode, nr << inode->i_sb->s_blocksize_bits);
03f6e92b 275}
1da177e4 276
b85f4b87
JK
277/*
278 * Define uppercase equivalents for compatibility with old function names
279 * Can go away when we think all users have been converted (15/04/2008)
280 */
281#define DQUOT_INIT(inode) vfs_dq_init(inode)
282#define DQUOT_DROP(inode) vfs_dq_drop(inode)
283#define DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr) \
284 vfs_dq_prealloc_space_nodirty(inode, nr)
285#define DQUOT_PREALLOC_SPACE(inode, nr) vfs_dq_prealloc_space(inode, nr)
286#define DQUOT_ALLOC_SPACE_NODIRTY(inode, nr) \
287 vfs_dq_alloc_space_nodirty(inode, nr)
288#define DQUOT_ALLOC_SPACE(inode, nr) vfs_dq_alloc_space(inode, nr)
289#define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) \
290 vfs_dq_prealloc_block_nodirty(inode, nr)
291#define DQUOT_PREALLOC_BLOCK(inode, nr) vfs_dq_prealloc_block(inode, nr)
292#define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) \
293 vfs_dq_alloc_block_nodirty(inode, nr)
294#define DQUOT_ALLOC_BLOCK(inode, nr) vfs_dq_alloc_block(inode, nr)
295#define DQUOT_ALLOC_INODE(inode) vfs_dq_alloc_inode(inode)
296#define DQUOT_FREE_SPACE_NODIRTY(inode, nr) \
297 vfs_dq_free_space_nodirty(inode, nr)
298#define DQUOT_FREE_SPACE(inode, nr) vfs_dq_free_space(inode, nr)
299#define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) \
300 vfs_dq_free_block_nodirty(inode, nr)
301#define DQUOT_FREE_BLOCK(inode, nr) vfs_dq_free_block(inode, nr)
302#define DQUOT_FREE_INODE(inode) vfs_dq_free_inode(inode)
303#define DQUOT_TRANSFER(inode, iattr) vfs_dq_transfer(inode, iattr)
304#define DQUOT_SYNC(sb) vfs_dq_sync(sb)
305#define DQUOT_OFF(sb, remount) vfs_dq_off(sb, remount)
306#define DQUOT_ON_REMOUNT(sb) vfs_dq_quota_on_remount(sb)
307
1da177e4 308#endif /* _LINUX_QUOTAOPS_ */