diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/quotaops.h | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 370abb1e99cb..e38ae53f3529 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 | |||
12 | static inline struct quota_info *sb_dqopt(struct super_block *sb) | 16 | static 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, | |||
41 | struct dquot *dquot_alloc(struct super_block *sb, int type); | 45 | struct dquot *dquot_alloc(struct super_block *sb, int type); |
42 | void dquot_destroy(struct dquot *dquot); | 46 | void dquot_destroy(struct dquot *dquot); |
43 | 47 | ||
44 | int __dquot_alloc_space(struct inode *inode, qsize_t number, | 48 | int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags); |
45 | int warn, int reserve); | 49 | void __dquot_free_space(struct inode *inode, qsize_t number, int flags); |
46 | void __dquot_free_space(struct inode *inode, qsize_t number, int reserve); | ||
47 | 50 | ||
48 | int dquot_alloc_inode(const struct inode *inode); | 51 | int 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 | ||
244 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, | 247 | static 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 | ||
252 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, | 255 | static 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 | ||
269 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) | 272 | static 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 | |||
277 | static 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 | ||
274 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) | 283 | static 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 | ||
298 | static 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 | |||
289 | static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) | 303 | static 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 | ||
294 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) | 308 | static 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 | ||
299 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) | 313 | static 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 | ||
309 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) | 323 | static 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 | ||
314 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) | 329 | static 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) | |||
345 | static inline void dquot_release_reservation_block(struct inode *inode, | 360 | static 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_ */ |