aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/quotaops.h
diff options
context:
space:
mode:
authorMingming Cao <cmm@us.ibm.com>2009-01-13 10:43:14 -0500
committerJan Kara <jack@suse.cz>2009-03-25 21:18:24 -0400
commit740d9dcd949a986c88886a591054a0cdb89ef669 (patch)
tree3a422d30c838c80d35b8d52a05a4c55d3c806e4e /include/linux/quotaops.h
parentf18df228997fb716990590d248663981a15f17d4 (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.h53
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);
35int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc); 35int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
36int dquot_alloc_inode(const struct inode *inode, qsize_t number); 36int dquot_alloc_inode(const struct inode *inode, qsize_t number);
37 37
38int dquot_reserve_space(struct inode *inode, qsize_t number, int prealloc);
39int dquot_claim_space(struct inode *inode, qsize_t number);
40void dquot_release_reserved_space(struct inode *inode, qsize_t number);
41qsize_t dquot_get_reserved_space(struct inode *inode);
42
38int dquot_free_space(struct inode *inode, qsize_t number); 43int dquot_free_space(struct inode *inode, qsize_t number);
39int dquot_free_inode(const struct inode *inode, qsize_t number); 44int 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 */
214static 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 */
229static inline
230void 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
206static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) 236static 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
387static inline int vfs_dq_claim_space(struct inode *inode, qsize_t nr)
388{
389 return vfs_dq_alloc_space(inode, nr);
390}
391
392static inline
393int vfs_dq_release_reservation_space(struct inode *inode, qsize_t nr)
394{
395 return 0;
396}
397
357static inline void vfs_dq_free_space_nodirty(struct inode *inode, qsize_t nr) 398static 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
441static 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
447static inline
448void 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
400static inline void vfs_dq_free_block_nodirty(struct inode *inode, qsize_t nr) 453static 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);