diff options
| author | Eric Sandeen <sandeen@redhat.com> | 2010-05-16 09:00:00 -0400 |
|---|---|---|
| committer | Theodore Ts'o <tytso@mit.edu> | 2010-05-16 09:00:00 -0400 |
| commit | 56246f9ae4cfa95b460f9dfbcfb1b772d85db046 (patch) | |
| tree | 2a11530806fd384c7a482d7d05f7966af773fef2 | |
| parent | 84061e07c5fbbbf9dc8aef8fb750fc3a2dfc31f3 (diff) | |
quota: use flags interface for dquot alloc/free space
Switch __dquot_alloc_space and __dquot_free_space to take flags
to indicate whether to warn and/or to reserve (or free reserve).
This is slightly more readable at the callpoints, and makes it
cleaner to add a "nofail" option in the next patch.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
| -rw-r--r-- | fs/quota/dquot.c | 8 | ||||
| -rw-r--r-- | include/linux/quotaops.h | 25 |
2 files changed, 19 insertions, 14 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 788b5802a7ce..8c40c07797ad 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
| @@ -1488,11 +1488,12 @@ static void inode_decr_space(struct inode *inode, qsize_t number, int reserve) | |||
| 1488 | /* | 1488 | /* |
| 1489 | * This operation can block, but only after everything is updated | 1489 | * This operation can block, but only after everything is updated |
| 1490 | */ | 1490 | */ |
| 1491 | int __dquot_alloc_space(struct inode *inode, qsize_t number, | 1491 | int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags) |
| 1492 | int warn, int reserve) | ||
| 1493 | { | 1492 | { |
| 1494 | int cnt, ret = 0; | 1493 | int cnt, ret = 0; |
| 1495 | char warntype[MAXQUOTAS]; | 1494 | char warntype[MAXQUOTAS]; |
| 1495 | int warn = flags & DQUOT_SPACE_WARN; | ||
| 1496 | int reserve = flags & DQUOT_SPACE_RESERVE; | ||
| 1496 | 1497 | ||
| 1497 | /* | 1498 | /* |
| 1498 | * First test before acquiring mutex - solves deadlocks when we | 1499 | * First test before acquiring mutex - solves deadlocks when we |
| @@ -1612,10 +1613,11 @@ EXPORT_SYMBOL(dquot_claim_space_nodirty); | |||
| 1612 | /* | 1613 | /* |
| 1613 | * This operation can block, but only after everything is updated | 1614 | * This operation can block, but only after everything is updated |
| 1614 | */ | 1615 | */ |
| 1615 | void __dquot_free_space(struct inode *inode, qsize_t number, int reserve) | 1616 | void __dquot_free_space(struct inode *inode, qsize_t number, int flags) |
| 1616 | { | 1617 | { |
| 1617 | unsigned int cnt; | 1618 | unsigned int cnt; |
| 1618 | char warntype[MAXQUOTAS]; | 1619 | char warntype[MAXQUOTAS]; |
| 1620 | int reserve = flags & DQUOT_SPACE_RESERVE; | ||
| 1619 | 1621 | ||
| 1620 | /* First test before acquiring mutex - solves deadlocks when we | 1622 | /* First test before acquiring mutex - solves deadlocks when we |
| 1621 | * re-enter the quota code and are already holding the mutex */ | 1623 | * re-enter the quota code and are already holding the mutex */ |
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index e6fa7acce290..9edd53c24984 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
| @@ -9,6 +9,9 @@ | |||
| 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 | |||
| 12 | static inline struct quota_info *sb_dqopt(struct super_block *sb) | 15 | static inline struct quota_info *sb_dqopt(struct super_block *sb) |
| 13 | { | 16 | { |
| 14 | return &sb->s_dquot; | 17 | return &sb->s_dquot; |
| @@ -33,9 +36,8 @@ int dquot_scan_active(struct super_block *sb, | |||
| 33 | struct dquot *dquot_alloc(struct super_block *sb, int type); | 36 | struct dquot *dquot_alloc(struct super_block *sb, int type); |
| 34 | void dquot_destroy(struct dquot *dquot); | 37 | void dquot_destroy(struct dquot *dquot); |
| 35 | 38 | ||
| 36 | int __dquot_alloc_space(struct inode *inode, qsize_t number, | 39 | int __dquot_alloc_space(struct inode *inode, qsize_t number, int flags); |
| 37 | int warn, int reserve); | 40 | void __dquot_free_space(struct inode *inode, qsize_t number, int flags); |
| 38 | void __dquot_free_space(struct inode *inode, qsize_t number, int reserve); | ||
| 39 | 41 | ||
| 40 | int dquot_alloc_inode(const struct inode *inode); | 42 | int dquot_alloc_inode(const struct inode *inode); |
| 41 | 43 | ||
| @@ -231,17 +233,17 @@ static inline int dquot_transfer(struct inode *inode, struct iattr *iattr) | |||
| 231 | } | 233 | } |
| 232 | 234 | ||
| 233 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, | 235 | static inline int __dquot_alloc_space(struct inode *inode, qsize_t number, |
| 234 | int warn, int reserve) | 236 | int flags) |
| 235 | { | 237 | { |
| 236 | if (!reserve) | 238 | if (!(flags & DQUOT_SPACE_RESERVE)) |
| 237 | inode_add_bytes(inode, number); | 239 | inode_add_bytes(inode, number); |
| 238 | return 0; | 240 | return 0; |
| 239 | } | 241 | } |
| 240 | 242 | ||
| 241 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, | 243 | static inline void __dquot_free_space(struct inode *inode, qsize_t number, |
| 242 | int reserve) | 244 | int flags) |
| 243 | { | 245 | { |
| 244 | if (!reserve) | 246 | if (!(flags & DQUOT_SPACE_RESERVE)) |
| 245 | inode_sub_bytes(inode, number); | 247 | inode_sub_bytes(inode, number); |
| 246 | } | 248 | } |
| 247 | 249 | ||
| @@ -257,7 +259,7 @@ static inline int dquot_claim_space_nodirty(struct inode *inode, qsize_t number) | |||
| 257 | 259 | ||
| 258 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) | 260 | static inline int dquot_alloc_space_nodirty(struct inode *inode, qsize_t nr) |
| 259 | { | 261 | { |
| 260 | return __dquot_alloc_space(inode, nr, 1, 0); | 262 | return __dquot_alloc_space(inode, nr, DQUOT_SPACE_WARN); |
| 261 | } | 263 | } |
| 262 | 264 | ||
| 263 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) | 265 | static inline int dquot_alloc_space(struct inode *inode, qsize_t nr) |
| @@ -282,7 +284,7 @@ static inline int dquot_alloc_block(struct inode *inode, qsize_t nr) | |||
| 282 | 284 | ||
| 283 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) | 285 | static inline int dquot_prealloc_block_nodirty(struct inode *inode, qsize_t nr) |
| 284 | { | 286 | { |
| 285 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0, 0); | 287 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 0); |
| 286 | } | 288 | } |
| 287 | 289 | ||
| 288 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) | 290 | static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) |
| @@ -297,7 +299,8 @@ static inline int dquot_prealloc_block(struct inode *inode, qsize_t nr) | |||
| 297 | 299 | ||
| 298 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) | 300 | static inline int dquot_reserve_block(struct inode *inode, qsize_t nr) |
| 299 | { | 301 | { |
| 300 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, 1, 1); | 302 | return __dquot_alloc_space(inode, nr << inode->i_blkbits, |
| 303 | DQUOT_SPACE_WARN|DQUOT_SPACE_RESERVE); | ||
| 301 | } | 304 | } |
| 302 | 305 | ||
| 303 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) | 306 | static inline int dquot_claim_block(struct inode *inode, qsize_t nr) |
| @@ -334,7 +337,7 @@ static inline void dquot_free_block(struct inode *inode, qsize_t nr) | |||
| 334 | static inline void dquot_release_reservation_block(struct inode *inode, | 337 | static inline void dquot_release_reservation_block(struct inode *inode, |
| 335 | qsize_t nr) | 338 | qsize_t nr) |
| 336 | { | 339 | { |
| 337 | __dquot_free_space(inode, nr << inode->i_blkbits, 1); | 340 | __dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE); |
| 338 | } | 341 | } |
| 339 | 342 | ||
| 340 | #endif /* _LINUX_QUOTAOPS_ */ | 343 | #endif /* _LINUX_QUOTAOPS_ */ |
