blob: e563a20cff4ff8c352329c4f6e3c47072256469f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7#ifndef _LINUX_QUOTAOPS_
8#define _LINUX_QUOTAOPS_
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/fs.h>
11
Jan Kara03b06342008-07-25 01:46:52 -070012static inline struct quota_info *sb_dqopt(struct super_block *sb)
13{
14 return &sb->s_dquot;
15}
Jan Kara74abb982008-07-25 01:46:51 -070016
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#if defined(CONFIG_QUOTA)
18
19/*
20 * declaration of quota_function calls in kernel.
21 */
Dmitry Monakhovc4690702010-02-09 17:53:36 +010022void inode_add_rsv_space(struct inode *inode, qsize_t number);
23void inode_claim_rsv_space(struct inode *inode, qsize_t number);
24void inode_sub_rsv_space(struct inode *inode, qsize_t number);
25
Jan Karab85f4b82008-07-25 01:46:50 -070026int dquot_initialize(struct inode *inode, int type);
27int dquot_drop(struct inode *inode);
Jan Kara3d9ea252008-10-10 16:12:23 +020028struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
29void dqput(struct dquot *dquot);
Jan Kara12c77522008-10-20 17:05:00 +020030int dquot_scan_active(struct super_block *sb,
31 int (*fn)(struct dquot *dquot, unsigned long priv),
32 unsigned long priv);
Jan Kara7d9056b2008-11-25 15:31:32 +010033struct dquot *dquot_alloc(struct super_block *sb, int type);
34void dquot_destroy(struct dquot *dquot);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Jan Karab85f4b82008-07-25 01:46:50 -070036int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
Jan Kara12095462008-08-20 14:45:12 +020037int dquot_alloc_inode(const struct inode *inode, qsize_t number);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Mingming Cao740d9dc2009-01-13 16:43:14 +010039int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc);
40int dquot_claim_space(struct inode *inode, qsize_t number);
41void dquot_release_reserved_space(struct inode *inode, qsize_t number);
Mingming Cao740d9dc2009-01-13 16:43:14 +010042
Jan Karab85f4b82008-07-25 01:46:50 -070043int dquot_free_space(struct inode *inode, qsize_t number);
Jan Kara12095462008-08-20 14:45:12 +020044int dquot_free_inode(const struct inode *inode, qsize_t number);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Jan Karab85f4b82008-07-25 01:46:50 -070046int dquot_transfer(struct inode *inode, struct iattr *iattr);
47int dquot_commit(struct dquot *dquot);
48int dquot_acquire(struct dquot *dquot);
49int dquot_release(struct dquot *dquot);
50int dquot_commit_info(struct super_block *sb, int type);
51int dquot_mark_dquot_dirty(struct dquot *dquot);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Jan Karab85f4b82008-07-25 01:46:50 -070053int vfs_quota_on(struct super_block *sb, int type, int format_id,
54 char *path, int remount);
Jan Karaf55abc02008-08-20 17:50:32 +020055int vfs_quota_enable(struct inode *inode, int type, int format_id,
56 unsigned int flags);
Al Viro77e69da2008-08-01 04:29:18 -040057int vfs_quota_on_path(struct super_block *sb, int type, int format_id,
58 struct path *path);
Jan Karab85f4b82008-07-25 01:46:50 -070059int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
60 int format_id, int type);
61int vfs_quota_off(struct super_block *sb, int type, int remount);
Jan Karaf55abc02008-08-20 17:50:32 +020062int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags);
Christoph Hellwig5fb324a2010-02-16 03:44:52 -050063int vfs_quota_sync(struct super_block *sb, int type, int wait);
Jan Karab85f4b82008-07-25 01:46:50 -070064int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
65int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
66int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
67int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
68
69void vfs_dq_drop(struct inode *inode);
70int vfs_dq_transfer(struct inode *inode, struct iattr *iattr);
71int vfs_dq_quota_on_remount(struct super_block *sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
Jan Kara03b06342008-07-25 01:46:52 -070073static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
74{
75 return sb_dqopt(sb)->info + type;
76}
Jan Kara74abb982008-07-25 01:46:51 -070077
78/*
79 * Functions for checking status of quota
80 */
81
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +030082static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type)
Jan Kara03b06342008-07-25 01:46:52 -070083{
Jan Karaf55abc02008-08-20 17:50:32 +020084 return sb_dqopt(sb)->flags &
85 dquot_state_flag(DQUOT_USAGE_ENABLED, type);
Jan Kara03b06342008-07-25 01:46:52 -070086}
Jan Kara74abb982008-07-25 01:46:51 -070087
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +030088static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type)
Jan Kara03b06342008-07-25 01:46:52 -070089{
Jan Karaf55abc02008-08-20 17:50:32 +020090 return sb_dqopt(sb)->flags &
91 dquot_state_flag(DQUOT_LIMITS_ENABLED, type);
Jan Kara03b06342008-07-25 01:46:52 -070092}
Jan Kara74abb982008-07-25 01:46:51 -070093
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +030094static inline bool sb_has_quota_suspended(struct super_block *sb, int type)
Jan Kara03b06342008-07-25 01:46:52 -070095{
Jan Karaf55abc02008-08-20 17:50:32 +020096 return sb_dqopt(sb)->flags &
97 dquot_state_flag(DQUOT_SUSPENDED, type);
Jan Kara03b06342008-07-25 01:46:52 -070098}
Jan Kara74abb982008-07-25 01:46:51 -070099
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300100static inline unsigned sb_any_quota_suspended(struct super_block *sb)
Jan Kara03b06342008-07-25 01:46:52 -0700101{
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300102 unsigned type, tmsk = 0;
103 for (type = 0; type < MAXQUOTAS; type++)
104 tmsk |= sb_has_quota_suspended(sb, type) << type;
105 return tmsk;
Jan Kara03b06342008-07-25 01:46:52 -0700106}
Jan Kara74abb982008-07-25 01:46:51 -0700107
Jan Karaf55abc02008-08-20 17:50:32 +0200108/* Does kernel know about any quota information for given sb + type? */
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300109static inline bool sb_has_quota_loaded(struct super_block *sb, int type)
Jan Karaf55abc02008-08-20 17:50:32 +0200110{
111 /* Currently if anything is on, then quota usage is on as well */
112 return sb_has_quota_usage_enabled(sb, type);
113}
114
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300115static inline unsigned sb_any_quota_loaded(struct super_block *sb)
Jan Karaf55abc02008-08-20 17:50:32 +0200116{
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300117 unsigned type, tmsk = 0;
118 for (type = 0; type < MAXQUOTAS; type++)
119 tmsk |= sb_has_quota_loaded(sb, type) << type;
120 return tmsk;
Jan Karaf55abc02008-08-20 17:50:32 +0200121}
122
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300123static inline bool sb_has_quota_active(struct super_block *sb, int type)
Jan Karaf55abc02008-08-20 17:50:32 +0200124{
125 return sb_has_quota_loaded(sb, type) &&
126 !sb_has_quota_suspended(sb, type);
127}
128
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300129static inline unsigned sb_any_quota_active(struct super_block *sb)
Jan Karaf55abc02008-08-20 17:50:32 +0200130{
Dmitry Monakhovad1e6e82010-02-16 08:31:49 +0300131 return sb_any_quota_loaded(sb) & ~sb_any_quota_suspended(sb);
Jan Karaf55abc02008-08-20 17:50:32 +0200132}
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134/*
135 * Operations supported for diskquotas.
136 */
Alexey Dobriyan61e225d2009-09-21 17:01:08 -0700137extern const struct dquot_operations dquot_operations;
Alexey Dobriyan0d54b212009-09-21 17:01:09 -0700138extern const struct quotactl_ops vfs_quotactl_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139
140#define sb_dquot_ops (&dquot_operations)
141#define sb_quotactl_ops (&vfs_quotactl_ops)
142
143/* It is better to call this function outside of any transaction as it might
144 * need a lot of space in journal for dquot structure allocation. */
Jan Karab85f4b82008-07-25 01:46:50 -0700145static inline void vfs_dq_init(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146{
147 BUG_ON(!inode->i_sb);
Jan Karaf55abc02008-08-20 17:50:32 +0200148 if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 inode->i_sb->dq_op->initialize(inode, -1);
150}
151
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152/* The following allocation/freeing/transfer functions *must* be called inside
153 * a transaction (deadlocks possible otherwise) */
Jan Karab85f4b82008-07-25 01:46:50 -0700154static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
Jan Karaf55abc02008-08-20 17:50:32 +0200156 if (sb_any_quota_active(inode->i_sb)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 /* Used space is updated in alloc_space() */
158 if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
159 return 1;
160 }
161 else
162 inode_add_bytes(inode, nr);
163 return 0;
164}
165
Jan Karab85f4b82008-07-25 01:46:50 -0700166static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167{
168 int ret;
Jan Karab85f4b82008-07-25 01:46:50 -0700169 if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 mark_inode_dirty(inode);
171 return ret;
172}
173
Jan Karab85f4b82008-07-25 01:46:50 -0700174static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
Jan Karaf55abc02008-08-20 17:50:32 +0200176 if (sb_any_quota_active(inode->i_sb)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 /* Used space is updated in alloc_space() */
178 if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
179 return 1;
180 }
181 else
182 inode_add_bytes(inode, nr);
183 return 0;
184}
185
Jan Karab85f4b82008-07-25 01:46:50 -0700186static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187{
188 int ret;
Jan Karab85f4b82008-07-25 01:46:50 -0700189 if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr)))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 mark_inode_dirty(inode);
191 return ret;
192}
193
Mingming Caof18df222009-01-13 16:43:09 +0100194static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
195{
196 if (sb_any_quota_active(inode->i_sb)) {
197 /* Used space is updated in alloc_space() */
198 if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
199 return 1;
200 }
Dmitry Monakhovc4690702010-02-09 17:53:36 +0100201 else
202 inode_add_rsv_space(inode, nr);
Mingming Caof18df222009-01-13 16:43:09 +0100203 return 0;
204}
205
Jan Karab85f4b82008-07-25 01:46:50 -0700206static inline int vfs_dq_alloc_inode(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207{
Jan Karaf55abc02008-08-20 17:50:32 +0200208 if (sb_any_quota_active(inode->i_sb)) {
Jan Karab85f4b82008-07-25 01:46:50 -0700209 vfs_dq_init(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
211 return 1;
212 }
213 return 0;
214}
215
Mingming Cao740d9dc2009-01-13 16:43:14 +0100216/*
217 * Convert in-memory reserved quotas to real consumed quotas
218 */
219static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
220{
221 if (sb_any_quota_active(inode->i_sb)) {
222 if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
223 return 1;
224 } else
Dmitry Monakhovc4690702010-02-09 17:53:36 +0100225 inode_claim_rsv_space(inode, nr);
Mingming Cao740d9dc2009-01-13 16:43:14 +0100226
227 mark_inode_dirty(inode);
228 return 0;
229}
230
231/*
232 * Release reserved (in-memory) quotas
233 */
234static inline
235void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
236{
237 if (sb_any_quota_active(inode->i_sb))
238 inode->i_sb->dq_op->release_rsv(inode, nr);
Dmitry Monakhovc4690702010-02-09 17:53:36 +0100239 else
240 inode_sub_rsv_space(inode, nr);
Mingming Cao740d9dc2009-01-13 16:43:14 +0100241}
242
Jan Karab85f4b82008-07-25 01:46:50 -0700243static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244{
Jan Karaf55abc02008-08-20 17:50:32 +0200245 if (sb_any_quota_active(inode->i_sb))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 inode->i_sb->dq_op->free_space(inode, nr);
247 else
248 inode_sub_bytes(inode, nr);
249}
250
Jan Karab85f4b82008-07-25 01:46:50 -0700251static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252{
Jan Karab85f4b82008-07-25 01:46:50 -0700253 vfs_dq_free_space_nodirty(inode, nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 mark_inode_dirty(inode);
255}
256
Jan Karab85f4b82008-07-25 01:46:50 -0700257static inline void vfs_dq_free_inode(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258{
Jan Karaf55abc02008-08-20 17:50:32 +0200259 if (sb_any_quota_active(inode->i_sb))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 inode->i_sb->dq_op->free_inode(inode, 1);
261}
262
Christoph Hellwig850b2012009-04-27 16:43:54 +0200263/* Cannot be called inside a transaction */
Jan Karab85f4b82008-07-25 01:46:50 -0700264static inline int vfs_dq_off(struct super_block *sb, int remount)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265{
266 int ret = -ENOSYS;
267
Jan Kara0ff5af82008-04-28 02:14:33 -0700268 if (sb->s_qcop && sb->s_qcop->quota_off)
269 ret = sb->s_qcop->quota_off(sb, -1, remount);
270 return ret;
271}
272
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273#else
274
Jan Karaf55abc02008-08-20 17:50:32 +0200275static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type)
Jan Kara03b06342008-07-25 01:46:52 -0700276{
277 return 0;
278}
279
Jan Karaf55abc02008-08-20 17:50:32 +0200280static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type)
Jan Kara03b06342008-07-25 01:46:52 -0700281{
282 return 0;
283}
284
285static inline int sb_has_quota_suspended(struct super_block *sb, int type)
286{
287 return 0;
288}
289
290static inline int sb_any_quota_suspended(struct super_block *sb)
291{
292 return 0;
293}
Jan Kara74abb982008-07-25 01:46:51 -0700294
Jan Karaf55abc02008-08-20 17:50:32 +0200295/* Does kernel know about any quota information for given sb + type? */
296static inline int sb_has_quota_loaded(struct super_block *sb, int type)
297{
298 return 0;
299}
300
301static inline int sb_any_quota_loaded(struct super_block *sb)
302{
303 return 0;
304}
305
306static inline int sb_has_quota_active(struct super_block *sb, int type)
307{
308 return 0;
309}
310
311static inline int sb_any_quota_active(struct super_block *sb)
312{
313 return 0;
314}
315
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316/*
317 * NO-OP when quota not configured.
318 */
319#define sb_dquot_ops (NULL)
320#define sb_quotactl_ops (NULL)
Andrew Morton50f8c372008-04-28 02:14:35 -0700321
Jan Karab85f4b82008-07-25 01:46:50 -0700322static inline void vfs_dq_init(struct inode *inode)
Andrew Morton50f8c372008-04-28 02:14:35 -0700323{
324}
325
Jan Karab85f4b82008-07-25 01:46:50 -0700326static inline void vfs_dq_drop(struct inode *inode)
Andrew Morton50f8c372008-04-28 02:14:35 -0700327{
328}
329
Jan Karab85f4b82008-07-25 01:46:50 -0700330static inline int vfs_dq_alloc_inode(struct inode *inode)
Andrew Morton50f8c372008-04-28 02:14:35 -0700331{
332 return 0;
333}
334
Jan Karab85f4b82008-07-25 01:46:50 -0700335static inline void vfs_dq_free_inode(struct inode *inode)
Andrew Morton50f8c372008-04-28 02:14:35 -0700336{
337}
338
Jan Karab85f4b82008-07-25 01:46:50 -0700339static inline int vfs_dq_off(struct super_block *sb, int remount)
Andrew Morton50f8c372008-04-28 02:14:35 -0700340{
341 return 0;
342}
343
Jan Karab85f4b82008-07-25 01:46:50 -0700344static inline int vfs_dq_quota_on_remount(struct super_block *sb)
Andrew Morton50f8c372008-04-28 02:14:35 -0700345{
346 return 0;
347}
348
Jan Karab85f4b82008-07-25 01:46:50 -0700349static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr)
Andrew Morton50f8c372008-04-28 02:14:35 -0700350{
351 return 0;
352}
353
Jan Karab85f4b82008-07-25 01:46:50 -0700354static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
356 inode_add_bytes(inode, nr);
357 return 0;
358}
359
Jan Karab85f4b82008-07-25 01:46:50 -0700360static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361{
Jan Karab85f4b82008-07-25 01:46:50 -0700362 vfs_dq_prealloc_space_nodirty(inode, nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 mark_inode_dirty(inode);
364 return 0;
365}
366
Jan Karab85f4b82008-07-25 01:46:50 -0700367static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368{
369 inode_add_bytes(inode, nr);
370 return 0;
371}
372
Jan Karab85f4b82008-07-25 01:46:50 -0700373static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374{
Jan Karab85f4b82008-07-25 01:46:50 -0700375 vfs_dq_alloc_space_nodirty(inode, nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 mark_inode_dirty(inode);
377 return 0;
378}
379
Mingming Caof18df222009-01-13 16:43:09 +0100380static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
381{
382 return 0;
383}
384
Mingming Cao740d9dc2009-01-13 16:43:14 +0100385static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
386{
387 return vfs_dq_alloc_space(inode, nr);
388}
389
390static inline
391int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
392{
393 return 0;
394}
395
Jan Karab85f4b82008-07-25 01:46:50 -0700396static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397{
398 inode_sub_bytes(inode, nr);
399}
400
Jan Karab85f4b82008-07-25 01:46:50 -0700401static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402{
Jan Karab85f4b82008-07-25 01:46:50 -0700403 vfs_dq_free_space_nodirty(inode, nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 mark_inode_dirty(inode);
405}
406
407#endif /* CONFIG_QUOTA */
408
Jan Karab85f4b82008-07-25 01:46:50 -0700409static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
Jan Kara03f6e922008-04-28 02:14:32 -0700410{
Mingming Cao9900ba32009-01-14 16:18:57 +0100411 return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits);
Jan Kara03f6e922008-04-28 02:14:32 -0700412}
413
Jan Karab85f4b82008-07-25 01:46:50 -0700414static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr)
Jan Kara03f6e922008-04-28 02:14:32 -0700415{
Mingming Cao9900ba32009-01-14 16:18:57 +0100416 return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits);
Jan Kara03f6e922008-04-28 02:14:32 -0700417}
418
Jan Karab85f4b82008-07-25 01:46:50 -0700419static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr)
Jan Kara03f6e922008-04-28 02:14:32 -0700420{
Mingming Cao9900ba32009-01-14 16:18:57 +0100421 return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits);
Jan Kara03f6e922008-04-28 02:14:32 -0700422}
423
Jan Karab85f4b82008-07-25 01:46:50 -0700424static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr)
Jan Kara03f6e922008-04-28 02:14:32 -0700425{
Mingming Cao9900ba32009-01-14 16:18:57 +0100426 return vfs_dq_alloc_space(inode, nr << inode->i_blkbits);
Jan Kara03f6e922008-04-28 02:14:32 -0700427}
428
Mingming Caof18df222009-01-13 16:43:09 +0100429static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr)
430{
Mingming Cao9900ba32009-01-14 16:18:57 +0100431 return vfs_dq_reserve_space(inode, nr << inode->i_blkbits);
Mingming Caof18df222009-01-13 16:43:09 +0100432}
433
Mingming Cao740d9dc2009-01-13 16:43:14 +0100434static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr)
435{
Mingming Cao9900ba32009-01-14 16:18:57 +0100436 return vfs_dq_claim_space(inode, nr << inode->i_blkbits);
Mingming Cao740d9dc2009-01-13 16:43:14 +0100437}
438
439static inline
440void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr)
441{
442 vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits);
443}
444
Jan Karab85f4b82008-07-25 01:46:50 -0700445static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr)
Jan Kara03f6e922008-04-28 02:14:32 -0700446{
Mingming Cao9900ba32009-01-14 16:18:57 +0100447 vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits);
Jan Kara03f6e922008-04-28 02:14:32 -0700448}
449
Jan Karab85f4b82008-07-25 01:46:50 -0700450static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr)
Jan Kara03f6e922008-04-28 02:14:32 -0700451{
Mingming Cao9900ba32009-01-14 16:18:57 +0100452 vfs_dq_free_space(inode, nr << inode->i_blkbits);
Jan Kara03f6e922008-04-28 02:14:32 -0700453}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455#endif /* _LINUX_QUOTAOPS_ */