diff options
| author | Dmitry Monakhov <dmonakhov@openvz.org> | 2010-02-16 00:31:49 -0500 |
|---|---|---|
| committer | Jan Kara <jack@suse.cz> | 2010-03-04 18:20:26 -0500 |
| commit | ad1e6e8da9fe8cb7ecfde8eabacedc3b50fceae4 (patch) | |
| tree | 0971e2039c2d6feb6763ba018e9c73123d207ddb | |
| parent | 86963918965eb8fe0c8ae009e7c1b4c630f533d5 (diff) | |
quota: sb_quota state flags cleanup
- remove hardcoded USRQUOTA/GRPQUOTA flags
- convert int to bool for appropriate functions
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>
| -rw-r--r-- | fs/quota/dquot.c | 3 | ||||
| -rw-r--r-- | include/linux/quota.h | 15 | ||||
| -rw-r--r-- | include/linux/quotaops.h | 31 |
3 files changed, 26 insertions, 23 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 4c2213f7ed36..5a831dc5ab28 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
| @@ -1301,7 +1301,7 @@ int dquot_initialize(struct inode *inode, int type) | |||
| 1301 | { | 1301 | { |
| 1302 | unsigned int id = 0; | 1302 | unsigned int id = 0; |
| 1303 | int cnt, ret = 0; | 1303 | int cnt, ret = 0; |
| 1304 | struct dquot *got[MAXQUOTAS] = { NULL, NULL }; | 1304 | struct dquot *got[MAXQUOTAS]; |
| 1305 | struct super_block *sb = inode->i_sb; | 1305 | struct super_block *sb = inode->i_sb; |
| 1306 | qsize_t rsv; | 1306 | qsize_t rsv; |
| 1307 | 1307 | ||
| @@ -1312,6 +1312,7 @@ int dquot_initialize(struct inode *inode, int type) | |||
| 1312 | 1312 | ||
| 1313 | /* First get references to structures we might need. */ | 1313 | /* First get references to structures we might need. */ |
| 1314 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { | 1314 | for (cnt = 0; cnt < MAXQUOTAS; cnt++) { |
| 1315 | got[cnt] = NULL; | ||
| 1315 | if (type != -1 && cnt != type) | 1316 | if (type != -1 && cnt != type) |
| 1316 | continue; | 1317 | continue; |
| 1317 | switch (cnt) { | 1318 | switch (cnt) { |
diff --git a/include/linux/quota.h b/include/linux/quota.h index 570348cbccb1..92547a57e25a 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
| @@ -357,26 +357,25 @@ enum { | |||
| 357 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ | 357 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ |
| 358 | DQUOT_SUSPENDED) | 358 | DQUOT_SUSPENDED) |
| 359 | /* Other quota flags */ | 359 | /* Other quota flags */ |
| 360 | #define DQUOT_QUOTA_SYS_FILE (1 << 6) /* Quota file is a special | 360 | #define DQUOT_STATE_LAST (_DQUOT_STATE_FLAGS * MAXQUOTAS) |
| 361 | #define DQUOT_QUOTA_SYS_FILE (1 << DQUOT_STATE_LAST) | ||
| 362 | /* Quota file is a special | ||
| 361 | * system file and user cannot | 363 | * system file and user cannot |
| 362 | * touch it. Filesystem is | 364 | * touch it. Filesystem is |
| 363 | * responsible for setting | 365 | * responsible for setting |
| 364 | * S_NOQUOTA, S_NOATIME flags | 366 | * S_NOQUOTA, S_NOATIME flags |
| 365 | */ | 367 | */ |
| 366 | #define DQUOT_NEGATIVE_USAGE (1 << 7) /* Allow negative quota usage */ | 368 | #define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1)) |
| 369 | /* Allow negative quota usage */ | ||
| 367 | 370 | ||
| 368 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) | 371 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) |
| 369 | { | 372 | { |
| 370 | if (type == USRQUOTA) | 373 | return flags << _DQUOT_STATE_FLAGS * type; |
| 371 | return flags; | ||
| 372 | return flags << _DQUOT_STATE_FLAGS; | ||
| 373 | } | 374 | } |
| 374 | 375 | ||
| 375 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) | 376 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) |
| 376 | { | 377 | { |
| 377 | if (type == USRQUOTA) | 378 | return (flags >> _DQUOT_STATE_FLAGS * type) & DQUOT_STATE_FLAGS; |
| 378 | return flags; | ||
| 379 | return flags >> _DQUOT_STATE_FLAGS; | ||
| 380 | } | 379 | } |
| 381 | 380 | ||
| 382 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE | 381 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE |
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 8cfd0d44c994..e563a20cff4f 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
| @@ -79,53 +79,56 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type) | |||
| 79 | * Functions for checking status of quota | 79 | * Functions for checking status of quota |
| 80 | */ | 80 | */ |
| 81 | 81 | ||
| 82 | static inline int sb_has_quota_usage_enabled(struct super_block *sb, int type) | 82 | static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type) |
| 83 | { | 83 | { |
| 84 | return sb_dqopt(sb)->flags & | 84 | return sb_dqopt(sb)->flags & |
| 85 | dquot_state_flag(DQUOT_USAGE_ENABLED, type); | 85 | dquot_state_flag(DQUOT_USAGE_ENABLED, type); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | static inline int sb_has_quota_limits_enabled(struct super_block *sb, int type) | 88 | static inline bool sb_has_quota_limits_enabled(struct super_block *sb, int type) |
| 89 | { | 89 | { |
| 90 | return sb_dqopt(sb)->flags & | 90 | return sb_dqopt(sb)->flags & |
| 91 | dquot_state_flag(DQUOT_LIMITS_ENABLED, type); | 91 | dquot_state_flag(DQUOT_LIMITS_ENABLED, type); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | static inline int sb_has_quota_suspended(struct super_block *sb, int type) | 94 | static inline bool sb_has_quota_suspended(struct super_block *sb, int type) |
| 95 | { | 95 | { |
| 96 | return sb_dqopt(sb)->flags & | 96 | return sb_dqopt(sb)->flags & |
| 97 | dquot_state_flag(DQUOT_SUSPENDED, type); | 97 | dquot_state_flag(DQUOT_SUSPENDED, type); |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | static inline int sb_any_quota_suspended(struct super_block *sb) | 100 | static inline unsigned sb_any_quota_suspended(struct super_block *sb) |
| 101 | { | 101 | { |
| 102 | return sb_has_quota_suspended(sb, USRQUOTA) || | 102 | unsigned type, tmsk = 0; |
| 103 | sb_has_quota_suspended(sb, GRPQUOTA); | 103 | for (type = 0; type < MAXQUOTAS; type++) |
| 104 | tmsk |= sb_has_quota_suspended(sb, type) << type; | ||
| 105 | return tmsk; | ||
| 104 | } | 106 | } |
| 105 | 107 | ||
| 106 | /* Does kernel know about any quota information for given sb + type? */ | 108 | /* Does kernel know about any quota information for given sb + type? */ |
| 107 | static inline int sb_has_quota_loaded(struct super_block *sb, int type) | 109 | static inline bool sb_has_quota_loaded(struct super_block *sb, int type) |
| 108 | { | 110 | { |
| 109 | /* Currently if anything is on, then quota usage is on as well */ | 111 | /* Currently if anything is on, then quota usage is on as well */ |
| 110 | return sb_has_quota_usage_enabled(sb, type); | 112 | return sb_has_quota_usage_enabled(sb, type); |
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | static inline int sb_any_quota_loaded(struct super_block *sb) | 115 | static inline unsigned sb_any_quota_loaded(struct super_block *sb) |
| 114 | { | 116 | { |
| 115 | return sb_has_quota_loaded(sb, USRQUOTA) || | 117 | unsigned type, tmsk = 0; |
| 116 | sb_has_quota_loaded(sb, GRPQUOTA); | 118 | for (type = 0; type < MAXQUOTAS; type++) |
| 119 | tmsk |= sb_has_quota_loaded(sb, type) << type; | ||
| 120 | return tmsk; | ||
| 117 | } | 121 | } |
| 118 | 122 | ||
| 119 | static inline int sb_has_quota_active(struct super_block *sb, int type) | 123 | static inline bool sb_has_quota_active(struct super_block *sb, int type) |
| 120 | { | 124 | { |
| 121 | return sb_has_quota_loaded(sb, type) && | 125 | return sb_has_quota_loaded(sb, type) && |
| 122 | !sb_has_quota_suspended(sb, type); | 126 | !sb_has_quota_suspended(sb, type); |
| 123 | } | 127 | } |
| 124 | 128 | ||
| 125 | static inline int sb_any_quota_active(struct super_block *sb) | 129 | static inline unsigned sb_any_quota_active(struct super_block *sb) |
| 126 | { | 130 | { |
| 127 | return sb_has_quota_active(sb, USRQUOTA) || | 131 | return sb_any_quota_loaded(sb) & ~sb_any_quota_suspended(sb); |
| 128 | sb_has_quota_active(sb, GRPQUOTA); | ||
| 129 | } | 132 | } |
| 130 | 133 | ||
| 131 | /* | 134 | /* |
