2 * Definitions for diskquota-operations. When diskquota is configured these
3 * macros expand to the right source-code.
5 * Author: Marco van Wieringen <mvw@planets.elm.net>
7 * Version: $Id: quotaops.h,v 1.2 1998/01/15 16:22:26 ecd Exp $
10 #ifndef _LINUX_QUOTAOPS_
11 #define _LINUX_QUOTAOPS_
13 #include <linux/smp_lock.h>
17 #if defined(CONFIG_QUOTA)
20 * declaration of quota_function calls in kernel.
22 void sync_dquots(struct super_block
*sb
, int type
);
24 int dquot_initialize(struct inode
*inode
, int type
);
25 int dquot_drop(struct inode
*inode
);
27 int dquot_alloc_space(struct inode
*inode
, qsize_t number
, int prealloc
);
28 int dquot_alloc_inode(const struct inode
*inode
, unsigned long number
);
30 int dquot_free_space(struct inode
*inode
, qsize_t number
);
31 int dquot_free_inode(const struct inode
*inode
, unsigned long number
);
33 int dquot_transfer(struct inode
*inode
, struct iattr
*iattr
);
34 int dquot_commit(struct dquot
*dquot
);
35 int dquot_acquire(struct dquot
*dquot
);
36 int dquot_release(struct dquot
*dquot
);
37 int dquot_commit_info(struct super_block
*sb
, int type
);
38 int dquot_mark_dquot_dirty(struct dquot
*dquot
);
40 int vfs_quota_on(struct super_block
*sb
, int type
, int format_id
,
41 char *path
, int remount
);
42 int vfs_quota_on_mount(struct super_block
*sb
, char *qf_name
,
43 int format_id
, int type
);
44 int vfs_quota_off(struct super_block
*sb
, int type
, int remount
);
45 int vfs_quota_sync(struct super_block
*sb
, int type
);
46 int vfs_get_dqinfo(struct super_block
*sb
, int type
, struct if_dqinfo
*ii
);
47 int vfs_set_dqinfo(struct super_block
*sb
, int type
, struct if_dqinfo
*ii
);
48 int vfs_get_dqblk(struct super_block
*sb
, int type
, qid_t id
, struct if_dqblk
*di
);
49 int vfs_set_dqblk(struct super_block
*sb
, int type
, qid_t id
, struct if_dqblk
*di
);
51 void vfs_dq_drop(struct inode
*inode
);
52 int vfs_dq_transfer(struct inode
*inode
, struct iattr
*iattr
);
53 int vfs_dq_quota_on_remount(struct super_block
*sb
);
56 * Operations supported for diskquotas.
58 extern struct dquot_operations dquot_operations
;
59 extern struct quotactl_ops vfs_quotactl_ops
;
61 #define sb_dquot_ops (&dquot_operations)
62 #define sb_quotactl_ops (&vfs_quotactl_ops)
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. */
66 static inline void vfs_dq_init(struct inode
*inode
)
69 if (sb_any_quota_enabled(inode
->i_sb
) && !IS_NOQUOTA(inode
))
70 inode
->i_sb
->dq_op
->initialize(inode
, -1);
73 /* The following allocation/freeing/transfer functions *must* be called inside
74 * a transaction (deadlocks possible otherwise) */
75 static inline int vfs_dq_prealloc_space_nodirty(struct inode
*inode
, qsize_t nr
)
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
)
83 inode_add_bytes(inode
, nr
);
87 static inline int vfs_dq_prealloc_space(struct inode
*inode
, qsize_t nr
)
90 if (!(ret
= vfs_dq_prealloc_space_nodirty(inode
, nr
)))
91 mark_inode_dirty(inode
);
95 static inline int vfs_dq_alloc_space_nodirty(struct inode
*inode
, qsize_t nr
)
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
)
103 inode_add_bytes(inode
, nr
);
107 static inline int vfs_dq_alloc_space(struct inode
*inode
, qsize_t nr
)
110 if (!(ret
= vfs_dq_alloc_space_nodirty(inode
, nr
)))
111 mark_inode_dirty(inode
);
115 static inline int vfs_dq_alloc_inode(struct inode
*inode
)
117 if (sb_any_quota_enabled(inode
->i_sb
)) {
119 if (inode
->i_sb
->dq_op
->alloc_inode(inode
, 1) == NO_QUOTA
)
125 static inline void vfs_dq_free_space_nodirty(struct inode
*inode
, qsize_t nr
)
127 if (sb_any_quota_enabled(inode
->i_sb
))
128 inode
->i_sb
->dq_op
->free_space(inode
, nr
);
130 inode_sub_bytes(inode
, nr
);
133 static inline void vfs_dq_free_space(struct inode
*inode
, qsize_t nr
)
135 vfs_dq_free_space_nodirty(inode
, nr
);
136 mark_inode_dirty(inode
);
139 static inline void vfs_dq_free_inode(struct inode
*inode
)
141 if (sb_any_quota_enabled(inode
->i_sb
))
142 inode
->i_sb
->dq_op
->free_inode(inode
, 1);
145 /* The following two functions cannot be called inside a transaction */
146 static inline void vfs_dq_sync(struct super_block
*sb
)
151 static inline int vfs_dq_off(struct super_block
*sb
, int remount
)
155 if (sb
->s_qcop
&& sb
->s_qcop
->quota_off
)
156 ret
= sb
->s_qcop
->quota_off(sb
, -1, remount
);
163 * NO-OP when quota not configured.
165 #define sb_dquot_ops (NULL)
166 #define sb_quotactl_ops (NULL)
168 static inline void vfs_dq_init(struct inode
*inode
)
172 static inline void vfs_dq_drop(struct inode
*inode
)
176 static inline int vfs_dq_alloc_inode(struct inode
*inode
)
181 static inline void vfs_dq_free_inode(struct inode
*inode
)
185 static inline void vfs_dq_sync(struct super_block
*sb
)
189 static inline int vfs_dq_off(struct super_block
*sb
, int remount
)
194 static inline int vfs_dq_quota_on_remount(struct super_block
*sb
)
199 static inline int vfs_dq_transfer(struct inode
*inode
, struct iattr
*iattr
)
204 static inline int vfs_dq_prealloc_space_nodirty(struct inode
*inode
, qsize_t nr
)
206 inode_add_bytes(inode
, nr
);
210 static inline int vfs_dq_prealloc_space(struct inode
*inode
, qsize_t nr
)
212 vfs_dq_prealloc_space_nodirty(inode
, nr
);
213 mark_inode_dirty(inode
);
217 static inline int vfs_dq_alloc_space_nodirty(struct inode
*inode
, qsize_t nr
)
219 inode_add_bytes(inode
, nr
);
223 static inline int vfs_dq_alloc_space(struct inode
*inode
, qsize_t nr
)
225 vfs_dq_alloc_space_nodirty(inode
, nr
);
226 mark_inode_dirty(inode
);
230 static inline void vfs_dq_free_space_nodirty(struct inode
*inode
, qsize_t nr
)
232 inode_sub_bytes(inode
, nr
);
235 static inline void vfs_dq_free_space(struct inode
*inode
, qsize_t nr
)
237 vfs_dq_free_space_nodirty(inode
, nr
);
238 mark_inode_dirty(inode
);
241 #endif /* CONFIG_QUOTA */
243 static inline int vfs_dq_prealloc_block_nodirty(struct inode
*inode
, qsize_t nr
)
245 return vfs_dq_prealloc_space_nodirty(inode
,
246 nr
<< inode
->i_sb
->s_blocksize_bits
);
249 static inline int vfs_dq_prealloc_block(struct inode
*inode
, qsize_t nr
)
251 return vfs_dq_prealloc_space(inode
,
252 nr
<< inode
->i_sb
->s_blocksize_bits
);
255 static inline int vfs_dq_alloc_block_nodirty(struct inode
*inode
, qsize_t nr
)
257 return vfs_dq_alloc_space_nodirty(inode
,
258 nr
<< inode
->i_sb
->s_blocksize_bits
);
261 static inline int vfs_dq_alloc_block(struct inode
*inode
, qsize_t nr
)
263 return vfs_dq_alloc_space(inode
,
264 nr
<< inode
->i_sb
->s_blocksize_bits
);
267 static inline void vfs_dq_free_block_nodirty(struct inode
*inode
, qsize_t nr
)
269 vfs_dq_free_space_nodirty(inode
, nr
<< inode
->i_sb
->s_blocksize_bits
);
272 static inline void vfs_dq_free_block(struct inode
*inode
, qsize_t nr
)
274 vfs_dq_free_space(inode
, nr
<< inode
->i_sb
->s_blocksize_bits
);
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)
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)
308 #endif /* _LINUX_QUOTAOPS_ */