aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/quotaops.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/quotaops.h')
-rw-r--r--include/linux/quotaops.h114
1 files changed, 61 insertions, 53 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 370abb1e99cb..aa36793b48bd 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -9,6 +9,10 @@
9 9
10#include <linux/fs.h> 10#include <linux/fs.h>
11 11
12#define DQUOT_SPACE_WARN 0x1
13#define DQUOT_SPACE_RESERVE 0x2
14#define DQUOT_SPACE_NOFAIL 0x4
15
12static inline struct quota_info *sb_dqopt(struct super_block *sb) 16static inline struct quota_info *sb_dqopt(struct super_block *sb)
13{ 17{
14 return &sb->s_dquot; 18 return &sb->s_dquot;
@@ -41,15 +45,22 @@ int dquot_scan_active(struct super_block *sb,
41struct dquot *dquot_alloc(struct super_block *sb, int type); 45struct dquot *dquot_alloc(struct super_block *sb, int type);
42void dquot_destroy(struct dquot *dquot); 46void dquot_destroy(struct dquot *dquot);
43 47
44int __dquot_alloc_space(struct inode *inode, qsize_t number, 48int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags);
45 int warn, int reserve); 49void __dquot_free_space(struct inode *inode, qsize_t number, int flags);
46void __dquot_free_space(struct inode *inode, qsize_t number, int reserve);
47 50
48int dquot_alloc_inode(const struct inode *inode); 51int dquot_alloc_inode(const struct inode *inode);
49 52
50int dquot_claim_space_nodirty(struct inode *inode, qsize_t number); 53int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
51void dquot_free_inode(const struct inode *inode); 54void dquot_free_inode(const struct inode *inode);
52 55
56int dquot_disable(struct super_block *sb, int type, unsigned int flags);
57/* Suspend quotas on remount RO */
58static inline int dquot_suspend(struct super_block *sb, int type)
59{
60 return dquot_disable(sb, type, DQUOT_SUSPENDED);
61}
62int dquot_resume(struct super_block *sb, int type);
63
53int dquot_commit(struct dquot *dquot); 64int dquot_commit(struct dquot *dquot);
54int dquot_acquire(struct dquot *dquot); 65int dquot_acquire(struct dquot *dquot);
55int dquot_release(struct dquot *dquot); 66int dquot_release(struct dquot *dquot);
@@ -58,27 +69,25 @@ int dquot_mark_dquot_dirty(struct dquot *dquot);
58 69
59int dquot_file_open(struct inode *inode, struct file *file); 70int dquot_file_open(struct inode *inode, struct file *file);
60 71
61int vfs_quota_on(struct super_block *sb, int type, int format_id, 72int dquot_quota_on(struct super_block *sb, int type, int format_id,
62 char *path, int remount); 73 char *path);
63int vfs_quota_enable(struct inode *inode, int type, int format_id, 74int dquot_enable(struct inode *inode, int type, int format_id,
64 unsigned int flags); 75 unsigned int flags);
65int vfs_quota_on_path(struct super_block *sb, int type, int format_id, 76int dquot_quota_on_path(struct super_block *sb, int type, int format_id,
66 struct path *path); 77 struct path *path);
67int vfs_quota_on_mount(struct super_block *sb, char *qf_name, 78int dquot_quota_on_mount(struct super_block *sb, char *qf_name,
68 int format_id, int type); 79 int format_id, int type);
69int vfs_quota_off(struct super_block *sb, int type, int remount); 80int dquot_quota_off(struct super_block *sb, int type);
70int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); 81int dquot_quota_sync(struct super_block *sb, int type, int wait);
71int vfs_quota_sync(struct super_block *sb, int type, int wait); 82int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
72int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 83int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
73int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 84int dquot_get_dqblk(struct super_block *sb, int type, qid_t id,
74int vfs_get_dqblk(struct super_block *sb, int type, qid_t id,
75 struct fs_disk_quota *di); 85 struct fs_disk_quota *di);
76int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, 86int dquot_set_dqblk(struct super_block *sb, int type, qid_t id,
77 struct fs_disk_quota *di); 87 struct fs_disk_quota *di);
78 88
79int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); 89int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
80int dquot_transfer(struct inode *inode, struct iattr *iattr); 90int dquot_transfer(struct inode *inode, struct iattr *iattr);
81int vfs_dq_quota_on_remount(struct super_block *sb);
82 91
83static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) 92static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
84{ 93{
@@ -145,20 +154,7 @@ static inline unsigned sb_any_quota_active(struct super_block *sb)
145 * Operations supported for diskquotas. 154 * Operations supported for diskquotas.
146 */ 155 */
147extern const struct dquot_operations dquot_operations; 156extern const struct dquot_operations dquot_operations;
148extern const struct quotactl_ops vfs_quotactl_ops; 157extern const struct quotactl_ops dquot_quotactl_ops;
149
150#define sb_dquot_ops (&dquot_operations)
151#define sb_quotactl_ops (&vfs_quotactl_ops)
152
153/* Cannot be called inside a transaction */
154static inline int vfs_dq_off(struct super_block *sb, int remount)
155{
156 int ret = -ENOSYS;
157
158 if (sb->s_qcop && sb->s_qcop->quota_off)
159 ret = sb->s_qcop->quota_off(sb, -1, remount);
160 return ret;
161}
162 158
163#else 159#else
164 160
@@ -203,12 +199,6 @@ static inline int sb_any_quota_active(struct super_block *sb)
203 return 0; 199 return 0;
204} 200}
205 201
206/*
207 * NO-OP when quota not configured.
208 */
209#define sb_dquot_ops (NULL)
210#define sb_quotactl_ops (NULL)
211
212static inline void dquot_initialize(struct inode *inode) 202static inline void dquot_initialize(struct inode *inode)
213{ 203{
214} 204}
@@ -226,39 +216,45 @@ static inline void dquot_free_inode(const struct inode *inode)
226{ 216{
227} 217}
228 218
229static inline int vfs_dq_off(struct super_block *sb, int remount) 219static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
230{ 220{
231 return 0; 221 return 0;
232} 222}
233 223
234static inline int vfs_dq_quota_on_remount(struct super_block *sb) 224static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
225 int flags)
235{ 226{
227 if (!(flags & DQUOT_SPACE_RESERVE))
228 inode_add_bytes(inode, number);
236 return 0; 229 return 0;
237} 230}
238 231
239static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) 232static inline void __dquot_free_space(struct inode *inode, qsize_t number,
233 int flags)
234{
235 if (!(flags & DQUOT_SPACE_RESERVE))
236 inode_sub_bytes(inode, number);
237}
238
239static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
240{ 240{
241 inode_add_bytes(inode, number);
241 return 0; 242 return 0;
242} 243}
243 244
244static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, 245static inline int dquot_disable(struct super_block *sb, int type,
245 int warn, int reserve) 246 unsigned int flags)
246{ 247{
247 if (!reserve)
248 inode_add_bytes(inode, number);
249 return 0; 248 return 0;
250} 249}
251 250
252static inline void __dquot_free_space(struct inode *inode, qsize_t number, 251static inline int dquot_suspend(struct super_block *sb, int type)
253 int reserve)
254{ 252{
255 if (!reserve) 253 return 0;
256 inode_sub_bytes(inode, number);
257} 254}
258 255
259static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) 256static inline int dquot_resume(struct super_block *sb, int type)
260{ 257{
261 inode_add_bytes(inode, number);
262 return 0; 258 return 0;
263} 259}
264 260
@@ -268,7 +264,13 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
268 264
269static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) 265static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
270{ 266{
271 return __dquot_alloc_space(inode, nr, 1, 0); 267 return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN);
268}
269
270static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr)
271{
272 __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL);
273 mark_inode_dirty(inode);
272} 274}
273 275
274static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) 276static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
@@ -286,6 +288,11 @@ static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr)
286 return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits); 288 return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits);
287} 289}
288 290
291static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr)
292{
293 dquot_alloc_space_nofail(inode, nr << inode->i_blkbits);
294}
295
289static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) 296static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
290{ 297{
291 return dquot_alloc_space(inode, nr << inode->i_blkbits); 298 return dquot_alloc_space(inode, nr << inode->i_blkbits);
@@ -293,7 +300,7 @@ static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
293 300
294static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) 301static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
295{ 302{
296 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0); 303 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0);
297} 304}
298 305
299static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) 306static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
@@ -308,7 +315,8 @@ static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
308 315
309static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) 316static inline int dquot_reserve_block(struct inode *inode, qsize_t nr)
310{ 317{
311 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1); 318 return __dquot_alloc_space(inode, nr << inode->i_blkbits,
319 DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE);
312} 320}
313 321
314static inline int dquot_claim_block(struct inode *inode, qsize_t nr) 322static inline int dquot_claim_block(struct inode *inode, qsize_t nr)
@@ -345,7 +353,7 @@ static inline void dquot_free_block(struct inode *inode, qsize_t nr)
345static inline void dquot_release_reservation_block(struct inode *inode, 353static inline void dquot_release_reservation_block(struct inode *inode,
346 qsize_t nr) 354 qsize_t nr)
347{ 355{
348 __dquot_free_space(inode, nr << inode->i_blkbits, 1); 356 __dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE);
349} 357}
350 358
351#endif /* _LINUX_QUOTAOPS_ */ 359#endif /* _LINUX_QUOTAOPS_ */