diff options
| author | Konstantin Khlebnikov <khlebnikov@yandex-team.ru> | 2015-02-12 11:08:16 -0500 |
|---|---|---|
| committer | Jan Kara <jack@suse.cz> | 2015-03-04 10:42:46 -0500 |
| commit | 781970240a56d1c15a9b8ee37d28987b8182f060 (patch) | |
| tree | 3b666d6613b7bf4aac0d8fa96ed7cf26620ba2f9 /include/linux | |
| parent | 69a25ee217ba8c93a6d4c6671d9208c0155c0485 (diff) | |
quota: reorder flags in quota state
Flags in struct quota_state keep flags for each quota type and
some common flags. This patch reorders typed flags:
Before:
0 USRQUOTA DQUOT_USAGE_ENABLED
1 USRQUOTA DQUOT_LIMITS_ENABLED
2 USRQUOTA DQUOT_SUSPENDED
3 GRPQUOTA DQUOT_USAGE_ENABLED
4 GRPQUOTA DQUOT_LIMITS_ENABLED
5 GRPQUOTA DQUOT_SUSPENDED
6 DQUOT_QUOTA_SYS_FILE
7 DQUOT_NEGATIVE_USAGE
After:
0 USRQUOTA DQUOT_USAGE_ENABLED
1 GRPQUOTA DQUOT_USAGE_ENABLED
2 USRQUOTA DQUOT_LIMITS_ENABLED
3 GRPQUOTA DQUOT_LIMITS_ENABLED
4 USRQUOTA DQUOT_SUSPENDED
5 GRPQUOTA DQUOT_SUSPENDED
6 DQUOT_QUOTA_SYS_FILE
7 DQUOT_NEGATIVE_USAGE
Now we can get bitmap of all enabled/suspended quota types without loop.
For example suspended: (flags / DQUOT_SUSPENDED) & ((1 << MAXQUOTAS) - 1).
add/remove: 0/1 grow/shrink: 3/11 up/down: 56/-215 (-159)
function old new delta
__dquot_initialize 423 447 +24
dquot_transfer 181 197 +16
dquot_alloc_inode 286 302 +16
dquot_reclaim_space_nodirty 316 313 -3
dquot_claim_space_nodirty 314 311 -3
dquot_resume 286 281 -5
dquot_free_inode 332 324 -8
__dquot_alloc_space 500 492 -8
dquot_disable 1944 1929 -15
dquot_quota_enable 252 236 -16
__dquot_free_space 750 734 -16
dquot_writeback_dquots 625 608 -17
__dquot_transfer 1186 1154 -32
dquot_quota_sync 299 261 -38
dquot_active.isra 54 - -54
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Jan Kara <jack@suse.cz>
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) |
