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.h304
1 files changed, 92 insertions, 212 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 3ebb2315364..e6fa7acce29 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -19,15 +19,12 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb)
19/* 19/*
20 * declaration of quota_function calls in kernel. 20 * declaration of quota_function calls in kernel.
21 */ 21 */
22void sync_quota_sb(struct super_block *sb, int type); 22void inode_add_rsv_space(struct inode *inode, qsize_t number);
23static inline void writeout_quota_sb(struct super_block *sb, int type) 23void inode_claim_rsv_space(struct inode *inode, qsize_t number);
24{ 24void inode_sub_rsv_space(struct inode *inode, qsize_t number);
25 if (sb->s_qcop->quota_sync)
26 sb->s_qcop->quota_sync(sb, type);
27}
28 25
29int dquot_initialize(struct inode *inode, int type); 26void dquot_initialize(struct inode *inode);
30int dquot_drop(struct inode *inode); 27void dquot_drop(struct inode *inode);
31struct dquot *dqget(struct super_block *sb, unsigned int id, int type); 28struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
32void dqput(struct dquot *dquot); 29void dqput(struct dquot *dquot);
33int dquot_scan_active(struct super_block *sb, 30int dquot_scan_active(struct super_block *sb,
@@ -36,24 +33,23 @@ int dquot_scan_active(struct super_block *sb,
36struct dquot *dquot_alloc(struct super_block *sb, int type); 33struct dquot *dquot_alloc(struct super_block *sb, int type);
37void dquot_destroy(struct dquot *dquot); 34void dquot_destroy(struct dquot *dquot);
38 35
39int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); 36int __dquot_alloc_space(struct inode *inode, qsize_t number,
40int dquot_alloc_inode(const struct inode *inode, qsize_t number); 37 int warn, int reserve);
38void __dquot_free_space(struct inode *inode, qsize_t number, int reserve);
41 39
42int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc); 40int dquot_alloc_inode(const struct inode *inode);
43int dquot_claim_space(struct inode *inode, qsize_t number);
44void dquot_release_reserved_space(struct inode *inode, qsize_t number);
45qsize_t dquot_get_reserved_space(struct inode *inode);
46 41
47int dquot_free_space(struct inode *inode, qsize_t number); 42int dquot_claim_space_nodirty(struct inode *inode, qsize_t number);
48int dquot_free_inode(const struct inode *inode, qsize_t number); 43void dquot_free_inode(const struct inode *inode);
49 44
50int dquot_transfer(struct inode *inode, struct iattr *iattr);
51int dquot_commit(struct dquot *dquot); 45int dquot_commit(struct dquot *dquot);
52int dquot_acquire(struct dquot *dquot); 46int dquot_acquire(struct dquot *dquot);
53int dquot_release(struct dquot *dquot); 47int dquot_release(struct dquot *dquot);
54int dquot_commit_info(struct super_block *sb, int type); 48int dquot_commit_info(struct super_block *sb, int type);
55int dquot_mark_dquot_dirty(struct dquot *dquot); 49int dquot_mark_dquot_dirty(struct dquot *dquot);
56 50
51int dquot_file_open(struct inode *inode, struct file *file);
52
57int vfs_quota_on(struct super_block *sb, int type, int format_id, 53int vfs_quota_on(struct super_block *sb, int type, int format_id,
58 char *path, int remount); 54 char *path, int remount);
59int vfs_quota_enable(struct inode *inode, int type, int format_id, 55int vfs_quota_enable(struct inode *inode, int type, int format_id,
@@ -64,14 +60,13 @@ int vfs_quota_on_mount(struct super_block *sb, char *qf_name,
64 int format_id, int type); 60 int format_id, int type);
65int vfs_quota_off(struct super_block *sb, int type, int remount); 61int vfs_quota_off(struct super_block *sb, int type, int remount);
66int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags); 62int vfs_quota_disable(struct super_block *sb, int type, unsigned int flags);
67int vfs_quota_sync(struct super_block *sb, int type); 63int vfs_quota_sync(struct super_block *sb, int type, int wait);
68int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 64int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
69int vfs_set_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);
70int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di); 66int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *di);
71int vfs_set_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);
72 68
73void vfs_dq_drop(struct inode *inode); 69int dquot_transfer(struct inode *inode, struct iattr *iattr);
74int vfs_dq_transfer(struct inode *inode, struct iattr *iattr);
75int vfs_dq_quota_on_remount(struct super_block *sb); 70int vfs_dq_quota_on_remount(struct super_block *sb);
76 71
77static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) 72static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
@@ -83,53 +78,56 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
83 * Functions for checking status of quota 78 * Functions for checking status of quota
84 */ 79 */
85 80
86static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) 81static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type)
87{ 82{
88 return sb_dqopt(sb)->flags & 83 return sb_dqopt(sb)->flags &
89 dquot_state_flag(DQUOT_USAGE_ENABLED, type); 84 dquot_state_flag(DQUOT_USAGE_ENABLED, type);
90} 85}
91 86
92static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type) 87static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type)
93{ 88{
94 return sb_dqopt(sb)->flags & 89 return sb_dqopt(sb)->flags &
95 dquot_state_flag(DQUOT_LIMITS_ENABLED, type); 90 dquot_state_flag(DQUOT_LIMITS_ENABLED, type);
96} 91}
97 92
98static inline int sb_has_quota_suspended(struct super_block *sb, int type) 93static inline bool sb_has_quota_suspended(struct super_block *sb, int type)
99{ 94{
100 return sb_dqopt(sb)->flags & 95 return sb_dqopt(sb)->flags &
101 dquot_state_flag(DQUOT_SUSPENDED, type); 96 dquot_state_flag(DQUOT_SUSPENDED, type);
102} 97}
103 98
104static inline int sb_any_quota_suspended(struct super_block *sb) 99static inline unsigned sb_any_quota_suspended(struct super_block *sb)
105{ 100{
106 return sb_has_quota_suspended(sb, USRQUOTA) || 101 unsigned type, tmsk = 0;
107 sb_has_quota_suspended(sb, GRPQUOTA); 102 for (type = 0; type < MAXQUOTAS; type++)
103 tmsk |= sb_has_quota_suspended(sb, type) << type;
104 return tmsk;
108} 105}
109 106
110/* Does kernel know about any quota information for given sb + type? */ 107/* Does kernel know about any quota information for given sb + type? */
111static inline int sb_has_quota_loaded(struct super_block *sb, int type) 108static inline bool sb_has_quota_loaded(struct super_block *sb, int type)
112{ 109{
113 /* Currently if anything is on, then quota usage is on as well */ 110 /* Currently if anything is on, then quota usage is on as well */
114 return sb_has_quota_usage_enabled(sb, type); 111 return sb_has_quota_usage_enabled(sb, type);
115} 112}
116 113
117static inline int sb_any_quota_loaded(struct super_block *sb) 114static inline unsigned sb_any_quota_loaded(struct super_block *sb)
118{ 115{
119 return sb_has_quota_loaded(sb, USRQUOTA) || 116 unsigned type, tmsk = 0;
120 sb_has_quota_loaded(sb, GRPQUOTA); 117 for (type = 0; type < MAXQUOTAS; type++)
118 tmsk |= sb_has_quota_loaded(sb, type) << type;
119 return tmsk;
121} 120}
122 121
123static inline int sb_has_quota_active(struct super_block *sb, int type) 122static inline bool sb_has_quota_active(struct super_block *sb, int type)
124{ 123{
125 return sb_has_quota_loaded(sb, type) && 124 return sb_has_quota_loaded(sb, type) &&
126 !sb_has_quota_suspended(sb, type); 125 !sb_has_quota_suspended(sb, type);
127} 126}
128 127
129static inline int sb_any_quota_active(struct super_block *sb) 128static inline unsigned sb_any_quota_active(struct super_block *sb)
130{ 129{
131 return sb_has_quota_active(sb, USRQUOTA) || 130 return sb_any_quota_loaded(sb) & ~sb_any_quota_suspended(sb);
132 sb_has_quota_active(sb, GRPQUOTA);
133} 131}
134 132
135/* 133/*
@@ -141,122 +139,6 @@ extern const struct quotactl_ops vfs_quotactl_ops;
141#define sb_dquot_ops (&dquot_operations) 139#define sb_dquot_ops (&dquot_operations)
142#define sb_quotactl_ops (&vfs_quotactl_ops) 140#define sb_quotactl_ops (&vfs_quotactl_ops)
143 141
144/* It is better to call this function outside of any transaction as it might
145 * need a lot of space in journal for dquot structure allocation. */
146static inline void vfs_dq_init(struct inode *inode)
147{
148 BUG_ON(!inode->i_sb);
149 if (sb_any_quota_active(inode->i_sb) && !IS_NOQUOTA(inode))
150 inode->i_sb->dq_op->initialize(inode, -1);
151}
152
153/* The following allocation/freeing/transfer functions *must* be called inside
154 * a transaction (deadlocks possible otherwise) */
155static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr)
156{
157 if (sb_any_quota_active(inode->i_sb)) {
158 /* Used space is updated in alloc_space() */
159 if (inode->i_sb->dq_op->alloc_space(inode, nr, 1) == NO_QUOTA)
160 return 1;
161 }
162 else
163 inode_add_bytes(inode, nr);
164 return 0;
165}
166
167static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr)
168{
169 int ret;
170 if (!(ret = vfs_dq_prealloc_space_nodirty(inode, nr)))
171 mark_inode_dirty(inode);
172 return ret;
173}
174
175static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr)
176{
177 if (sb_any_quota_active(inode->i_sb)) {
178 /* Used space is updated in alloc_space() */
179 if (inode->i_sb->dq_op->alloc_space(inode, nr, 0) == NO_QUOTA)
180 return 1;
181 }
182 else
183 inode_add_bytes(inode, nr);
184 return 0;
185}
186
187static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr)
188{
189 int ret;
190 if (!(ret = vfs_dq_alloc_space_nodirty(inode, nr)))
191 mark_inode_dirty(inode);
192 return ret;
193}
194
195static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr)
196{
197 if (sb_any_quota_active(inode->i_sb)) {
198 /* Used space is updated in alloc_space() */
199 if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA)
200 return 1;
201 }
202 return 0;
203}
204
205static inline int vfs_dq_alloc_inode(struct inode *inode)
206{
207 if (sb_any_quota_active(inode->i_sb)) {
208 vfs_dq_init(inode);
209 if (inode->i_sb->dq_op->alloc_inode(inode, 1) == NO_QUOTA)
210 return 1;
211 }
212 return 0;
213}
214
215/*
216 * Convert in-memory reserved quotas to real consumed quotas
217 */
218static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
219{
220 if (sb_any_quota_active(inode->i_sb)) {
221 if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA)
222 return 1;
223 } else
224 inode_add_bytes(inode, nr);
225
226 mark_inode_dirty(inode);
227 return 0;
228}
229
230/*
231 * Release reserved (in-memory) quotas
232 */
233static inline
234void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
235{
236 if (sb_any_quota_active(inode->i_sb))
237 inode->i_sb->dq_op->release_rsv(inode, nr);
238}
239
240static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr)
241{
242 if (sb_any_quota_active(inode->i_sb))
243 inode->i_sb->dq_op->free_space(inode, nr);
244 else
245 inode_sub_bytes(inode, nr);
246}
247
248static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr)
249{
250 vfs_dq_free_space_nodirty(inode, nr);
251 mark_inode_dirty(inode);
252}
253
254static inline void vfs_dq_free_inode(struct inode *inode)
255{
256 if (sb_any_quota_active(inode->i_sb))
257 inode->i_sb->dq_op->free_inode(inode, 1);
258}
259
260/* Cannot be called inside a transaction */ 142/* Cannot be called inside a transaction */
261static inline int vfs_dq_off(struct super_block *sb, int remount) 143static inline int vfs_dq_off(struct super_block *sb, int remount)
262{ 144{
@@ -316,28 +198,20 @@ static inline int sb_any_quota_active(struct super_block *sb)
316#define sb_dquot_ops (NULL) 198#define sb_dquot_ops (NULL)
317#define sb_quotactl_ops (NULL) 199#define sb_quotactl_ops (NULL)
318 200
319static inline void vfs_dq_init(struct inode *inode) 201static inline void dquot_initialize(struct inode *inode)
320{ 202{
321} 203}
322 204
323static inline void vfs_dq_drop(struct inode *inode) 205static inline void dquot_drop(struct inode *inode)
324{ 206{
325} 207}
326 208
327static inline int vfs_dq_alloc_inode(struct inode *inode) 209static inline int dquot_alloc_inode(const struct inode *inode)
328{ 210{
329 return 0; 211 return 0;
330} 212}
331 213
332static inline void vfs_dq_free_inode(struct inode *inode) 214static inline void dquot_free_inode(const struct inode *inode)
333{
334}
335
336static inline void sync_quota_sb(struct super_block *sb, int type)
337{
338}
339
340static inline void writeout_quota_sb(struct super_block *sb, int type)
341{ 215{
342} 216}
343 217
@@ -351,110 +225,116 @@ static inline int vfs_dq_quota_on_remount(struct super_block *sb)
351 return 0; 225 return 0;
352} 226}
353 227
354static inline int vfs_dq_transfer(struct inode *inode, struct iattr *iattr) 228static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
355{ 229{
356 return 0; 230 return 0;
357} 231}
358 232
359static inline int vfs_dq_prealloc_space_nodirty(struct inode *inode, qsize_t nr) 233static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
234 int warn, int reserve)
360{ 235{
361 inode_add_bytes(inode, nr); 236 if (!reserve)
237 inode_add_bytes(inode, number);
362 return 0; 238 return 0;
363} 239}
364 240
365static inline int vfs_dq_prealloc_space(struct inode *inode, qsize_t nr) 241static inline void __dquot_free_space(struct inode *inode, qsize_t number,
242 int reserve)
366{ 243{
367 vfs_dq_prealloc_space_nodirty(inode, nr); 244 if (!reserve)
368 mark_inode_dirty(inode); 245 inode_sub_bytes(inode, number);
369 return 0;
370} 246}
371 247
372static inline int vfs_dq_alloc_space_nodirty(struct inode *inode, qsize_t nr) 248static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
373{ 249{
374 inode_add_bytes(inode, nr); 250 inode_add_bytes(inode, number);
375 return 0; 251 return 0;
376} 252}
377 253
378static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) 254#define dquot_file_open generic_file_open
255
256#endif /* CONFIG_QUOTA */
257
258static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
379{ 259{
380 vfs_dq_alloc_space_nodirty(inode, nr); 260 return __dquot_alloc_space(inode, nr, 1, 0);
381 mark_inode_dirty(inode);
382 return 0;
383} 261}
384 262
385static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) 263static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
386{ 264{
387 return 0; 265 int ret;
266
267 ret = dquot_alloc_space_nodirty(inode, nr);
268 if (!ret)
269 mark_inode_dirty(inode);
270 return ret;
388} 271}
389 272
390static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) 273static inline int dquot_alloc_block_nodirty(struct inode *inode, qsize_t nr)
391{ 274{
392 return vfs_dq_alloc_space(inode, nr); 275 return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits);
393} 276}
394 277
395static inline 278static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
396int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
397{ 279{
398 return 0; 280 return dquot_alloc_space(inode, nr << inode->i_blkbits);
399} 281}
400 282
401static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) 283static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
402{ 284{
403 inode_sub_bytes(inode, nr); 285 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0);
404} 286}
405 287
406static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) 288static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
407{ 289{
408 vfs_dq_free_space_nodirty(inode, nr); 290 int ret;
409 mark_inode_dirty(inode);
410}
411
412#endif /* CONFIG_QUOTA */
413 291
414static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) 292 ret = dquot_prealloc_block_nodirty(inode, nr);
415{ 293 if (!ret)
416 return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits); 294 mark_inode_dirty(inode);
295 return ret;
417} 296}
418 297
419static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) 298static inline int dquot_reserve_block(struct inode *inode, qsize_t nr)
420{ 299{
421 return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits); 300 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1);
422} 301}
423 302
424static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) 303static inline int dquot_claim_block(struct inode *inode, qsize_t nr)
425{ 304{
426 return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits); 305 int ret;
427}
428 306
429static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) 307 ret = dquot_claim_space_nodirty(inode, nr << inode->i_blkbits);
430{ 308 if (!ret)
431 return vfs_dq_alloc_space(inode, nr << inode->i_blkbits); 309 mark_inode_dirty(inode);
310 return ret;
432} 311}
433 312
434static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) 313static inline void dquot_free_space_nodirty(struct inode *inode, qsize_t nr)
435{ 314{
436 return vfs_dq_reserve_space(inode, nr << inode->i_blkbits); 315 __dquot_free_space(inode, nr, 0);
437} 316}
438 317
439static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) 318static inline void dquot_free_space(struct inode *inode, qsize_t nr)
440{ 319{
441 return vfs_dq_claim_space(inode, nr << inode->i_blkbits); 320 dquot_free_space_nodirty(inode, nr);
321 mark_inode_dirty(inode);
442} 322}
443 323
444static inline 324static inline void dquot_free_block_nodirty(struct inode *inode, qsize_t nr)
445void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr)
446{ 325{
447 vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); 326 dquot_free_space_nodirty(inode, nr << inode->i_blkbits);
448} 327}
449 328
450static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) 329static inline void dquot_free_block(struct inode *inode, qsize_t nr)
451{ 330{
452 vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits); 331 dquot_free_space(inode, nr << inode->i_blkbits);
453} 332}
454 333
455static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) 334static inline void dquot_release_reservation_block(struct inode *inode,
335 qsize_t nr)
456{ 336{
457 vfs_dq_free_space(inode, nr << inode->i_blkbits); 337 __dquot_free_space(inode, nr << inode->i_blkbits, 1);
458} 338}
459 339
460#endif /* _LINUX_QUOTAOPS_ */ 340#endif /* _LINUX_QUOTAOPS_ */