From: Jan Kara <jack@suse.cz>
To: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] quota: reorder flags in quota state
Date: Thu, 12 Feb 2015 17:42:23 +0100 [thread overview]
Message-ID: <20150212164223.GA17773@quack.suse.cz> (raw)
In-Reply-To: <20150212160816.17256.85344.stgit@buzz>
On Thu 12-02-15 19:08:16, Konstantin Khlebnikov wrote:
> 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
Thanks. Applied to my tree.
Honza
>
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
> include/linux/quota.h | 32 +++++++++++++++++++++++++-------
> 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 d534e8e..a3374dc 100644
> --- a/include/linux/quota.h
> +++ b/include/linux/quota.h
> @@ -389,7 +389,19 @@ struct quota_format_type {
> struct quota_format_type *qf_next;
> };
>
> -/* Quota state flags - they actually come in two flavors - for users and groups */
> +/**
> + * Quota state flags - they actually come in two flavors - for users and groups.
> + *
> + * Actual typed flags layout:
> + * USRQUOTA GRPQUOTA
> + * DQUOT_USAGE_ENABLED 0x0001 0x0002
> + * DQUOT_LIMITS_ENABLED 0x0004 0x0008
> + * DQUOT_SUSPENDED 0x0010 0x0020
> + *
> + * Following bits are used for non-typed flags:
> + * DQUOT_QUOTA_SYS_FILE 0x0040
> + * DQUOT_NEGATIVE_USAGE 0x0080
> + */
> enum {
> _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */
> _DQUOT_LIMITS_ENABLED, /* Enforce quota limits for users */
> @@ -398,9 +410,9 @@ enum {
> * memory to turn them on */
> _DQUOT_STATE_FLAGS
> };
> -#define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED)
> -#define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED)
> -#define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED)
> +#define DQUOT_USAGE_ENABLED (1 << _DQUOT_USAGE_ENABLED * MAXQUOTAS)
> +#define DQUOT_LIMITS_ENABLED (1 << _DQUOT_LIMITS_ENABLED * MAXQUOTAS)
> +#define DQUOT_SUSPENDED (1 << _DQUOT_SUSPENDED * MAXQUOTAS)
> #define DQUOT_STATE_FLAGS (DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED | \
> DQUOT_SUSPENDED)
> /* Other quota flags */
> @@ -414,15 +426,21 @@ enum {
> */
> #define DQUOT_NEGATIVE_USAGE (1 << (DQUOT_STATE_LAST + 1))
> /* Allow negative quota usage */
> -
> static inline unsigned int dquot_state_flag(unsigned int flags, int type)
> {
> - return flags << _DQUOT_STATE_FLAGS * type;
> + return flags << type;
> }
>
> static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
> {
> - return (flags >> _DQUOT_STATE_FLAGS * type) & DQUOT_STATE_FLAGS;
> + return (flags >> type) & DQUOT_STATE_FLAGS;
> +}
> +
> +/* Bitmap of quota types where flag is set in flags */
> +static __always_inline unsigned dquot_state_types(unsigned flags, unsigned flag)
> +{
> + BUILD_BUG_ON_NOT_POWER_OF_2(flag);
> + return (flags / flag) & ((1 << MAXQUOTAS) - 1);
> }
>
> #ifdef CONFIG_QUOTA_NETLINK_INTERFACE
> diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
> index df73258..8778ec4 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)
>
> static inline unsigned sb_any_quota_suspended(struct super_block *sb)
> {
> - unsigned type, tmsk = 0;
> - for (type = 0; type < MAXQUOTAS; type++)
> - tmsk |= sb_has_quota_suspended(sb, type) << type;
> - return tmsk;
> + return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_SUSPENDED);
> }
>
> /* 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)
>
> static inline unsigned sb_any_quota_loaded(struct super_block *sb)
> {
> - unsigned type, tmsk = 0;
> - for (type = 0; type < MAXQUOTAS; type++)
> - tmsk |= sb_has_quota_loaded(sb, type) << type;
> - return tmsk;
> + return dquot_state_types(sb_dqopt(sb)->flags, DQUOT_USAGE_ENABLED);
> }
>
> static inline bool sb_has_quota_active(struct super_block *sb, int type)
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
prev parent reply other threads:[~2015-02-12 16:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-12 16:08 [PATCH v2] quota: reorder flags in quota state Konstantin Khlebnikov
2015-02-12 16:42 ` Jan Kara [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150212164223.GA17773@quack.suse.cz \
--to=jack@suse.cz \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).