diff options
Diffstat (limited to 'include/linux/quotaops.h')
-rw-r--r-- | include/linux/quotaops.h | 119 |
1 files changed, 78 insertions, 41 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 0b35b3a1be05..36353d95c8db 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
@@ -35,6 +35,11 @@ void dquot_destroy(struct dquot *dquot); | |||
35 | int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); | 35 | int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); |
36 | int dquot_alloc_inode(const struct inode *inode, qsize_t number); | 36 | int dquot_alloc_inode(const struct inode *inode, qsize_t number); |
37 | 37 | ||
38 | int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc); | ||
39 | int dquot_claim_space(struct inode *inode, qsize_t number); | ||
40 | void dquot_release_reserved_space(struct inode *inode, qsize_t number); | ||
41 | qsize_t dquot_get_reserved_space(struct inode *inode); | ||
42 | |||
38 | int dquot_free_space(struct inode *inode, qsize_t number); | 43 | int dquot_free_space(struct inode *inode, qsize_t number); |
39 | int dquot_free_inode(const struct inode *inode, qsize_t number); | 44 | int dquot_free_inode(const struct inode *inode, qsize_t number); |
40 | 45 | ||
@@ -183,6 +188,16 @@ static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | |||
183 | return ret; | 188 | return ret; |
184 | } | 189 | } |
185 | 190 | ||
191 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | ||
192 | { | ||
193 | if (sb_any_quota_active(inode->i_sb)) { | ||
194 | /* Used space is updated in alloc_space() */ | ||
195 | if (inode->i_sb->dq_op->reserve_space(inode, nr, 0) == NO_QUOTA) | ||
196 | return 1; | ||
197 | } | ||
198 | return 0; | ||
199 | } | ||
200 | |||
186 | static inline int vfs_dq_alloc_inode(struct inode *inode) | 201 | static inline int vfs_dq_alloc_inode(struct inode *inode) |
187 | { | 202 | { |
188 | if (sb_any_quota_active(inode->i_sb)) { | 203 | if (sb_any_quota_active(inode->i_sb)) { |
@@ -193,6 +208,31 @@ static inline int vfs_dq_alloc_inode(struct inode *inode) | |||
193 | return 0; | 208 | return 0; |
194 | } | 209 | } |
195 | 210 | ||
211 | /* | ||
212 | * Convert in-memory reserved quotas to real consumed quotas | ||
213 | */ | ||
214 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) | ||
215 | { | ||
216 | if (sb_any_quota_active(inode->i_sb)) { | ||
217 | if (inode->i_sb->dq_op->claim_space(inode, nr) == NO_QUOTA) | ||
218 | return 1; | ||
219 | } else | ||
220 | inode_add_bytes(inode, nr); | ||
221 | |||
222 | mark_inode_dirty(inode); | ||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | /* | ||
227 | * Release reserved (in-memory) quotas | ||
228 | */ | ||
229 | static inline | ||
230 | void vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) | ||
231 | { | ||
232 | if (sb_any_quota_active(inode->i_sb)) | ||
233 | inode->i_sb->dq_op->release_rsv(inode, nr); | ||
234 | } | ||
235 | |||
196 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | 236 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) |
197 | { | 237 | { |
198 | if (sb_any_quota_active(inode->i_sb)) | 238 | if (sb_any_quota_active(inode->i_sb)) |
@@ -339,6 +379,22 @@ static inline int vfs_dq_alloc_space(struct inode *inode, qsize_t nr) | |||
339 | return 0; | 379 | return 0; |
340 | } | 380 | } |
341 | 381 | ||
382 | static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | ||
383 | { | ||
384 | return 0; | ||
385 | } | ||
386 | |||
387 | static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr) | ||
388 | { | ||
389 | return vfs_dq_alloc_space(inode, nr); | ||
390 | } | ||
391 | |||
392 | static inline | ||
393 | int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr) | ||
394 | { | ||
395 | return 0; | ||
396 | } | ||
397 | |||
342 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) | 398 | static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) |
343 | { | 399 | { |
344 | inode_sub_bytes(inode, nr); | 400 | inode_sub_bytes(inode, nr); |
@@ -354,67 +410,48 @@ static inline void vfs_dq_free_space(struct inode *inode, qsize_t nr) | |||
354 | 410 | ||
355 | static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) | 411 | static inline int vfs_dq_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
356 | { | 412 | { |
357 | return vfs_dq_prealloc_space_nodirty(inode, | 413 | return vfs_dq_prealloc_space_nodirty(inode, nr << inode->i_blkbits); |
358 | nr << inode->i_sb->s_blocksize_bits); | ||
359 | } | 414 | } |
360 | 415 | ||
361 | static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) | 416 | static inline int vfs_dq_prealloc_block(struct inode *inode, qsize_t nr) |
362 | { | 417 | { |
363 | return vfs_dq_prealloc_space(inode, | 418 | return vfs_dq_prealloc_space(inode, nr << inode->i_blkbits); |
364 | nr << inode->i_sb->s_blocksize_bits); | ||
365 | } | 419 | } |
366 | 420 | ||
367 | static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) | 421 | static inline int vfs_dq_alloc_block_nodirty(struct inode *inode, qsize_t nr) |
368 | { | 422 | { |
369 | return vfs_dq_alloc_space_nodirty(inode, | 423 | return vfs_dq_alloc_space_nodirty(inode, nr << inode->i_blkbits); |
370 | nr << inode->i_sb->s_blocksize_bits); | ||
371 | } | 424 | } |
372 | 425 | ||
373 | static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) | 426 | static inline int vfs_dq_alloc_block(struct inode *inode, qsize_t nr) |
374 | { | 427 | { |
375 | return vfs_dq_alloc_space(inode, | 428 | return vfs_dq_alloc_space(inode, nr << inode->i_blkbits); |
376 | nr << inode->i_sb->s_blocksize_bits); | 429 | } |
430 | |||
431 | static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) | ||
432 | { | ||
433 | return vfs_dq_reserve_space(inode, nr << inode->i_blkbits); | ||
434 | } | ||
435 | |||
436 | static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) | ||
437 | { | ||
438 | return vfs_dq_claim_space(inode, nr << inode->i_blkbits); | ||
439 | } | ||
440 | |||
441 | static inline | ||
442 | void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr) | ||
443 | { | ||
444 | vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); | ||
377 | } | 445 | } |
378 | 446 | ||
379 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) | 447 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) |
380 | { | 448 | { |
381 | vfs_dq_free_space_nodirty(inode, nr << inode->i_sb->s_blocksize_bits); | 449 | vfs_dq_free_space_nodirty(inode, nr << inode->i_blkbits); |
382 | } | 450 | } |
383 | 451 | ||
384 | static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) | 452 | static inline void vfs_dq_free_block(struct inode *inode, qsize_t nr) |
385 | { | 453 | { |
386 | vfs_dq_free_space(inode, nr << inode->i_sb->s_blocksize_bits); | 454 | vfs_dq_free_space(inode, nr << inode->i_blkbits); |
387 | } | 455 | } |
388 | 456 | ||
389 | /* | ||
390 | * Define uppercase equivalents for compatibility with old function names | ||
391 | * Can go away when we think all users have been converted (15/04/2008) | ||
392 | */ | ||
393 | #define DQUOT_INIT(inode) vfs_dq_init(inode) | ||
394 | #define DQUOT_DROP(inode) vfs_dq_drop(inode) | ||
395 | #define DQUOT_PREALLOC_SPACE_NODIRTY(inode, nr) \ | ||
396 | vfs_dq_prealloc_space_nodirty(inode, nr) | ||
397 | #define DQUOT_PREALLOC_SPACE(inode, nr) vfs_dq_prealloc_space(inode, nr) | ||
398 | #define DQUOT_ALLOC_SPACE_NODIRTY(inode, nr) \ | ||
399 | vfs_dq_alloc_space_nodirty(inode, nr) | ||
400 | #define DQUOT_ALLOC_SPACE(inode, nr) vfs_dq_alloc_space(inode, nr) | ||
401 | #define DQUOT_PREALLOC_BLOCK_NODIRTY(inode, nr) \ | ||
402 | vfs_dq_prealloc_block_nodirty(inode, nr) | ||
403 | #define DQUOT_PREALLOC_BLOCK(inode, nr) vfs_dq_prealloc_block(inode, nr) | ||
404 | #define DQUOT_ALLOC_BLOCK_NODIRTY(inode, nr) \ | ||
405 | vfs_dq_alloc_block_nodirty(inode, nr) | ||
406 | #define DQUOT_ALLOC_BLOCK(inode, nr) vfs_dq_alloc_block(inode, nr) | ||
407 | #define DQUOT_ALLOC_INODE(inode) vfs_dq_alloc_inode(inode) | ||
408 | #define DQUOT_FREE_SPACE_NODIRTY(inode, nr) \ | ||
409 | vfs_dq_free_space_nodirty(inode, nr) | ||
410 | #define DQUOT_FREE_SPACE(inode, nr) vfs_dq_free_space(inode, nr) | ||
411 | #define DQUOT_FREE_BLOCK_NODIRTY(inode, nr) \ | ||
412 | vfs_dq_free_block_nodirty(inode, nr) | ||
413 | #define DQUOT_FREE_BLOCK(inode, nr) vfs_dq_free_block(inode, nr) | ||
414 | #define DQUOT_FREE_INODE(inode) vfs_dq_free_inode(inode) | ||
415 | #define DQUOT_TRANSFER(inode, iattr) vfs_dq_transfer(inode, iattr) | ||
416 | #define DQUOT_SYNC(sb) vfs_dq_sync(sb) | ||
417 | #define DQUOT_OFF(sb, remount) vfs_dq_off(sb, remount) | ||
418 | #define DQUOT_ON_REMOUNT(sb) vfs_dq_quota_on_remount(sb) | ||
419 | |||
420 | #endif /* _LINUX_QUOTAOPS_ */ | 457 | #endif /* _LINUX_QUOTAOPS_ */ |