diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/quota.h | 32 | ||||
| -rw-r--r-- | include/linux/quotaops.h | 10 |
2 files changed, 27 insertions, 15 deletions
diff --git a/include/linux/quota.h b/include/linux/quota.h index d534e8ed308a..a3374dc3a91b 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
| @@ -389,7 +389,19 @@ struct quota_format_type { | |||
| 389 | struct quota_format_type *qf_next; | 389 | struct quota_format_type *qf_next; |
| 390 | }; | 390 | }; |
| 391 | 391 | ||
| 392 | /* Quota state flags - they actually come in two flavors - for users and groups */ | 392 | /** |
| 393 | * Quota state flags - they actually come in two flavors - for users and groups. | ||
| 394 | * | ||
| 395 | * Actual typed flags layout: | ||
| 396 | * USRQUOTA GRPQUOTA | ||
| 397 | * DQUOT_USAGE_ENABLED 0x0001 0x0002 | ||
| 398 | * DQUOT_LIMITS_ENABLED 0x0004 0x0008 | ||
| 399 | * DQUOT_SUSPENDED 0x0010 0x0020 | ||
| 400 | * | ||
| 401 | * Following bits are used for non-typed flags: | ||
| 402 | * DQUOT_QUOTA_SYS_FILE 0x0040 | ||
| 403 | * DQUOT_NEGATIVE_USAGE 0x0080 | ||
| 404 | */ | ||
| 393 | enum { | 405 | enum { |
| 394 | _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */ | 406 | _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */ |
| 395 | _DQUOT_LIMITS_ENABLED, /* Enforce quota limits for users */ | 407 | _DQUOT_LIMITS_ENABLED, /* Enforce quota limits for users */ |
| @@ -398,9 +410,9 @@ enum { | |||
| 398 | * memory to turn them on */ | 410 | * memory to turn them on */ |
| 399 | _DQUOT_STATE_FLAGS | 411 | _DQUOT_STATE_FLAGS |
| 400 | }; | 412 | }; |
| 401 | #define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED) | 413 | #define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED * MAXQUOTAS) |
| 402 | #define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED) | 414 | #define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED * MAXQUOTAS) |
| 403 | #define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED) | 415 | #define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED * MAXQUOTAS) |
| 404 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ | 416 | #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \ |
| 405 | DQUOT_SUSPENDED) | 417 | DQUOT_SUSPENDED) |
| 406 | /* Other quota flags */ | 418 | /* Other quota flags */ |
| @@ -414,15 +426,21 @@ enum { | |||
| 414 | */ | 426 | */ |
| 415 | #define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1)) | 427 | #define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1)) |
| 416 | /* Allow negative quota usage */ | 428 | /* Allow negative quota usage */ |
| 417 | |||
| 418 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) | 429 | static inline unsigned int dquot_state_flag(unsigned int flags, int type) |
| 419 | { | 430 | { |
| 420 | return flags << _DQUOT_STATE_FLAGS * type; | 431 | return flags << type; |
| 421 | } | 432 | } |
| 422 | 433 | ||
| 423 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) | 434 | static inline unsigned int dquot_generic_flag(unsigned int flags, int type) |
| 424 | { | 435 | { |
| 425 | return (flags >> _DQUOT_STATE_FLAGS * type) & DQUOT_STATE_FLAGS; | 436 | return (flags >> type) & DQUOT_STATE_FLAGS; |
| 437 | } | ||
| 438 | |||
| 439 | /* Bitmap of quota types where flag is set in flags */ | ||
| 440 | static __always_inline unsigned dquot_state_types(unsigned flags, unsigned flag) | ||
| 441 | { | ||
| 442 | BUILD_BUG_ON_NOT_POWER_OF_2(flag); | ||
| 443 | return (flags / flag) & ((1 << MAXQUOTAS) - 1); | ||
| 426 | } | 444 | } |
| 427 | 445 | ||
| 428 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE | 446 | #ifdef CONFIG_QUOTA_NETLINK_INTERFACE |
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index df73258cca47..8778ec4775eb 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h | |||
| @@ -134,10 +134,7 @@ static inline bool sb_has_quota_suspended(struct super_block *sb, int type) | |||
| 134 | 134 | ||
| 135 | static inline unsigned sb_any_quota_suspended(struct super_block *sb) | 135 | static inline unsigned sb_any_quota_suspended(struct super_block *sb) |
| 136 | { | 136 | { |
| 137 | unsigned type, tmsk = 0; | 137 | return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_SUSPENDED); |
| 138 | for (type = 0; type < MAXQUOTAS; type++) | ||
| 139 | tmsk |= sb_has_quota_suspended(sb, type) << type; | ||
| 140 | return tmsk; | ||
| 141 | } | 138 | } |
| 142 | 139 | ||
| 143 | /* Does kernel know about any quota information for given sb + type? */ | 140 | /* Does kernel know about any quota information for given sb + type? */ |
| @@ -149,10 +146,7 @@ static inline bool sb_has_quota_loaded(struct super_block *sb, int type) | |||
| 149 | 146 | ||
| 150 | static inline unsigned sb_any_quota_loaded(struct super_block *sb) | 147 | static inline unsigned sb_any_quota_loaded(struct super_block *sb) |
| 151 | { | 148 | { |
| 152 | unsigned type, tmsk = 0; | 149 | return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_USAGE_ENABLED); |
| 153 | for (type = 0; type < MAXQUOTAS; type++) | ||
| 154 | tmsk |= sb_has_quota_loaded(sb, type) << type; | ||
| 155 | return tmsk; | ||
| 156 | } | 150 | } |
| 157 | 151 | ||
| 158 | static inline bool sb_has_quota_active(struct super_block *sb, int type) | 152 | static inline bool sb_has_quota_active(struct super_block *sb, int type) |
