diff options
author | Mingming Cao <cmm@us.ibm.com> | 2009-01-13 10:43:14 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2009-03-25 21:18:24 -0400 |
commit | 740d9dcd949a986c88886a591054a0cdb89ef669 (patch) | |
tree | 3a422d30c838c80d35b8d52a05a4c55d3c806e4e /include/linux/quotaops.h | |
parent | f18df228997fb716990590d248663981a15f17d4 (diff) |
quota: Add quota reservation claim and released operations
Reserved quota will be claimed at the block allocation time. Over-booked
quota could be returned back with the release callback function.
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'include/linux/quotaops.h')
-rw-r--r-- | include/linux/quotaops.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 3e3a0d2874d9..7369d04e0a86 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 | ||
@@ -203,6 +208,31 @@ static inline int vfs_dq_alloc_inode(struct inode *inode) | |||
203 | return 0; | 208 | return 0; |
204 | } | 209 | } |
205 | 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 | |||
206 | 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) |
207 | { | 237 | { |
208 | if (sb_any_quota_active(inode->i_sb)) | 238 | if (sb_any_quota_active(inode->i_sb)) |
@@ -354,6 +384,17 @@ static inline int vfs_dq_reserve_space(struct inode *inode, qsize_t nr) | |||
354 | return 0; | 384 | return 0; |
355 | } | 385 | } |
356 | 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 | |||
357 | 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) |
358 | { | 399 | { |
359 | inode_sub_bytes(inode, nr); | 400 | inode_sub_bytes(inode, nr); |
@@ -397,6 +438,18 @@ static inline int vfs_dq_reserve_block(struct inode *inode, qsize_t nr) | |||
397 | nr << inode->i_blkbits); | 438 | nr << inode->i_blkbits); |
398 | } | 439 | } |
399 | 440 | ||
441 | static inline int vfs_dq_claim_block(struct inode *inode, qsize_t nr) | ||
442 | { | ||
443 | return vfs_dq_claim_space(inode, | ||
444 | nr << inode->i_blkbits); | ||
445 | } | ||
446 | |||
447 | static inline | ||
448 | void vfs_dq_release_reservation_block(struct inode *inode, qsize_t nr) | ||
449 | { | ||
450 | vfs_dq_release_reservation_space(inode, nr << inode->i_blkbits); | ||
451 | } | ||
452 | |||
400 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) | 453 | static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) |
401 | { | 454 | { |
402 | vfs_dq_free_space_nodirty(inode, nr << inode->i_sb->s_blocksize_bits); | 455 | vfs_dq_free_space_nodirty(inode, nr << inode->i_sb->s_blocksize_bits); |