[03/12] xfs: Set allowed quota types
diff mbox

Message ID 1412191894-9113-4-git-send-email-jack@suse.cz
State New, archived
Headers show

Commit Message

Jan Kara Oct. 1, 2014, 7:31 p.m. UTC
We support user, group, and project quotas. Tell VFS about it.

CC: xfs@oss.sgi.com
CC: Dave Chinner <david@fromorbit.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/xfs/xfs_super.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Dave Chinner Oct. 6, 2014, 8:30 p.m. UTC | #1
On Wed, Oct 01, 2014 at 09:31:25PM +0200, Jan Kara wrote:
> We support user, group, and project quotas. Tell VFS about it.
> 
> CC: xfs@oss.sgi.com
> CC: Dave Chinner <david@fromorbit.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
>  fs/xfs/xfs_super.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index b194652033cd..b32e998e8cbc 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1419,6 +1419,8 @@ xfs_fs_fill_super(
>  	sb->s_export_op = &xfs_export_operations;
>  #ifdef CONFIG_XFS_QUOTA
>  	sb->s_qcop = &xfs_quotactl_operations;
> +	sb->s_dquot.allowed_types = (1 << USRQUOTA) | (1 << GRPQUOTA) |
> +				    (1 << PRJQUOTA);

Would it be better to define masks for these rather than open
coding these shifts everywhere?

Cheers,

Dave.
Jan Kara Oct. 7, 2014, 7:29 p.m. UTC | #2
On Tue 07-10-14 07:30:28, Dave Chinner wrote:
> On Wed, Oct 01, 2014 at 09:31:25PM +0200, Jan Kara wrote:
> > We support user, group, and project quotas. Tell VFS about it.
> > 
> > CC: xfs@oss.sgi.com
> > CC: Dave Chinner <david@fromorbit.com>
> > Signed-off-by: Jan Kara <jack@suse.cz>
> > ---
> >  fs/xfs/xfs_super.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index b194652033cd..b32e998e8cbc 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -1419,6 +1419,8 @@ xfs_fs_fill_super(
> >  	sb->s_export_op = &xfs_export_operations;
> >  #ifdef CONFIG_XFS_QUOTA
> >  	sb->s_qcop = &xfs_quotactl_operations;
> > +	sb->s_dquot.allowed_types = (1 << USRQUOTA) | (1 << GRPQUOTA) |
> > +				    (1 << PRJQUOTA);
> 
> Would it be better to define masks for these rather than open
> coding these shifts everywhere?
  I can do that. Any suggestion for a name? I was thinking about it for a
while and couldn't come up with anything satisfactory...

								Honza
Andreas Dilger Oct. 7, 2014, 7:46 p.m. UTC | #3
On Oct 7, 2014, at 1:29 PM, Jan Kara <jack@suse.cz> wrote:
> On Tue 07-10-14 07:30:28, Dave Chinner wrote:
>> On Wed, Oct 01, 2014 at 09:31:25PM +0200, Jan Kara wrote:
>>> We support user, group, and project quotas. Tell VFS about it.
>>> 
>>> CC: xfs@oss.sgi.com
>>> CC: Dave Chinner <david@fromorbit.com>
>>> Signed-off-by: Jan Kara <jack@suse.cz>
>>> ---
>>> fs/xfs/xfs_super.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>> 
>>> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
>>> index b194652033cd..b32e998e8cbc 100644
>>> --- a/fs/xfs/xfs_super.c
>>> +++ b/fs/xfs/xfs_super.c
>>> @@ -1419,6 +1419,8 @@ xfs_fs_fill_super(
>>> 	sb->s_export_op = &xfs_export_operations;
>>> #ifdef CONFIG_XFS_QUOTA
>>> 	sb->s_qcop = &xfs_quotactl_operations;
>>> +	sb->s_dquot.allowed_types = (1 << USRQUOTA) | (1 << GRPQUOTA) |
>>> +				    (1 << PRJQUOTA);
>> 
>> Would it be better to define masks for these rather than open
>> coding these shifts everywhere?
>  I can do that. Any suggestion for a name? I was thinking about it for a
> while and couldn't come up with anything satisfactory...

Better to have QUOTA at the start, and TYPE in the name, so maybe:

enum quota_types {
	QUOTA_TYPE_USR = 1 << USRQUOTA,
	QUOTA_TYPE_GRP = 1 << GRPQUOTA,
	QUOTA_TYPE_PRJ = 1 << PRJQUOTA,
};

or maybe "enum quota_type_mask" or similar.

I prefer named enums over #defines since this makes it more clear
when declaring variables like "allowed_types" what valid values are
instead of just "int" that someone might mistakenly set to USRQUOTA
directly or something.

Cheers, Andreas
Jan Kara Oct. 8, 2014, 8:42 a.m. UTC | #4
On Tue 07-10-14 13:46:20, Andreas Dilger wrote:
> On Oct 7, 2014, at 1:29 PM, Jan Kara <jack@suse.cz> wrote:
> > On Tue 07-10-14 07:30:28, Dave Chinner wrote:
> >> On Wed, Oct 01, 2014 at 09:31:25PM +0200, Jan Kara wrote:
> >>> We support user, group, and project quotas. Tell VFS about it.
> >>> 
> >>> CC: xfs@oss.sgi.com
> >>> CC: Dave Chinner <david@fromorbit.com>
> >>> Signed-off-by: Jan Kara <jack@suse.cz>
> >>> ---
> >>> fs/xfs/xfs_super.c | 2 ++
> >>> 1 file changed, 2 insertions(+)
> >>> 
> >>> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> >>> index b194652033cd..b32e998e8cbc 100644
> >>> --- a/fs/xfs/xfs_super.c
> >>> +++ b/fs/xfs/xfs_super.c
> >>> @@ -1419,6 +1419,8 @@ xfs_fs_fill_super(
> >>> 	sb->s_export_op = &xfs_export_operations;
> >>> #ifdef CONFIG_XFS_QUOTA
> >>> 	sb->s_qcop = &xfs_quotactl_operations;
> >>> +	sb->s_dquot.allowed_types = (1 << USRQUOTA) | (1 << GRPQUOTA) |
> >>> +				    (1 << PRJQUOTA);
> >> 
> >> Would it be better to define masks for these rather than open
> >> coding these shifts everywhere?
> >  I can do that. Any suggestion for a name? I was thinking about it for a
> > while and couldn't come up with anything satisfactory...
> 
> Better to have QUOTA at the start, and TYPE in the name, so maybe:
> 
> enum quota_types {
> 	QUOTA_TYPE_USR = 1 << USRQUOTA,
> 	QUOTA_TYPE_GRP = 1 << GRPQUOTA,
> 	QUOTA_TYPE_PRJ = 1 << PRJQUOTA,
> };
> 
> or maybe "enum quota_type_mask" or similar.
> 
> I prefer named enums over #defines since this makes it more clear
> when declaring variables like "allowed_types" what valid values are
> instead of just "int" that someone might mistakenly set to USRQUOTA
> directly or something.
  OK, QUOTA_TYPE_USR etc. looks good. I'm not so sure about named enum. I'd
be fine with named enum for USRQUOTA, GRPQUOTA, etc. - i.e., types which
should have one of the named values but for a bitmask with arbitrary
combinations of flags it looks confusing to me (although technically
it would work).

								Honza

Patch
diff mbox

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index b194652033cd..b32e998e8cbc 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1419,6 +1419,8 @@  xfs_fs_fill_super(
 	sb->s_export_op = &xfs_export_operations;
 #ifdef CONFIG_XFS_QUOTA
 	sb->s_qcop = &xfs_quotactl_operations;
+	sb->s_dquot.allowed_types = (1 << USRQUOTA) | (1 << GRPQUOTA) |
+				    (1 << PRJQUOTA);
 #endif
 	sb->s_op = &xfs_super_operations;