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.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 370abb1e99c..e38ae53f352 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,9 +45,8 @@ 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
@@ -242,17 +245,17 @@ static inline int dquot_transfer(struct inode *inode, struct iattr *iattr)
242} 245}
243 246
244static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, 247static inline int __dquot_alloc_space(struct inode *inode, qsize_t number,
245 int warn, int reserve) 248 int flags)
246{ 249{
247 if (!reserve) 250 if (!(flags & DQUOT_SPACE_RESERVE))
248 inode_add_bytes(inode, number); 251 inode_add_bytes(inode, number);
249 return 0; 252 return 0;
250} 253}
251 254
252static inline void __dquot_free_space(struct inode *inode, qsize_t number, 255static inline void __dquot_free_space(struct inode *inode, qsize_t number,
253 int reserve) 256 int flags)
254{ 257{
255 if (!reserve) 258 if (!(flags & DQUOT_SPACE_RESERVE))
256 inode_sub_bytes(inode, number); 259 inode_sub_bytes(inode, number);
257} 260}
258 261
@@ -268,7 +271,13 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number)
268 271
269static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) 272static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr)
270{ 273{
271 return __dquot_alloc_space(inode, nr, 1, 0); 274 return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN);
275}
276
277static inline void dquot_alloc_space_nofail(struct inode *inode, qsize_t nr)
278{
279 __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN|DQUOT_SPACE_NOFAIL);
280 mark_inode_dirty(inode);
272} 281}
273 282
274static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) 283static inline int dquot_alloc_space(struct inode *inode, qsize_t nr)
@@ -286,6 +295,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); 295 return dquot_alloc_space_nodirty(inode, nr << inode->i_blkbits);
287} 296}
288 297
298static inline void dquot_alloc_block_nofail(struct inode *inode, qsize_t nr)
299{
300 dquot_alloc_space_nofail(inode, nr << inode->i_blkbits);
301}
302
289static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) 303static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
290{ 304{
291 return dquot_alloc_space(inode, nr << inode->i_blkbits); 305 return dquot_alloc_space(inode, nr << inode->i_blkbits);
@@ -293,7 +307,7 @@ static inline int dquot_alloc_block(struct inode *inode, qsize_t nr)
293 307
294static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) 308static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr)
295{ 309{
296 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0); 310 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0);
297} 311}
298 312
299static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) 313static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
@@ -308,7 +322,8 @@ static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr)
308 322
309static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) 323static inline int dquot_reserve_block(struct inode *inode, qsize_t nr)
310{ 324{
311 return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1); 325 return __dquot_alloc_space(inode, nr << inode->i_blkbits,
326 DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE);
312} 327}
313 328
314static inline int dquot_claim_block(struct inode *inode, qsize_t nr) 329static inline int dquot_claim_block(struct inode *inode, qsize_t nr)
@@ -345,7 +360,7 @@ static inline void dquot_free_block(struct inode *inode, qsize_t nr)
345static inline void dquot_release_reservation_block(struct inode *inode, 360static inline void dquot_release_reservation_block(struct inode *inode,
346 qsize_t nr) 361 qsize_t nr)
347{ 362{
348 __dquot_free_space(inode, nr << inode->i_blkbits, 1); 363 __dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE);
349} 364}
350 365
351#endif /* _LINUX_QUOTAOPS_ */ 366#endif /* _LINUX_QUOTAOPS_ */