diff mbox

[2/2] quota: merge sb->s_quota_types into sb->s_dquot.flags

Message ID 20150212093645.6055.77105.stgit@buzz (mailing list archive)
State New, archived
Headers show

Commit Message

Konstantin Khlebnikov Feb. 12, 2015, 9:36 a.m. UTC
This patch converts supported quota types bitmask (sb->s_quota_types)
into per-type flag DQUOT_SUPPORTED in sb->s_dquot.flags.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 fs/ext2/super.c          |    3 ++-
 fs/ext3/super.c          |    3 ++-
 fs/ext4/super.c          |    3 ++-
 fs/gfs2/ops_fstype.c     |    3 ++-
 fs/jfs/super.c           |    3 ++-
 fs/ocfs2/super.c         |    3 ++-
 fs/quota/quota.c         |    6 +++---
 fs/reiserfs/super.c      |    3 ++-
 fs/xfs/xfs_super.c       |    5 ++++-
 include/linux/fs.h       |    1 -
 include/linux/quota.h    |    4 +++-
 include/linux/quotaops.h |   10 ++++++++++
 12 files changed, 34 insertions(+), 13 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Jan Kara Feb. 12, 2015, 3:13 p.m. UTC | #1
On Thu 12-02-15 12:36:45, Konstantin Khlebnikov wrote:
> This patch converts supported quota types bitmask (sb->s_quota_types)
> into per-type flag DQUOT_SUPPORTED in sb->s_dquot.flags.
  I had something like this previously (although your patch is nicer) but
Christoph objected that filesystems not using VFS quotas (XFS, GFS2) don't
touch sb->s_dquot at all and this would make them use it. So I used a
special field in the superblock instead.

								Honza

> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
>  fs/ext2/super.c          |    3 ++-
>  fs/ext3/super.c          |    3 ++-
>  fs/ext4/super.c          |    3 ++-
>  fs/gfs2/ops_fstype.c     |    3 ++-
>  fs/jfs/super.c           |    3 ++-
>  fs/ocfs2/super.c         |    3 ++-
>  fs/quota/quota.c         |    6 +++---
>  fs/reiserfs/super.c      |    3 ++-
>  fs/xfs/xfs_super.c       |    5 ++++-
>  include/linux/fs.h       |    1 -
>  include/linux/quota.h    |    4 +++-
>  include/linux/quotaops.h |   10 ++++++++++
>  12 files changed, 34 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index ae55fdd..9e2b1c3 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -1099,7 +1099,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>  #ifdef CONFIG_QUOTA
>  	sb->dq_op = &dquot_operations;
>  	sb->s_qcop = &dquot_quotactl_ops;
> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
>  #endif
>  
>  	root = ext2_iget(sb, EXT2_ROOT_INO);
> diff --git a/fs/ext3/super.c b/fs/ext3/super.c
> index d4dbf3c..fc71d08 100644
> --- a/fs/ext3/super.c
> +++ b/fs/ext3/super.c
> @@ -2012,7 +2012,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
>  #ifdef CONFIG_QUOTA
>  	sb->s_qcop = &ext3_qctl_operations;
>  	sb->dq_op = &ext3_quota_operations;
> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
>  #endif
>  	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
>  	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index ac64edb..e36d73c 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -3925,7 +3925,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
>  		sb->s_qcop = &dquot_quotactl_sysfile_ops;
>  	else
>  		sb->s_qcop = &ext4_qctl_operations;
> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
>  #endif
>  	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
>  
> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
> index 8633ad3..3e8f590 100644
> --- a/fs/gfs2/ops_fstype.c
> +++ b/fs/gfs2/ops_fstype.c
> @@ -1074,7 +1074,8 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
>  	sb->s_export_op = &gfs2_export_ops;
>  	sb->s_xattr = gfs2_xattr_handlers;
>  	sb->s_qcop = &gfs2_quotactl_ops;
> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
>  	sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
>  	sb->s_time_gran = 1;
>  	sb->s_maxbytes = MAX_LFS_FILESIZE;
> diff --git a/fs/jfs/super.c b/fs/jfs/super.c
> index 16c3a95..b820b76 100644
> --- a/fs/jfs/super.c
> +++ b/fs/jfs/super.c
> @@ -540,7 +540,8 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
>  #ifdef CONFIG_QUOTA
>  	sb->dq_op = &dquot_operations;
>  	sb->s_qcop = &dquot_quotactl_ops;
> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
>  #endif
>  
>  	/*
> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
> index 87a1f76..1db5903 100644
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
> @@ -2059,7 +2059,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
>  	sb->s_export_op = &ocfs2_export_ops;
>  	sb->s_qcop = &dquot_quotactl_sysfile_ops;
>  	sb->dq_op = &ocfs2_quota_operations;
> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
>  	sb->s_xattr = ocfs2_xattr_handlers;
>  	sb->s_time_gran = 1;
>  	sb->s_flags |= MS_NOATIME;
> diff --git a/fs/quota/quota.c b/fs/quota/quota.c
> index d14a799..28d54bc 100644
> --- a/fs/quota/quota.c
> +++ b/fs/quota/quota.c
> @@ -50,7 +50,7 @@ static void quota_sync_one(struct super_block *sb, void *arg)
>  	int type = *(int *)arg;
>  
>  	if (sb->s_qcop && sb->s_qcop->quota_sync &&
> -	    (sb->s_quota_types & (1 << type)))
> +	    sb_has_quota_supported(sb, type))
>  		sb->s_qcop->quota_sync(sb, type);
>  }
>  
> @@ -446,12 +446,12 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
>  	if (type >= (XQM_COMMAND(cmd) ? XQM_MAXQUOTAS : MAXQUOTAS))
>  		return -EINVAL;
>  	/*
> -	 * Quota not supported on this fs? Check this before s_quota_types
> +	 * Quota not supported on this fs? Check this before sb_dqopt flags
>  	 * since they needn't be set if quota is not supported at all.
>  	 */
>  	if (!sb->s_qcop)
>  		return -ENOSYS;
> -	if (!(sb->s_quota_types & (1 << type)))
> +	if (!sb_has_quota_supported(sb, type))
>  		return -EINVAL;
>  
>  	ret = check_quotactl_permission(sb, type, cmd, id);
> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
> index 71fbbe3..f08740f 100644
> --- a/fs/reiserfs/super.c
> +++ b/fs/reiserfs/super.c
> @@ -1643,7 +1643,8 @@ static int read_super_block(struct super_block *s, int offset)
>  #ifdef CONFIG_QUOTA
>  	s->s_qcop = &reiserfs_qctl_operations;
>  	s->dq_op = &reiserfs_quota_operations;
> -	s->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
>  #endif
>  
>  	/*
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index f2449fd..f8806c89 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -55,6 +55,7 @@
>  #include <linux/kthread.h>
>  #include <linux/freezer.h>
>  #include <linux/parser.h>
> +#include <linux/quotaops.h>
>  
>  static const struct super_operations xfs_super_operations;
>  static kmem_zone_t *xfs_ioend_zone;
> @@ -1434,7 +1435,9 @@ xfs_fs_fill_super(
>  	sb->s_export_op = &xfs_export_operations;
>  #ifdef CONFIG_XFS_QUOTA
>  	sb->s_qcop = &xfs_quotactl_operations;
> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
> +	sb_set_quota_supported(sb, USRQUOTA);
> +	sb_set_quota_supported(sb, GRPQUOTA);
> +	sb_set_quota_supported(sb, PRJQUOTA);
>  #endif
>  	sb->s_op = &xfs_super_operations;
>  
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index f125b88..e1d19b6 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1257,7 +1257,6 @@ struct super_block {
>  	struct backing_dev_info *s_bdi;
>  	struct mtd_info		*s_mtd;
>  	struct hlist_node	s_instances;
> -	unsigned int		s_quota_types;	/* Bitmask of supported quota types */
>  	struct quota_info	s_dquot;	/* Diskquota specific options */
>  
>  	struct sb_writers	s_writers;
> diff --git a/include/linux/quota.h b/include/linux/quota.h
> index 205b4f7..3c6cc80 100644
> --- a/include/linux/quota.h
> +++ b/include/linux/quota.h
> @@ -391,13 +391,15 @@ struct quota_format_type {
>  
>  /* Quota state flags - they actually come in two flavors - for users and groups */
>  enum {
> -	_DQUOT_USAGE_ENABLED = 0,		/* Track disk usage for users */
> +	_DQUOT_SUPPORTED = 0,			/* Quota type supported by fs */
> +	_DQUOT_USAGE_ENABLED,			/* Track disk usage for users */
>  	_DQUOT_LIMITS_ENABLED,			/* Enforce quota limits for users */
>  	_DQUOT_SUSPENDED,			/* User diskquotas are off, but
>  						 * we have necessary info in
>  						 * memory to turn them on */
>  	_DQUOT_STATE_FLAGS
>  };
> +#define DQUOT_SUPPORTED		(1 << _DQUOT_SUPPORTED * MAXQUOTAS)
>  #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)
> diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
> index 8778ec4..e431a87 100644
> --- a/include/linux/quotaops.h
> +++ b/include/linux/quotaops.h
> @@ -110,10 +110,20 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
>  	return sb_dqopt(sb)->info + type;
>  }
>  
> +static inline void sb_set_quota_supported(struct super_block *sb, unsigned type)
> +{
> +	sb_dqopt(sb)->flags |= dquot_state_flag(DQUOT_SUPPORTED, type);
> +}
> +
>  /*
>   * Functions for checking status of quota
>   */
>  
> +static inline bool sb_has_quota_supported(struct super_block *sb, unsigned type)
> +{
> +	return sb_dqopt(sb)->flags & dquot_state_flag(DQUOT_SUPPORTED, type);
> +}
> +
>  static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type)
>  {
>  	return sb_dqopt(sb)->flags &
>
Konstantin Khlebnikov Feb. 12, 2015, 3:40 p.m. UTC | #2
On 12.02.2015 18:13, Jan Kara wrote:
> On Thu 12-02-15 12:36:45, Konstantin Khlebnikov wrote:
>> This patch converts supported quota types bitmask (sb->s_quota_types)
>> into per-type flag DQUOT_SUPPORTED in sb->s_dquot.flags.
>    I had something like this previously (although your patch is nicer) but
> Christoph objected that filesystems not using VFS quotas (XFS, GFS2) don't
> touch sb->s_dquot at all and this would make them use it. So I used a
> special field in the superblock instead.

Ok. This makes sense.

>
> 								Honza
>
>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>> ---
>>   fs/ext2/super.c          |    3 ++-
>>   fs/ext3/super.c          |    3 ++-
>>   fs/ext4/super.c          |    3 ++-
>>   fs/gfs2/ops_fstype.c     |    3 ++-
>>   fs/jfs/super.c           |    3 ++-
>>   fs/ocfs2/super.c         |    3 ++-
>>   fs/quota/quota.c         |    6 +++---
>>   fs/reiserfs/super.c      |    3 ++-
>>   fs/xfs/xfs_super.c       |    5 ++++-
>>   include/linux/fs.h       |    1 -
>>   include/linux/quota.h    |    4 +++-
>>   include/linux/quotaops.h |   10 ++++++++++
>>   12 files changed, 34 insertions(+), 13 deletions(-)
>>
>> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
>> index ae55fdd..9e2b1c3 100644
>> --- a/fs/ext2/super.c
>> +++ b/fs/ext2/super.c
>> @@ -1099,7 +1099,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>>   #ifdef CONFIG_QUOTA
>>   	sb->dq_op = &dquot_operations;
>>   	sb->s_qcop = &dquot_quotactl_ops;
>> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>>   #endif
>>
>>   	root = ext2_iget(sb, EXT2_ROOT_INO);
>> diff --git a/fs/ext3/super.c b/fs/ext3/super.c
>> index d4dbf3c..fc71d08 100644
>> --- a/fs/ext3/super.c
>> +++ b/fs/ext3/super.c
>> @@ -2012,7 +2012,8 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
>>   #ifdef CONFIG_QUOTA
>>   	sb->s_qcop = &ext3_qctl_operations;
>>   	sb->dq_op = &ext3_quota_operations;
>> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>>   #endif
>>   	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
>>   	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
>> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
>> index ac64edb..e36d73c 100644
>> --- a/fs/ext4/super.c
>> +++ b/fs/ext4/super.c
>> @@ -3925,7 +3925,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
>>   		sb->s_qcop = &dquot_quotactl_sysfile_ops;
>>   	else
>>   		sb->s_qcop = &ext4_qctl_operations;
>> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>>   #endif
>>   	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
>>
>> diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
>> index 8633ad3..3e8f590 100644
>> --- a/fs/gfs2/ops_fstype.c
>> +++ b/fs/gfs2/ops_fstype.c
>> @@ -1074,7 +1074,8 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
>>   	sb->s_export_op = &gfs2_export_ops;
>>   	sb->s_xattr = gfs2_xattr_handlers;
>>   	sb->s_qcop = &gfs2_quotactl_ops;
>> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>>   	sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
>>   	sb->s_time_gran = 1;
>>   	sb->s_maxbytes = MAX_LFS_FILESIZE;
>> diff --git a/fs/jfs/super.c b/fs/jfs/super.c
>> index 16c3a95..b820b76 100644
>> --- a/fs/jfs/super.c
>> +++ b/fs/jfs/super.c
>> @@ -540,7 +540,8 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
>>   #ifdef CONFIG_QUOTA
>>   	sb->dq_op = &dquot_operations;
>>   	sb->s_qcop = &dquot_quotactl_ops;
>> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>>   #endif
>>
>>   	/*
>> diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
>> index 87a1f76..1db5903 100644
>> --- a/fs/ocfs2/super.c
>> +++ b/fs/ocfs2/super.c
>> @@ -2059,7 +2059,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
>>   	sb->s_export_op = &ocfs2_export_ops;
>>   	sb->s_qcop = &dquot_quotactl_sysfile_ops;
>>   	sb->dq_op = &ocfs2_quota_operations;
>> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>>   	sb->s_xattr = ocfs2_xattr_handlers;
>>   	sb->s_time_gran = 1;
>>   	sb->s_flags |= MS_NOATIME;
>> diff --git a/fs/quota/quota.c b/fs/quota/quota.c
>> index d14a799..28d54bc 100644
>> --- a/fs/quota/quota.c
>> +++ b/fs/quota/quota.c
>> @@ -50,7 +50,7 @@ static void quota_sync_one(struct super_block *sb, void *arg)
>>   	int type = *(int *)arg;
>>
>>   	if (sb->s_qcop && sb->s_qcop->quota_sync &&
>> -	    (sb->s_quota_types & (1 << type)))
>> +	    sb_has_quota_supported(sb, type))
>>   		sb->s_qcop->quota_sync(sb, type);
>>   }
>>
>> @@ -446,12 +446,12 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
>>   	if (type >= (XQM_COMMAND(cmd) ? XQM_MAXQUOTAS : MAXQUOTAS))
>>   		return -EINVAL;
>>   	/*
>> -	 * Quota not supported on this fs? Check this before s_quota_types
>> +	 * Quota not supported on this fs? Check this before sb_dqopt flags
>>   	 * since they needn't be set if quota is not supported at all.
>>   	 */
>>   	if (!sb->s_qcop)
>>   		return -ENOSYS;
>> -	if (!(sb->s_quota_types & (1 << type)))
>> +	if (!sb_has_quota_supported(sb, type))
>>   		return -EINVAL;
>>
>>   	ret = check_quotactl_permission(sb, type, cmd, id);
>> diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
>> index 71fbbe3..f08740f 100644
>> --- a/fs/reiserfs/super.c
>> +++ b/fs/reiserfs/super.c
>> @@ -1643,7 +1643,8 @@ static int read_super_block(struct super_block *s, int offset)
>>   #ifdef CONFIG_QUOTA
>>   	s->s_qcop = &reiserfs_qctl_operations;
>>   	s->dq_op = &reiserfs_quota_operations;
>> -	s->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>>   #endif
>>
>>   	/*
>> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
>> index f2449fd..f8806c89 100644
>> --- a/fs/xfs/xfs_super.c
>> +++ b/fs/xfs/xfs_super.c
>> @@ -55,6 +55,7 @@
>>   #include <linux/kthread.h>
>>   #include <linux/freezer.h>
>>   #include <linux/parser.h>
>> +#include <linux/quotaops.h>
>>
>>   static const struct super_operations xfs_super_operations;
>>   static kmem_zone_t *xfs_ioend_zone;
>> @@ -1434,7 +1435,9 @@ xfs_fs_fill_super(
>>   	sb->s_export_op = &xfs_export_operations;
>>   #ifdef CONFIG_XFS_QUOTA
>>   	sb->s_qcop = &xfs_quotactl_operations;
>> -	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
>> +	sb_set_quota_supported(sb, USRQUOTA);
>> +	sb_set_quota_supported(sb, GRPQUOTA);
>> +	sb_set_quota_supported(sb, PRJQUOTA);
>>   #endif
>>   	sb->s_op = &xfs_super_operations;
>>
>> diff --git a/include/linux/fs.h b/include/linux/fs.h
>> index f125b88..e1d19b6 100644
>> --- a/include/linux/fs.h
>> +++ b/include/linux/fs.h
>> @@ -1257,7 +1257,6 @@ struct super_block {
>>   	struct backing_dev_info *s_bdi;
>>   	struct mtd_info		*s_mtd;
>>   	struct hlist_node	s_instances;
>> -	unsigned int		s_quota_types;	/* Bitmask of supported quota types */
>>   	struct quota_info	s_dquot;	/* Diskquota specific options */
>>
>>   	struct sb_writers	s_writers;
>> diff --git a/include/linux/quota.h b/include/linux/quota.h
>> index 205b4f7..3c6cc80 100644
>> --- a/include/linux/quota.h
>> +++ b/include/linux/quota.h
>> @@ -391,13 +391,15 @@ struct quota_format_type {
>>
>>   /* Quota state flags - they actually come in two flavors - for users and groups */
>>   enum {
>> -	_DQUOT_USAGE_ENABLED = 0,		/* Track disk usage for users */
>> +	_DQUOT_SUPPORTED = 0,			/* Quota type supported by fs */
>> +	_DQUOT_USAGE_ENABLED,			/* Track disk usage for users */
>>   	_DQUOT_LIMITS_ENABLED,			/* Enforce quota limits for users */
>>   	_DQUOT_SUSPENDED,			/* User diskquotas are off, but
>>   						 * we have necessary info in
>>   						 * memory to turn them on */
>>   	_DQUOT_STATE_FLAGS
>>   };
>> +#define DQUOT_SUPPORTED		(1 << _DQUOT_SUPPORTED * MAXQUOTAS)
>>   #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)
>> diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
>> index 8778ec4..e431a87 100644
>> --- a/include/linux/quotaops.h
>> +++ b/include/linux/quotaops.h
>> @@ -110,10 +110,20 @@ static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
>>   	return sb_dqopt(sb)->info + type;
>>   }
>>
>> +static inline void sb_set_quota_supported(struct super_block *sb, unsigned type)
>> +{
>> +	sb_dqopt(sb)->flags |= dquot_state_flag(DQUOT_SUPPORTED, type);
>> +}
>> +
>>   /*
>>    * Functions for checking status of quota
>>    */
>>
>> +static inline bool sb_has_quota_supported(struct super_block *sb, unsigned type)
>> +{
>> +	return sb_dqopt(sb)->flags & dquot_state_flag(DQUOT_SUPPORTED, type);
>> +}
>> +
>>   static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type)
>>   {
>>   	return sb_dqopt(sb)->flags &
>>
diff mbox

Patch

diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index ae55fdd..9e2b1c3 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -1099,7 +1099,8 @@  static int ext2_fill_super(struct super_block *sb, void *data, int silent)
 #ifdef CONFIG_QUOTA
 	sb->dq_op = &dquot_operations;
 	sb->s_qcop = &dquot_quotactl_ops;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
 #endif
 
 	root = ext2_iget(sb, EXT2_ROOT_INO);
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index d4dbf3c..fc71d08 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -2012,7 +2012,8 @@  static int ext3_fill_super (struct super_block *sb, void *data, int silent)
 #ifdef CONFIG_QUOTA
 	sb->s_qcop = &ext3_qctl_operations;
 	sb->dq_op = &ext3_quota_operations;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
 #endif
 	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
 	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ac64edb..e36d73c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3925,7 +3925,8 @@  static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 		sb->s_qcop = &dquot_quotactl_sysfile_ops;
 	else
 		sb->s_qcop = &ext4_qctl_operations;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
 #endif
 	memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
 
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 8633ad3..3e8f590 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -1074,7 +1074,8 @@  static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent
 	sb->s_export_op = &gfs2_export_ops;
 	sb->s_xattr = gfs2_xattr_handlers;
 	sb->s_qcop = &gfs2_quotactl_ops;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
 	sb_dqopt(sb)->flags |= DQUOT_QUOTA_SYS_FILE;
 	sb->s_time_gran = 1;
 	sb->s_maxbytes = MAX_LFS_FILESIZE;
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 16c3a95..b820b76 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -540,7 +540,8 @@  static int jfs_fill_super(struct super_block *sb, void *data, int silent)
 #ifdef CONFIG_QUOTA
 	sb->dq_op = &dquot_operations;
 	sb->s_qcop = &dquot_quotactl_ops;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
 #endif
 
 	/*
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 87a1f76..1db5903 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -2059,7 +2059,8 @@  static int ocfs2_initialize_super(struct super_block *sb,
 	sb->s_export_op = &ocfs2_export_ops;
 	sb->s_qcop = &dquot_quotactl_sysfile_ops;
 	sb->dq_op = &ocfs2_quota_operations;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
 	sb->s_xattr = ocfs2_xattr_handlers;
 	sb->s_time_gran = 1;
 	sb->s_flags |= MS_NOATIME;
diff --git a/fs/quota/quota.c b/fs/quota/quota.c
index d14a799..28d54bc 100644
--- a/fs/quota/quota.c
+++ b/fs/quota/quota.c
@@ -50,7 +50,7 @@  static void quota_sync_one(struct super_block *sb, void *arg)
 	int type = *(int *)arg;
 
 	if (sb->s_qcop && sb->s_qcop->quota_sync &&
-	    (sb->s_quota_types & (1 << type)))
+	    sb_has_quota_supported(sb, type))
 		sb->s_qcop->quota_sync(sb, type);
 }
 
@@ -446,12 +446,12 @@  static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
 	if (type >= (XQM_COMMAND(cmd) ? XQM_MAXQUOTAS : MAXQUOTAS))
 		return -EINVAL;
 	/*
-	 * Quota not supported on this fs? Check this before s_quota_types
+	 * Quota not supported on this fs? Check this before sb_dqopt flags
 	 * since they needn't be set if quota is not supported at all.
 	 */
 	if (!sb->s_qcop)
 		return -ENOSYS;
-	if (!(sb->s_quota_types & (1 << type)))
+	if (!sb_has_quota_supported(sb, type))
 		return -EINVAL;
 
 	ret = check_quotactl_permission(sb, type, cmd, id);
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 71fbbe3..f08740f 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -1643,7 +1643,8 @@  static int read_super_block(struct super_block *s, int offset)
 #ifdef CONFIG_QUOTA
 	s->s_qcop = &reiserfs_qctl_operations;
 	s->dq_op = &reiserfs_quota_operations;
-	s->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
 #endif
 
 	/*
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f2449fd..f8806c89 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -55,6 +55,7 @@ 
 #include <linux/kthread.h>
 #include <linux/freezer.h>
 #include <linux/parser.h>
+#include <linux/quotaops.h>
 
 static const struct super_operations xfs_super_operations;
 static kmem_zone_t *xfs_ioend_zone;
@@ -1434,7 +1435,9 @@  xfs_fs_fill_super(
 	sb->s_export_op = &xfs_export_operations;
 #ifdef CONFIG_XFS_QUOTA
 	sb->s_qcop = &xfs_quotactl_operations;
-	sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP | QTYPE_MASK_PRJ;
+	sb_set_quota_supported(sb, USRQUOTA);
+	sb_set_quota_supported(sb, GRPQUOTA);
+	sb_set_quota_supported(sb, PRJQUOTA);
 #endif
 	sb->s_op = &xfs_super_operations;
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f125b88..e1d19b6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1257,7 +1257,6 @@  struct super_block {
 	struct backing_dev_info *s_bdi;
 	struct mtd_info		*s_mtd;
 	struct hlist_node	s_instances;
-	unsigned int		s_quota_types;	/* Bitmask of supported quota types */
 	struct quota_info	s_dquot;	/* Diskquota specific options */
 
 	struct sb_writers	s_writers;
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 205b4f7..3c6cc80 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -391,13 +391,15 @@  struct quota_format_type {
 
 /* Quota state flags - they actually come in two flavors - for users and groups */
 enum {
-	_DQUOT_USAGE_ENABLED = 0,		/* Track disk usage for users */
+	_DQUOT_SUPPORTED = 0,			/* Quota type supported by fs */
+	_DQUOT_USAGE_ENABLED,			/* Track disk usage for users */
 	_DQUOT_LIMITS_ENABLED,			/* Enforce quota limits for users */
 	_DQUOT_SUSPENDED,			/* User diskquotas are off, but
 						 * we have necessary info in
 						 * memory to turn them on */
 	_DQUOT_STATE_FLAGS
 };
+#define DQUOT_SUPPORTED		(1 << _DQUOT_SUPPORTED * MAXQUOTAS)
 #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)
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 8778ec4..e431a87 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -110,10 +110,20 @@  static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
 	return sb_dqopt(sb)->info + type;
 }
 
+static inline void sb_set_quota_supported(struct super_block *sb, unsigned type)
+{
+	sb_dqopt(sb)->flags |= dquot_state_flag(DQUOT_SUPPORTED, type);
+}
+
 /*
  * Functions for checking status of quota
  */
 
+static inline bool sb_has_quota_supported(struct super_block *sb, unsigned type)
+{
+	return sb_dqopt(sb)->flags & dquot_state_flag(DQUOT_SUPPORTED, type);
+}
+
 static inline bool sb_has_quota_usage_enabled(struct super_block *sb, int type)
 {
 	return sb_dqopt(sb)->flags &