quota: Unify VFS and XFS quota interfaces
Subsystems (6)
Jan Kara
reviewerv3 cover quota: Unify VFS and XFS quota interfaces
Hello,
this is another iteration of patches to unify VFS and XFS quota interfaces so
that XFS quotactls work for filesystems with VFS quotas and vice versa. This is useful so that userspace doesn't have to care that much about which filesystem it is using at least when using basic quota functionality. In particular we should be able to reuse project quota tests in xfstests for ext4.
The patches are based on quota cleanup series [1] and XFS cleanup series [2] I've sent previously and based on 3.19-rc4 + for-next branch of XFS tree. I could further split this series into per-quotactl series but frankly I don't think it will help reviewers in any way (the patches in the current series are already ordered by quotactl).
I would like to get some review especially of the fs-specific parts of the series - mostly for XFS where things aren't always trivial.
Some more details about the series below:
In this patch set I unify quotaon / quotaoff handling (Q_QUOTAON, Q_QUOTAOFF, Q_XQUOTAON, Q_XQUOTAOFF calls), fix some bugs in the Q_XGETQUOTA, Q_XSETQLIM, Q_GETQUOTA, Q_SETQUOTA calls done by Christoph some time ago, unify Q_GETXSTATE, Q_GETXSTATV with Q_GETINFO, and also wire up Q_SETINFO to work with XFS (and Q_XSETQLIM for id 0 to modify time limits for VFS quotas). So after these patches xfs_quota can manipulate quotas for ext4 filesystem and similarly quota-tools can be used to manipulate quotas for xfs filesystem.
I have also verified that xfstests pass fine both for xfs and ext4 so hopefully I didn't introduce any regression in the current functionality (I also did a couple of manual checks for timer setting etc).
All the comments to the first version of the series are hopefully addressed, except for Dave's request to reduce number of copying of dquot information - I have benchmarked that reducing number of copies from 3 to 2 brings just 2% improvement in speed in my test setup and getting quota information isn't IMHO so performance critical that it would be worth the complications of the code.
Honza
[1] http://www.spinics.net/lists/linux-fsdevel/msg81903.html
[2] http://www.spinics.net/lists/xfs/msg31389.html
Jan Kara
reviewerPATCH v3 1/17 quota: Split ->set_xstate callback into two
Split ->set_xstate callback into two callbacks - one for turning quotas on (->quota_enable) and one for turning quotas off (->quota_disable). That way we don't have to pass quotactl command into the callback which seems cleaner.
--- fs/quota/quota.c | 20 ++++++++++++++---- fs/xfs/xfs_quotaops.c | 58 ++++++++++++++++++++++++++++++++------------------- include/linux/quota.h | 3 ++- 3 files changed, 54 insertions(+), 27 deletions(-)
fs/quota/quota.c +16 -4
@@ -198,15 +198,26 @@ static int quota_setquota(struct super_block *sb, int type, qid_t id,return sb->s_qcop->set_dqblk (sb, qid, &fdq); } -static int quota_setxstate (struct super_block *sb,int cmd,void __user *addr) +static int quota_enable (struct super_block *sb,void __user *addr) {__u32 flags;if (copy_from_user (&flags, addr,sizeof (flags)))return -EFAULT ; -if (!sb->s_qcop->set_xstate) +if (!sb->s_qcop->quota_enable)return -ENOSYS ; -return sb->s_qcop->set_xstate (sb, flags, cmd); +return sb->s_qcop->quota_enable (sb, flags); +} + +static int quota_disable (struct super_block *sb,void __user *addr) +{ +__u32 flags; + +if (copy_from_user (&flags, addr,sizeof (flags))) +return -EFAULT ; +if (!sb->s_qcop->quota_disable) +return -ENOSYS ; +return sb->s_qcop->quota_disable (sb, flags); }static int quota_getxstate (struct super_block *sb,void __user *addr)
@@ -335,8 +346,9 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,return -ENOSYS ;return sb->s_qcop->quota_sync (sb, type);case Q_XQUOTAON : +return quota_enable (sb, addr);case Q_XQUOTAOFF : -return quota_setxstate (sb, cmd, addr); +return quota_disable (sb, addr);case Q_XQUOTARM :return quota_rmxquota (sb, addr);case Q_XGETQSTAT :
fs/xfs/xfs_quotaops.c +36 -22
78 lines not on this page · raw message
include/linux/quota.h +2 -1
@@ -328,13 +328,14 @@ struct quotactl_ops {int (*quota_on)(struct super_block *,int ,int ,struct path *);int (*quota_on_meta)(struct super_block *,int ,int );int (*quota_off)(struct super_block *,int ); +int (*quota_enable)(struct super_block *,unsigned int ); +int (*quota_disable)(struct super_block *,unsigned int );int (*quota_sync)(struct super_block *,int );int (*get_info)(struct super_block *,int ,struct if_dqinfo *);int (*set_info)(struct super_block *,int ,struct if_dqinfo *);int (*get_dqblk)(struct super_block *,struct kqid ,struct fs_disk_quota *);int (*set_dqblk)(struct super_block *,struct kqid ,struct fs_disk_quota *);int (*get_xstate)(struct super_block *,struct fs_quota_stat *); -int (*set_xstate)(struct super_block *,unsigned int ,int );int (*get_xstatev)(struct super_block *,struct fs_quota_statv *);int (*rm_xquota)(struct super_block *,unsigned int ); };
Signature · 1 line
2.1.2
Re: [PATCH 01/17] quota: Split ->set_xstate callback into two
Quoted 6 lines · Jan Kara
Split ->set_xstate callback into two callbacks - one for turning quotas on (->quota_enable) and one for turning quotas off (->quota_disable). That way we don't have to pass quotactl command into the callback which seems cleaner.
Signed-off-by Jan Kara <[email protected]>
Looks good,
Jan Kara
reviewerPATCH v3 2/17 quota: Wire up ->quota_{enable,disable} callbacks into Q_QUOTA{ON,OFF}
In reply to Jan KaraMake Q_QUOTAON / Q_QUOTAOFF quotactl call ->quota_enable / ->quota_disable callback when provided. To match current behavior of ocfs2 & ext4 we make these quotactls turn on / off quota enforcement for appropriate quota type.
--- fs/quota/quota.c | 31 +++++++++++++++++++++++++++---- include/linux/quotaops.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-)
fs/quota/quota.c +27 -4
@@ -66,18 +66,43 @@ static int quota_sync_all(int type)return ret; } +unsigned int qtype_limit_flag (int type) +{ +switch (type) { +case USRQUOTA : +return FS_QUOTA_UDQ_ENFD ; +case GRPQUOTA : +return FS_QUOTA_GDQ_ENFD ; +case PRJQUOTA : +return FS_QUOTA_PDQ_ENFD ; + } +return 0 ; +} +static int quota_quotaon (struct super_block *sb,int type,int cmd,qid_t id,struct path *path) { -if (!sb->s_qcop->quota_on && !sb->s_qcop->quota_on_meta) +if (!sb->s_qcop->quota_on && !sb->s_qcop->quota_on_meta && + !sb->s_qcop->quota_enable)return -ENOSYS ;if (sb->s_qcop->quota_on_meta)return sb->s_qcop->quota_on_meta (sb, type, id); +if (sb->s_qcop->quota_enable) +return sb->s_qcop->quota_enable (sb,qtype_limit_flag (type));if (IS_ERR (path))return PTR_ERR (path);return sb->s_qcop->quota_on (sb, type, id, path); } +static int quota_quotaoff (struct super_block *sb,int type) +{ +if (!sb->s_qcop->quota_off && !sb->s_qcop->quota_disable) +return -ENOSYS ; +if (sb->s_qcop->quota_disable) +return sb->s_qcop->quota_disable (sb,qtype_limit_flag (type)); +return sb->s_qcop->quota_off (sb, type); +} +static int quota_getfmt (struct super_block *sb,int type,void __user *addr) {__u32 fmt;
@@ -328,9 +353,7 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,case Q_QUOTAON :return quota_quotaon (sb, type, cmd, id, path);case Q_QUOTAOFF : -if (!sb->s_qcop->quota_off) -return -ENOSYS ; -return sb->s_qcop->quota_off (sb, type); +return quota_quotaoff (sb, type);case Q_GETFMT :return quota_getfmt (sb, type, addr);case Q_GETINFO :
include/linux/quotaops.h +2 -0
@@ -386,4 +386,6 @@ static inline void dquot_release_reservation_block(struct inode *inode, __dquot_free_space(inode, nr << inode->i_blkbits, DQUOT_SPACE_RESERVE); } +unsigned int qtype_limit_flag (int type); +#endif /* _LINUX_QUOTAOPS_ */
Signature · 1 line
2.1.2
Re: [PATCH 02/17] quota: Wire up ->quota_{enable,disable} callbacks into Q_QUOTA{ON,OFF}
Quoted 20 lines · Jan Kara
Make
Q_QUOTAON/Q_QUOTAOFFquotactl call ->quota_enable / ->quota_disable callback when provided. To match current behavior of ocfs2 & ext4 we make these quotactls turn on / off quota enforcement for appropriate quota type.Signed-off-by Jan Kara <[email protected]>--- fs/quota/quota.c | 31 +++++++++++++++++++++++++++---- include/linux/quotaops.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-)fs/quota/quota.c +1
-0@@ -66,18 +66,43 @@ static int quota_sync_all(int type)return ret; } +unsigned int qtype_limit_flag (int type)
fs/quota/quota.c static int quota_sync_all(int type) · line 79
Quoted 10 lines
fs/quota/quota.c +10
-0+{ +switch (type) { +case USRQUOTA : +return FS_QUOTA_UDQ_ENFD ; +case GRPQUOTA : +return FS_QUOTA_GDQ_ENFD ; +case PRJQUOTA : +return FS_QUOTA_PDQ_ENFD ; + } +return 0 ;
What's the limit_ in the name supposed to mean?
Otherwise looks good:
Jan Kara
reviewerRe: [PATCH 02/17] quota: Wire up ->quota_{enable,disable} callbacks into Q_QUOTA{ON,OFF}
Quoted 20 lines · Christoph Hellwig
Quoted 19 lines · Jan Kara
Make
Q_QUOTAON/Q_QUOTAOFFquotactl call ->quota_enable / ->quota_disable callback when provided. To match current behavior of ocfs2 & ext4 we make these quotactls turn on / off quota enforcement for appropriate quota type.Signed-off-by Jan Kara <[email protected]>--- fs/quota/quota.c | 31 +++++++++++++++++++++++++++---- include/linux/quotaops.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-)fs/quota/quota.c +0
-0@@ -66,18 +66,43 @@ static int quota_sync_all(int type)return ret; }
Quoted 14 lines
fs/quota/quota.c static int quota_sync_all(int type) · line 79
Quoted 11 lines
fs/quota/quota.c +11
-0+unsigned int qtype_limit_flag (int type) +{ +switch (type) { +case USRQUOTA : +return FS_QUOTA_UDQ_ENFD ; +case GRPQUOTA : +return FS_QUOTA_GDQ_ENFD ; +case PRJQUOTA : +return FS_QUOTA_PDQ_ENFD ; + } +return 0 ;What's the
limit_in the name supposed to mean?
qtype_enforce_flag() explains probably better what's going on so I've
used that instead.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerPATCH v3 3/17 quota: Add ->quota_{enable, disable} callbacks for VFS quotas
In reply to Jan KaraAdd functions which translate ->quota_enable / ->quota_disable calls into appropriate changes in VFS quota. This will enable filesystems supporting VFS quota files in system inodes to be controlled via Q_XQUOTA[ON|OFF] quotactls for better userspace compatibility.
Also provide a vector for quotactl using these functions which can be used by filesystems with quota files stored in hidden system files.
--- fs/quota/dquot.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/quotaops.h | 3 ++ 2 files changed, 96 insertions(+)
fs/quota/dquot.c +93 -0
@@ -2385,6 +2385,88 @@ out: }EXPORT_SYMBOL (dquot_quota_on_mount); +int dquot_quota_enable (struct super_block *sb,unsigned int flags) +{ +int ret; +int type; +struct quota_info *dqopt =sb_dqopt (sb); + +if (!(dqopt->flags &DQUOT_QUOTA_SYS_FILE )) +return -ENOSYS ; +/* Accounting cannot be turned on while fs is mounted */ + flags &= ~(FS_QUOTA_UDQ_ACCT |FS_QUOTA_GDQ_ACCT |FS_QUOTA_PDQ_ACCT ); +if (!flags) +return -EINVAL ; +for (type =0 ; type <MAXQUOTAS ; type++) { +if (!(flags &qtype_limit_flag (type))) +continue ; +/* Can't enforce without accounting */ +if (!sb_has_quota_usage_enabled (sb, type)) +return -EINVAL ; + ret =dquot_enable (dqopt->files[type], type, + dqopt->info[type].dqi_fmt_id, +DQUOT_LIMITS_ENABLED ); +if (ret <0 ) + goto out_err; + } +return 0 ; +out_err: +/* Backout enforcement enablement we already did */ +for (type--; type >=0 ; type--) { +if (flags &qtype_limit_flag (type)) +dquot_disable (sb, type,DQUOT_LIMITS_ENABLED ); + } +/* Error code translation for better compatibility with XFS */ +if (ret == -EBUSY ) + ret = -EEXIST ; +return ret; +} +EXPORT_SYMBOL (dquot_quota_enable); + +int dquot_quota_disable (struct super_block *sb,unsigned int flags) +{ +int ret; +int type; +struct quota_info *dqopt =sb_dqopt (sb); + +if (!(dqopt->flags &DQUOT_QUOTA_SYS_FILE )) +return -ENOSYS ; +/* +* We don't support turning off accounting via quotactl. In principle +* quota infrastructure can do this but filesystems don't expect +* userspace to be able to do it. +*/ +if (flags & + (FS_QUOTA_UDQ_ACCT |FS_QUOTA_GDQ_ACCT |FS_QUOTA_PDQ_ACCT )) +return -EOPNOTSUPP ; + +/* Filter out limits not enabled */ +for (type =0 ; type <MAXQUOTAS ; type++) +if (!sb_has_quota_limits_enabled (sb, type)) + flags &= ~qtype_limit_flag (type); +/* Nothing left? */ +if (!flags) +return -EEXIST ; +for (type =0 ; type <MAXQUOTAS ; type++) { +if (flags &qtype_limit_flag (type)) { + ret =dquot_disable (sb, type,DQUOT_LIMITS_ENABLED ); +if (ret <0 ) + goto out_err; + } + } +return 0 ; +out_err: +/* Backout enforcement disabling we already did */ +for (type--; type >=0 ; type--) { +if (flags &qtype_limit_flag (type)) +dquot_enable (dqopt->files[type], type, + dqopt->info[type].dqi_fmt_id, +DQUOT_LIMITS_ENABLED ); + } +return ret; +} +EXPORT_SYMBOL (dquot_quota_disable); +static inline qsize_t qbtos (qsize_t blocks) {return blocks <<QIF_DQBLKSIZE_BITS ;
@@ -2619,6 +2701,17 @@ const struct quotactl_ops dquot_quotactl_ops = { };EXPORT_SYMBOL (dquot_quotactl_ops); +const struct quotactl_ops dquot_quotactl_sysfile_ops = { + .quota_enable = dquot_quota_enable, + .quota_disable = dquot_quota_disable, + .quota_sync = dquot_quota_sync, + .get_info = dquot_get_dqinfo, + .set_info = dquot_set_dqinfo, + .get_dqblk = dquot_get_dqblk, + .set_dqblk = dquot_set_dqblk +}; +EXPORT_SYMBOL (dquot_quotactl_sysfile_ops); +static int do_proc_dqstats (struct ctl_table *table,int write,void __user *buffer,size_t *lenp,loff_t *ppos) {
include/linux/quotaops.h +3 -0
@@ -93,6 +93,8 @@ int dquot_quota_on(struct super_block *sb, int type, int format_id,int dquot_quota_on_mount (struct super_block *sb,char *qf_name,int format_id,int type);int dquot_quota_off (struct super_block *sb,int type); +int dquot_quota_enable (struct super_block *sb,unsigned int flags); +int dquot_quota_disable (struct super_block *sb,unsigned int flags);int dquot_writeback_dquots (struct super_block *sb,int type);int dquot_quota_sync (struct super_block *sb,int type);int dquot_get_dqinfo (struct super_block *sb,int type,struct if_dqinfo *ii);
@@ -166,6 +168,7 @@ static inline bool sb_has_quota_active(struct super_block *sb, int type)*/ extern const struct dquot_operations dquot_operations;extern const struct quotactl_ops dquot_quotactl_ops; +extern const struct quotactl_ops dquot_quotactl_sysfile_ops;#else
Signature · 1 line
2.1.2
Re: [PATCH 03/17] quota: Add ->quota_{enable,disable} callbacks for VFS quotas
fs/quota/dquot.c out: · line 2468
Quoted 3 lines · Jan Kara
fs/quota/dquot.c +2
-0+EXPORT_SYMBOL (dquot_quota_enable); +EXPORT_SYMBOL (dquot_quota_disable);
I can't find any modular users of this (in fact none outside this file), so I'd suggest to keep these local.
Jan Kara
reviewerRe: [PATCH 03/17] quota: Add ->quota_{enable,disable} callbacks for VFS quotas
Quoted 7 lines · Christoph Hellwig
fs/quota/dquot.c out: · line 2468
Quoted 3 lines · Jan Kara
fs/quota/dquot.c +2
-0+EXPORT_SYMBOL (dquot_quota_enable); +EXPORT_SYMBOL (dquot_quota_disable);I can't find any modular users of this (in fact none outside this file), so I'd suggest to keep these local.
OK, we can do that. I've exported the functions because in principle
filesystems are free to provide own .quota_enable function and then may want to call dquot_quota_enable() from there but currently nobody needs that so let's export them only if there are real users.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerPATCH v3 4/17 ext4: Use generic helpers for quotaon and quotaoff
In reply to Jan KaraExt4 can just use the generic helpers provided by quota code for turning quotas on and off when quota files are stored as system inodes. The only difference is the feature test in ext4_quota_on_sysfile() but the same is achieved in dquot_quota_enable() by checking whether usage tracking for the corresponding quota type is enabled (which can happen only if quota feature is set).
--- fs/ext4/super.c | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-)
fs/ext4/super.c +1 -41
@@ -1046,10 +1046,7 @@ static int ext4_mark_dquot_dirty(struct dquot *dquot);static int ext4_write_info (struct super_block *sb,int type);static int ext4_quota_on (struct super_block *sb,int type,int format_id,struct path *path); -static int ext4_quota_on_sysfile (struct super_block *sb,int type, -int format_id);static int ext4_quota_off (struct super_block *sb,int type); -static int ext4_quota_off_sysfile (struct super_block *sb,int type);static int ext4_quota_on_mount (struct super_block *sb,int type);static ssize_t ext4_quota_read (struct super_block *sb,int type,char *data,size_t len,loff_t off);
@@ -1084,16 +1081,6 @@ static const struct quotactl_ops ext4_qctl_operations = { .get_dqblk = dquot_get_dqblk, .set_dqblk = dquot_set_dqblk }; - -static const struct quotactl_ops ext4_qctl_sysfile_operations = { - .quota_on_meta = ext4_quota_on_sysfile, - .quota_off = ext4_quota_off_sysfile, - .quota_sync = dquot_quota_sync, - .get_info = dquot_get_dqinfo, - .set_info = dquot_set_dqinfo, - .get_dqblk = dquot_get_dqblk, - .set_dqblk = dquot_set_dqblk -};#endif static const struct super_operations ext4_sops = {
@@ -3935,7 +3922,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)#ifdef CONFIG_QUOTA sb->dq_op = &ext4_quota_operations;if (EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_QUOTA )) - sb->s_qcop = &ext4_qctl_sysfile_operations; + sb->s_qcop = &dquot_quotactl_sysfile_ops;else sb->s_qcop = &ext4_qctl_operations; sb->s_quota_types =QTYPE_MASK_USR |QTYPE_MASK_GRP ;
@@ -5288,21 +5275,6 @@ static int ext4_enable_quotas(struct super_block *sb)return 0 ; } -/* -* quota_on function that is used when QUOTA feature is set. -*/ -static int ext4_quota_on_sysfile (struct super_block *sb,int type, -int format_id) -{ -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_QUOTA )) -return -EINVAL ; - -/* -* USAGE was enabled at mount time. Only need to enable LIMITS now. -*/ -return ext4_quota_enable (sb, type, format_id,DQUOT_LIMITS_ENABLED ); -} -static int ext4_quota_off (struct super_block *sb,int type) {struct inode *inode =sb_dqopt (sb)->files[type];
@@ -5329,18 +5301,6 @@ out:return dquot_quota_off (sb, type); } -/* -* quota_off function that is used when QUOTA feature is set. -*/ -static int ext4_quota_off_sysfile (struct super_block *sb,int type) -{ -if (!EXT4_HAS_RO_COMPAT_FEATURE (sb,EXT4_FEATURE_RO_COMPAT_QUOTA )) -return -EINVAL ; - -/* Disable only the limits. */ -return dquot_disable (sb, type,DQUOT_LIMITS_ENABLED ); -} -/* Read data from quotafile - avoid pagecache and such because we cannot afford * acquiring the locks... As quota files are never truncated and quota code * itself serializes the operations (and no one else should touch the files)
Signature · 1 line
2.1.2
Re: [PATCH 04/17] ext4: Use generic helpers for quotaon and quotaoff
Looks good,
Jan Kara
reviewerPATCH v3 5/17 ocfs2: Use generic helpers for quotaon and quotaoff
In reply to Jan KaraOcfs2 can just use the generic helpers provided by quota code for turning quotas on and off when quota files are stored as system inodes. The only difference is the feature test in ocfs2_quota_on() and that is covered by dquot_quota_enable() checking whether usage tracking is enabled (which can happen only if the filesystem has the quota feature set).
--- fs/ocfs2/super.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-)
fs/ocfs2/super.c +1 -31
@@ -1000,36 +1000,6 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb) } } -/* Handle quota on quotactl */ -static int ocfs2_quota_on (struct super_block *sb,int type,int format_id) -{ -unsigned int feature[OCFS2_MAXQUOTAS ] = { -OCFS2_FEATURE_RO_COMPAT_USRQUOTA , -OCFS2_FEATURE_RO_COMPAT_GRPQUOTA }; - -if (!OCFS2_HAS_RO_COMPAT_FEATURE (sb, feature[type])) -return -EINVAL ; - -return dquot_enable (sb_dqopt (sb)->files[type], type, - format_id,DQUOT_LIMITS_ENABLED ); -} - -/* Handle quota off quotactl */ -static int ocfs2_quota_off (struct super_block *sb,int type) -{ -return dquot_disable (sb, type,DQUOT_LIMITS_ENABLED ); -} - -static const struct quotactl_ops ocfs2_quotactl_ops = { - .quota_on_meta = ocfs2_quota_on, - .quota_off = ocfs2_quota_off, - .quota_sync = dquot_quota_sync, - .get_info = dquot_get_dqinfo, - .set_info = dquot_set_dqinfo, - .get_dqblk = dquot_get_dqblk, - .set_dqblk = dquot_set_dqblk, -}; -static int ocfs2_fill_super (struct super_block *sb,void *data,int silent) {struct dentry *root;
@@ -2079,7 +2049,7 @@ static int ocfs2_initialize_super(struct super_block *sb, sb->s_op = &ocfs2_sops; sb->s_d_op = &ocfs2_dentry_ops; sb->s_export_op = &ocfs2_export_ops; - sb->s_qcop = &ocfs2_quotactl_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->s_xattr = ocfs2_xattr_handlers;
Signature · 1 line
2.1.2
Re: [PATCH 05/17] ocfs2: Use generic helpers for quotaon and quotaoff
Quoted 19 lines · Jan Kara
Ocfs2 can just use the generic helpers provided by quota code for turning quotas on and off when quota files are stored as system inodes. The only difference is the feature test in
ocfs2_quota_on()and that is covered bydquot_quota_enable()checking whether usage tracking is enabled (which can happen only if the filesystem has the quota feature set).Signed-off-by Jan Kara <[email protected]>--- fs/ocfs2/super.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-)fs/ocfs2/super.c +0
-0@@ -1000,36 +1000,6 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb) } }
fs/ocfs2/super.c static void ocfs2_disable_quotas(struct ocfs2_super *osb) · line 1011
Quoted 10 lines
fs/ocfs2/super.c +0
-9-/* Handle quota on quotactl */ -static int ocfs2_quota_on (struct super_block *sb,int type,int format_id) -{ -unsigned int feature[OCFS2_MAXQUOTAS ] = { -OCFS2_FEATURE_RO_COMPAT_USRQUOTA , -OCFS2_FEATURE_RO_COMPAT_GRPQUOTA }; - -if (!OCFS2_HAS_RO_COMPAT_FEATURE (sb, feature[type])) -return -EINVAL ;
Where are we doing this feature check now?
Jan Kara
reviewerRe: [PATCH 05/17] ocfs2: Use generic helpers for quotaon and quotaoff
Quoted 21 lines · Christoph Hellwig
Quoted 20 lines · Jan Kara
Ocfs2 can just use the generic helpers provided by quota code for turning quotas on and off when quota files are stored as system inodes. The only difference is the feature test in
ocfs2_quota_on()and that is covered bydquot_quota_enable()checking whether usage tracking is enabled (which can happen only if the filesystem has the quota feature set).Signed-off-by Jan Kara <[email protected]>--- fs/ocfs2/super.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-)fs/ocfs2/super.c +0
-0@@ -1000,36 +1000,6 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb) } }
Quoted 11 lines
fs/ocfs2/super.c static void ocfs2_disable_quotas(struct ocfs2_super *osb) · line 1011
Quoted 9 lines
fs/ocfs2/super.c +0
-9-/* Handle quota on quotactl */ -static int ocfs2_quota_on (struct super_block *sb,int type,int format_id) -{ -unsigned int feature[OCFS2_MAXQUOTAS ] = { -OCFS2_FEATURE_RO_COMPAT_USRQUOTA , -OCFS2_FEATURE_RO_COMPAT_GRPQUOTA }; - -if (!OCFS2_HAS_RO_COMPAT_FEATURE (sb, feature[type])) -return -EINVAL ;Where are we doing this feature check now?
So OCFS2 (similarly as ext4 or xfs) has to enable quota accounting on
mount and at that point we test for the feature. Q_QUOTAON quotactl is used just to turn on enforcement and at that point it makes no sense to check for the feature (BTW, the changelog already explains this ;).
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerPATCH v3 6/17 quota: Remove quota_on_meta callback
In reply to Jan KaraThere are no more users for quota_on_meta callback. Just remove it.
--- fs/quota/quota.c | 5 +---- include/linux/quota.h | 1 - 2 files changed, 1 insertion(+), 5 deletions(-)
fs/quota/quota.c +1 -4
@@ -82,11 +82,8 @@ unsigned int qtype_limit_flag(int type)static int quota_quotaon (struct super_block *sb,int type,int cmd,qid_t id,struct path *path) { -if (!sb->s_qcop->quota_on && !sb->s_qcop->quota_on_meta && - !sb->s_qcop->quota_enable) +if (!sb->s_qcop->quota_on && !sb->s_qcop->quota_enable)return -ENOSYS ; -if (sb->s_qcop->quota_on_meta) -return sb->s_qcop->quota_on_meta (sb, type, id);if (sb->s_qcop->quota_enable)return sb->s_qcop->quota_enable (sb,qtype_limit_flag (type));if (IS_ERR (path))
include/linux/quota.h +0 -1
@@ -326,7 +326,6 @@ struct path;/* Operations handling requests from userspace */ struct quotactl_ops {int (*quota_on)(struct super_block *,int ,int ,struct path *); -int (*quota_on_meta)(struct super_block *,int ,int );int (*quota_off)(struct super_block *,int );int (*quota_enable)(struct super_block *,unsigned int );int (*quota_disable)(struct super_block *,unsigned int );
Signature · 1 line
2.1.2
Re: [PATCH 06/17] quota: Remove quota_on_meta callback
Looks good,
Jan Kara
reviewerPATCH v3 7/17 quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units
In reply to Jan KaraCurrently ->get_dqblk() and ->set_dqblk() use struct fs_disk_quota which tracks space limits and usage in 512-byte blocks. However VFS quotas track usage in bytes (as some filesystems require that) and we need to somehow pass this information. Upto now it wasn't a problem because we didn't do any unit conversion (thus VFS quota routines happily stuck number of bytes into d_bcount field of struct fd_disk_quota). Only if you tried to use Q_XGETQUOTA or Q_XSETQLIM for VFS quotas (or Q_GETQUOTA / Q_SETQUOTA for XFS quotas), you got bogus results but noone really tried that. But when we want interfaces compatible we need to fix this.
So we bite the bullet and define another quota structure used for passing information from/to ->get_dqblk()/->set_dqblk. It's somewhat sad we have to have more conversion routines in fs/quota/quota.c but it seems cleaner than overloading e.g. units of d_bcount to bytes.
--- fs/gfs2/quota.c | 49 ++++++------- fs/quota/dquot.c | 83 +++++++++++----------- fs/quota/quota.c | 145 +++++++++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_fs.h | 14 ---- fs/xfs/xfs_qm.h | 4 +- fs/xfs/xfs_qm_syscalls.c | 156 +++++++++++++++++------------------------ fs/xfs/xfs_quotaops.c | 8 +-- include/linux/quota.h | 47 ++++++++++++- include/linux/quotaops.h | 4 +- include/uapi/linux/dqblk_xfs.h | 12 ++++ 10 files changed, 313 insertions(+), 209 deletions(-)
fs/gfs2/quota.c +23 -26
@@ -667,7 +667,7 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)static int gfs2_adjust_quota (struct gfs2_inode *ip,loff_t loc,s64 change,struct gfs2_quota_data *qd, -struct fs_disk_quota *fdq) +struct qc_dqblk *fdq) {struct inode *inode = &ip->i_inode;struct gfs2_sbd *sdp =GFS2_SB (inode);
@@ -697,16 +697,16 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,be64_add_cpu (&q.qu_value, change); qd->qd_qb.qb_value = q.qu_value;if (fdq) { -if (fdq->d_fieldmask &FS_DQ_BSOFT ) { - q.qu_warn =cpu_to_be64 (fdq->d_blk_softlimit >> sdp->sd_fsb2bb_shift); +if (fdq->d_fieldmask &QC_SPC_SOFT ) { + q.qu_warn =cpu_to_be64 (fdq->d_spc_softlimit >> sdp->sd_sb.sb_bsize_shift); qd->qd_qb.qb_warn = q.qu_warn; } -if (fdq->d_fieldmask &FS_DQ_BHARD ) { - q.qu_limit =cpu_to_be64 (fdq->d_blk_hardlimit >> sdp->sd_fsb2bb_shift); +if (fdq->d_fieldmask &QC_SPC_HARD ) { + q.qu_limit =cpu_to_be64 (fdq->d_spc_hardlimit >> sdp->sd_sb.sb_bsize_shift); qd->qd_qb.qb_limit = q.qu_limit; } -if (fdq->d_fieldmask &FS_DQ_BCOUNT ) { - q.qu_value =cpu_to_be64 (fdq->d_bcount >> sdp->sd_fsb2bb_shift); +if (fdq->d_fieldmask &QC_SPACE ) { + q.qu_value =cpu_to_be64 (fdq->d_space >> sdp->sd_sb.sb_bsize_shift); qd->qd_qb.qb_value = q.qu_value; } }
@@ -1497,7 +1497,7 @@ static int gfs2_quota_get_xstate(struct super_block *sb, }static int gfs2_get_dqblk (struct super_block *sb,struct kqid qid, -struct fs_disk_quota *fdq) +struct qc_dqblk *fdq) {struct gfs2_sbd *sdp = sb->s_fs_info;struct gfs2_quota_lvb *qlvb;
@@ -1505,7 +1505,7 @@ static int gfs2_get_dqblk(struct super_block *sb, struct kqid qid,struct gfs2_holder q_gh;int error; -memset (fdq,0 ,sizeof (struct fs_disk_quota )); +memset (fdq,0 ,sizeof (*fdq));if (sdp->sd_args.ar_quota ==GFS2_QUOTA_OFF )return -ESRCH ;/* Crazy XFS error code */
@@ -1522,12 +1522,9 @@ static int gfs2_get_dqblk(struct super_block *sb, struct kqid qid, goto out; qlvb = (struct gfs2_quota_lvb *)qd->qd_gl->gl_lksb.sb_lvbptr; - fdq->d_version =FS_DQUOT_VERSION ; - fdq->d_flags = (qid.type ==USRQUOTA ) ?FS_USER_QUOTA :FS_GROUP_QUOTA ; - fdq->d_id =from_kqid_munged (current_user_ns (), qid); - fdq->d_blk_hardlimit =be64_to_cpu (qlvb->qb_limit) << sdp->sd_fsb2bb_shift; - fdq->d_blk_softlimit =be64_to_cpu (qlvb->qb_warn) << sdp->sd_fsb2bb_shift; - fdq->d_bcount =be64_to_cpu (qlvb->qb_value) << sdp->sd_fsb2bb_shift; + fdq->d_spc_hardlimit =be64_to_cpu (qlvb->qb_limit) << sdp->sd_sb.sb_bsize_shift; + fdq->d_spc_softlimit =be64_to_cpu (qlvb->qb_warn) << sdp->sd_sb.sb_bsize_shift; + fdq->d_space =be64_to_cpu (qlvb->qb_value) << sdp->sd_sb.sb_bsize_shift;gfs2_glock_dq_uninit (&q_gh); out:
@@ -1536,10 +1533,10 @@ out: }/* GFS2 only supports a subset of the XFS fields */ -#define GFS2_FIELDMASK (FS_DQ_BSOFT|FS_DQ_BHARD|FS_DQ_BCOUNT) +#define GFS2_FIELDMASK (QC_SPC_SOFT|QC_SPC_HARD|QC_SPACE)static int gfs2_set_dqblk (struct super_block *sb,struct kqid qid, -struct fs_disk_quota *fdq) +struct qc_dqblk *fdq) {struct gfs2_sbd *sdp = sb->s_fs_info;struct gfs2_inode *ip =GFS2_I (sdp->sd_quota_inode);
@@ -1583,17 +1580,17 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid, goto out_i;/* If nothing has changed, this is a no-op */ -if ((fdq->d_fieldmask &FS_DQ_BSOFT ) && - ((fdq->d_blk_softlimit >> sdp->sd_fsb2bb_shift) ==be64_to_cpu (qd->qd_qb.qb_warn))) - fdq->d_fieldmask ^=FS_DQ_BSOFT ; +if ((fdq->d_fieldmask &QC_SPC_SOFT ) && + ((fdq->d_spc_softlimit >> sdp->sd_sb.sb_bsize_shift) ==be64_to_cpu (qd->qd_qb.qb_warn))) + fdq->d_fieldmask ^=QC_SPC_SOFT ; -if ((fdq->d_fieldmask &FS_DQ_BHARD ) && - ((fdq->d_blk_hardlimit >> sdp->sd_fsb2bb_shift) ==be64_to_cpu (qd->qd_qb.qb_limit))) - fdq->d_fieldmask ^=FS_DQ_BHARD ; +if ((fdq->d_fieldmask &QC_SPC_HARD ) && + ((fdq->d_spc_hardlimit >> sdp->sd_sb.sb_bsize_shift) ==be64_to_cpu (qd->qd_qb.qb_limit))) + fdq->d_fieldmask ^=QC_SPC_HARD ; -if ((fdq->d_fieldmask &FS_DQ_BCOUNT ) && - ((fdq->d_bcount >> sdp->sd_fsb2bb_shift) ==be64_to_cpu (qd->qd_qb.qb_value))) - fdq->d_fieldmask ^=FS_DQ_BCOUNT ; +if ((fdq->d_fieldmask &QC_SPACE ) && + ((fdq->d_space >> sdp->sd_sb.sb_bsize_shift) ==be64_to_cpu (qd->qd_qb.qb_value))) + fdq->d_fieldmask ^=QC_SPACE ;if (fdq->d_fieldmask ==0 ) goto out_i;
fs/quota/dquot.c +39 -44
160 lines not on this page · raw message
fs/quota/quota.c +120 -25
211 lines not on this page · raw message
fs/xfs/libxfs/xfs_fs.h +0 -14
@@ -559,18 +559,4 @@ typedef struct xfs_swapext/* XFS_IOC_GETFSUUID ---------- deprecated 140 */ -#ifndef HAVE_BBMACROS -/* -* Block I/O parameterization. A basic block (BB) is the lowest size of -* filesystem allocation, and must equal 512. Length units given to bio -* routines are in BB's. -*/ -#define BBSHIFT 9 -#define BBSIZE (1<<BBSHIFT) -#define BBMASK (BBSIZE-1) -#define BTOBB (bytes) (((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT) -#define BTOBBT (bytes) ((__u64)(bytes) >> BBSHIFT) -#define BBTOB (bbs) ((bbs) << BBSHIFT) -#endif -#endif /* __XFS_FS_H__ */
fs/xfs/xfs_qm.h +2 -2
@@ -165,9 +165,9 @@ extern void xfs_qm_dqrele_all_inodes(struct xfs_mount *, uint);/* quota ops */ extern int xfs_qm_scall_trunc_qfiles (struct xfs_mount *,uint );extern int xfs_qm_scall_getquota (struct xfs_mount *,xfs_dqid_t , -uint ,struct fs_disk_quota *); +uint ,struct qc_dqblk *);extern int xfs_qm_scall_setqlim (struct xfs_mount *,xfs_dqid_t ,uint , -struct fs_disk_quota *); +struct qc_dqblk *);extern int xfs_qm_scall_getqstat (struct xfs_mount *,struct fs_quota_stat *); extern int xfs_qm_scall_getqstatv(struct xfs_mount *,
fs/xfs/xfs_qm_syscalls.c +66 -90
249 lines not on this page · raw message
fs/xfs/xfs_quotaops.c +4 -4
@@ -144,7 +144,7 @@ STATIC intxfs_fs_get_dqblk ( struct super_block *sb, struct kqid qid, - struct fs_disk_quota *fdq) + struct qc_dqblk *qdq) { struct xfs_mount *mp = XFS_M(sb);
@@ -154,14 +154,14 @@ xfs_fs_get_dqblk(return -ESRCH ;return xfs_qm_scall_getquota (mp,from_kqid (&init_user_ns, qid), -xfs_quota_type (qid.type), fdq); +xfs_quota_type (qid.type), qdq); } STATIC intxfs_fs_set_dqblk (struct super_block *sb,struct kqid qid, -struct fs_disk_quota *fdq) +struct qc_dqblk *qdq) {struct xfs_mount *mp =XFS_M (sb);
@@ -173,7 +173,7 @@ xfs_fs_set_dqblk(return -ESRCH ;return xfs_qm_scall_setqlim (mp,from_kqid (&init_user_ns, qid), -xfs_quota_type (qid.type), fdq); +xfs_quota_type (qid.type), qdq); }const struct quotactl_ops xfs_quotactl_operations = {
include/linux/quota.h +45 -2
59 lines not on this page · raw message
include/linux/quotaops.h +2 -2
@@ -100,9 +100,9 @@ int dquot_quota_sync(struct super_block *sb, int type);int dquot_get_dqinfo (struct super_block *sb,int type,struct if_dqinfo *ii);int dquot_set_dqinfo (struct super_block *sb,int type,struct if_dqinfo *ii);int dquot_get_dqblk (struct super_block *sb,struct kqid id, -struct fs_disk_quota *di); +struct qc_dqblk *di);int dquot_set_dqblk (struct super_block *sb,struct kqid id, -struct fs_disk_quota *di); +struct qc_dqblk *di);int __dquot_transfer (struct inode *inode,struct dquot **transfer_to);int dquot_transfer (struct inode *inode,struct iattr *iattr);
include/uapi/linux/dqblk_xfs.h +12 -0
@@ -120,6 +120,18 @@ typedef struct fs_disk_quota {#define FS_DQ_ACCT_MASK (FS_DQ_BCOUNT | FS_DQ_ICOUNT | FS_DQ_RTBCOUNT)/* +* Block I/O parameterization. A basic block (BB) is the lowest size of +* filesystem allocation, and must equal 512. Length units given to bio +* routines are in BB's. Also quota information is reported in basic blocks. +*/ +#define BBSHIFT 9 +#define BBSIZE (1<<BBSHIFT) +#define BBMASK (BBSIZE-1) +#define BTOBB (bytes) (((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT) +#define BTOBBT (bytes) ((__u64)(bytes) >> BBSHIFT) +#define BBTOB (bbs) ((bbs) << BBSHIFT) + +/* * Various flags related to quotactl(2). */ #define FS_QUOTA_UDQ_ACCT (1<<0)/* user quota accounting */
Signature · 1 line
2.1.2
Re: [PATCH 07/17] quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units
Quoted 11 lines
fs/xfs/libxfs/xfs_fs.h +0
-3@@ -559,18 +559,4 @@ typedef struct xfs_swapext/* XFS_IOC_GETFSUUID ---------- deprecated 140 */ -#ifndef HAVE_BBMACROS -/* -* Block I/O parameterization. A basic block (BB) is the lowest size of
fs/xfs/libxfs/xfs_fs.h typedef struct xfs_swapext · line 574
Quoted 10 lines
fs/xfs/libxfs/xfs_fs.h +0
-10-* filesystem allocation, and must equal 512. Length units given to bio -* routines are in BB's. -*/ -#define BBSHIFT 9 -#define BBSIZE (1<<BBSHIFT) -#define BBMASK (BBSIZE-1) -#define BTOBB (bytes) (((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT) -#define BTOBBT (bytes) ((__u64)(bytes) >> BBSHIFT) -#define BBTOB (bbs) ((bbs) << BBSHIFT) -#endif
Please don't move these defintions around and just opencode them in the quota code.
Otherwise looks good:
Jan Kara
reviewerRe: [PATCH 07/17] quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units
Quoted 8 lines · Christoph Hellwig
Quoted 8 lines
fs/xfs/libxfs/xfs_fs.h +0
-0@@ -559,18 +559,4 @@ typedef struct xfs_swapext/* XFS_IOC_GETFSUUID ---------- deprecated 140 */
Quoted 16 lines
fs/xfs/libxfs/xfs_fs.h typedef struct xfs_swapext · line 574
Quoted 13 lines
fs/xfs/libxfs/xfs_fs.h +0
-13-#ifndef HAVE_BBMACROS -/* -* Block I/O parameterization. A basic block (BB) is the lowest size of -* filesystem allocation, and must equal 512. Length units given to bio -* routines are in BB's. -*/ -#define BBSHIFT 9 -#define BBSIZE (1<<BBSHIFT) -#define BBMASK (BBSIZE-1) -#define BTOBB (bytes) (((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT) -#define BTOBBT (bytes) ((__u64)(bytes) >> BBSHIFT) -#define BBTOB (bbs) ((bbs) << BBSHIFT) -#endif Please don't move these defintions around and just opencode them in the quota code.
I have moved the definitions because Dave asked me to use them in the XFS
parts of quota code (maybe he didn't realize that to be able to use them I have to move the definitions somewhere where quota code can include them). Dave? I personally don't care which variant will get used...
Quoted 3 lines
Otherwise looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Thanks.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerPATCH v3 8/17 quota: Store maximum space limit in bytes
In reply to Jan KaraCurrently maximum space limit quota format supports is in blocks however since we store space limits in bytes, this is somewhat confusing. So store the maximum limit in bytes as well. Also rename the field to match the new unit and related inode field to match the new naming scheme.
--- fs/ocfs2/quota_local.c | 4 ++-- fs/quota/dquot.c | 18 ++++-------------- fs/quota/quota_v1.c | 4 ++-- fs/quota/quota_v2.c | 10 +++++----- include/linux/quota.h | 4 ++-- 5 files changed, 15 insertions(+), 25 deletions(-)
fs/ocfs2/quota_local.c +2 -2
@@ -701,8 +701,8 @@ static int ocfs2_local_read_info(struct super_block *sb, int type)/* We don't need the lock and we have to acquire quota file locks * which will later depend on this lock */ mutex_unlock (&sb_dqopt (sb)->dqio_mutex); - info->dqi_maxblimit =0x7fffffffffffffffLL ; - info->dqi_maxilimit =0x7fffffffffffffffLL ; + info->dqi_max_spc_limit =0x7fffffffffffffffLL ; + info->dqi_max_ino_limit =0x7fffffffffffffffLL ; oinfo =kmalloc (sizeof (struct ocfs2_mem_dqinfo ),GFP_NOFS );if (!oinfo) { mlog(ML_ERROR, "failed to allocate memory for ocfs2 quota"
fs/quota/dquot.c +4 -14
@@ -2467,16 +2467,6 @@ out_err: }EXPORT_SYMBOL (dquot_quota_disable); -static inline qsize_t qbtos (qsize_t blocks) -{ -return blocks <<QIF_DQBLKSIZE_BITS ; -} - -static inline qsize_t stoqb (qsize_t space) -{ -return (space +QIF_DQBLKSIZE -1 ) >>QIF_DQBLKSIZE_BITS ; -} -/* Generic routine for getting common part of quota structure */ static void do_get_dqblk (struct dquot *dquot,struct qc_dqblk *di) {
@@ -2526,13 +2516,13 @@ static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)return -EINVAL ;if (((di->d_fieldmask &QC_SPC_SOFT ) && -stoqb (di->d_spc_softlimit) > dqi->dqi_maxblimit) || + di->d_spc_softlimit > dqi->dqi_max_spc_limit) || ((di->d_fieldmask &QC_SPC_HARD ) && -stoqb (di->d_spc_hardlimit) > dqi->dqi_maxblimit) || + di->d_spc_hardlimit > dqi->dqi_max_spc_limit) || ((di->d_fieldmask &QC_INO_SOFT ) && - (di->d_ino_softlimit > dqi->dqi_maxilimit)) || + (di->d_ino_softlimit > dqi->dqi_max_ino_limit)) || ((di->d_fieldmask &QC_INO_HARD ) && - (di->d_ino_hardlimit > dqi->dqi_maxilimit))) + (di->d_ino_hardlimit > dqi->dqi_max_ino_limit)))return -ERANGE ;spin_lock (&dq_data_lock);
fs/quota/quota_v1.c +2 -2
@@ -169,8 +169,8 @@ static int v1_read_file_info(struct super_block *sb, int type) } ret =0 ;/* limits are stored as unsigned 32-bit data */ - dqopt->info[type].dqi_maxblimit =0xffffffff ; - dqopt->info[type].dqi_maxilimit =0xffffffff ; + dqopt->info[type].dqi_max_spc_limit =0xffffffffULL <<QUOTABLOCK_BITS ; + dqopt->info[type].dqi_max_ino_limit =0xffffffff ; dqopt->info[type].dqi_igrace = dqblk.dqb_itime ? dqblk.dqb_itime :MAX_IQ_TIME ; dqopt->info[type].dqi_bgrace =
fs/quota/quota_v2.c +5 -5
@@ -117,12 +117,12 @@ static int v2_read_file_info(struct super_block *sb, int type) qinfo = info->dqi_priv;if (version ==0 ) {/* limits are stored as unsigned 32-bit data */ - info->dqi_maxblimit =0xffffffff ; - info->dqi_maxilimit =0xffffffff ; + info->dqi_max_spc_limit =0xffffffffULL <<QUOTABLOCK_BITS ; + info->dqi_max_ino_limit =0xffffffff ; }else { -/* used space is stored as unsigned 64-bit value */ - info->dqi_maxblimit =0xffffffffffffffffULL ;/* 2^64-1 */ - info->dqi_maxilimit =0xffffffffffffffffULL ; +/* used space is stored as unsigned 64-bit value in bytes */ + info->dqi_max_spc_limit =0xffffffffffffffffULL ;/* 2^64-1 */ + info->dqi_max_ino_limit =0xffffffffffffffffULL ; } info->dqi_bgrace =le32_to_cpu (dinfo.dqi_bgrace); info->dqi_igrace =le32_to_cpu (dinfo.dqi_igrace);
include/linux/quota.h +2 -2
@@ -216,8 +216,8 @@ struct mem_dqinfo {unsigned long dqi_flags;unsigned int dqi_bgrace;unsigned int dqi_igrace; -qsize_t dqi_maxblimit; -qsize_t dqi_maxilimit; +qsize_t dqi_max_spc_limit; +qsize_t dqi_max_ino_limit;void *dqi_priv; };
Signature · 1 line
2.1.2
Re: [PATCH 08/17] quota: Store maximum space limit in bytes
Looks good,
Jan Kara
reviewerPATCH v3 9/17 quota: Make Q_XQUOTASYNC support VFS quota syncing
In reply to Jan KaraCall ->quota_sync method from Q_XQUOTASYNC for better userspace compatibility.
--- fs/quota/quota.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/quota/quota.c +3 -2
@@ -477,8 +477,9 @@ static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,case Q_XQUOTASYNC :if (sb->s_flags &MS_RDONLY )return -EROFS ; -/* XFS quotas are fully coherent now, making this call a noop */ -return 0 ; +if (!sb->s_qcop->quota_sync) +return 0 ; +return sb->s_qcop->quota_sync (sb, type);default :return -EINVAL ; }
Signature · 1 line
2.1.2
Re: [PATCH 09/17] quota: Make Q_XQUOTASYNC support VFS quota syncing
Quoted 2 lines · Jan Kara
Call ->quota_sync method from
Q_XQUOTASYNCfor better userspace compatibility.
Q_XQUOTASYNC never did the equivalent to ->quota_sync, but rather was the equivalent to sys_syncfs which also happens to write out quotas.
Unless you have a really strong reason for wiring it up, I'd rather keep it as-is.
Jan Kara
reviewerRe: [PATCH 09/17] quota: Make Q_XQUOTASYNC support VFS quota syncing
Quoted 9 lines · Christoph Hellwig
Quoted 2 lines · Jan Kara
Call ->quota_sync method from
Q_XQUOTASYNCfor better userspace compatibility.
Q_XQUOTASYNCnever did the equivalent to ->quota_sync, but rather was the equivalent tosys_syncfswhich also happens to write out quotas.Unless you have a really strong reason for wiring it up, I'd rather keep it as-is.
OK, patch dropped.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerPATCH v3 10/17 quota: Make VFS quotas use new interface for getting quota info
In reply to Jan KaraCreate new internal interface for getting information about quota which contains everything needed for both VFS quotas and XFS quotas. Make VFS use this and hook it up to Q_GETINFO.
--- fs/ext3/super.c | 2 +- fs/ext4/super.c | 2 +- fs/quota/dquot.c | 41 +++++++++++++++++++++++++++-------------- fs/quota/quota.c | 25 +++++++++++++++++++++---- fs/reiserfs/super.c | 2 +- include/linux/quota.h | 33 ++++++++++++++++++++++++++++++++- include/linux/quotaops.h | 2 +- 7 files changed, 84 insertions(+), 23 deletions(-)
fs/ext3/super.c +1 -1
@@ -787,7 +787,7 @@ static const struct quotactl_ops ext3_qctl_operations = { .quota_on = ext3_quota_on, .quota_off = dquot_quota_off, .quota_sync = dquot_quota_sync, - .get_info = dquot_get_dqinfo, + .get_state = dquot_get_state, .set_info = dquot_set_dqinfo, .get_dqblk = dquot_get_dqblk, .set_dqblk = dquot_set_dqblk
fs/ext4/super.c +1 -1
@@ -1076,7 +1076,7 @@ static const struct quotactl_ops ext4_qctl_operations = { .quota_on = ext4_quota_on, .quota_off = ext4_quota_off, .quota_sync = dquot_quota_sync, - .get_info = dquot_get_dqinfo, + .get_state = dquot_get_state, .set_info = dquot_set_dqinfo, .get_dqblk = dquot_get_dqblk, .set_dqblk = dquot_set_dqblk
fs/quota/dquot.c +27 -14
67 lines not on this page · raw message
fs/quota/quota.c +21 -4
@@ -118,13 +118,30 @@ static int quota_getfmt(struct super_block *sb, int type, void __user *addr)static int quota_getinfo (struct super_block *sb,int type,void __user *addr) { -struct if_dqinfo info; +struct qc_state state; +struct qc_type_state *tstate; +struct if_dqinfo uinfo;int ret; -if (!sb->s_qcop->get_info) +/* This checks whether qc_state has enough entries... */ +BUILD_BUG_ON (MAXQUOTAS >XQM_MAXQUOTAS ); +if (!sb->s_qcop->get_state)return -ENOSYS ; - ret = sb->s_qcop->get_info (sb, type, &info); -if (!ret &©_to_user (addr, &info,sizeof (info))) + ret = sb->s_qcop->get_state (sb, &state); +if (ret) +return ret; + tstate = state.s_state + type; +if (!(tstate->flags &QCI_ACCT_ENABLED )) +return -ESRCH ; +memset (&uinfo,0 ,sizeof (uinfo)); + uinfo.dqi_bgrace = tstate->spc_timelimit; + uinfo.dqi_igrace = tstate->ino_timelimit; +if (tstate->flags &QCI_SYSFILE ) + uinfo.dqi_flags |=DQF_SYS_FILE ; +if (tstate->flags &QCI_ROOT_SQUASH ) + uinfo.dqi_flags |=DQF_ROOT_SQUASH ; + uinfo.dqi_valid =IIF_ALL ; +if (!ret &©_to_user (addr, &uinfo,sizeof (uinfo)))return -EFAULT ;return ret; }
fs/reiserfs/super.c +1 -1
@@ -805,7 +805,7 @@ static const struct quotactl_ops reiserfs_qctl_operations = { .quota_on = reiserfs_quota_on, .quota_off = dquot_quota_off, .quota_sync = dquot_quota_sync, - .get_info = dquot_get_dqinfo, + .get_state = dquot_get_state, .set_info = dquot_set_dqinfo, .get_dqblk = dquot_get_dqblk, .set_dqblk = dquot_set_dqblk,
include/linux/quota.h +32 -1
@@ -366,6 +366,37 @@ struct qc_dqblk {#define QC_RT_SPACE (1<<14)#define QC_ACCT_MASK (QC_SPACE | QC_INO_COUNT | QC_RT_SPACE) +#define QCI_SYSFILE (1 << 0)/* Quota file is hidden from userspace */ +#define QCI_ROOT_SQUASH (1 << 1)/* Root squash turned on */ +#define QCI_ACCT_ENABLED (1 << 2)/* Quota accounting enabled */ +#define QCI_LIMITS_ENFORCED (1 << 3)/* Quota limits enforced */ + +/* Structures for communicating via ->get_state */ +struct qc_type_state { +unsigned int flags;/* Flags QCI_* */ +unsigned int spc_timelimit;/* Time after which space softlimit is +* enforced */ +unsigned int ino_timelimit;/* Ditto for inode softlimit */ +unsigned int rt_spc_timelimit;/* Ditto for real-time space */ +unsigned int spc_warnlimit;/* Limit for number of space warnings */ +unsigned int ino_warnlimit;/* Ditto for inodes */ +unsigned int rt_spc_warnlimit;/* Ditto for real-time space */ +unsigned long long ino;/* Inode number of quota file */ +blkcnt_t blocks;/* Number of 512-byte blocks in the file */ +blkcnt_t nextents;/* Number of extents in the file */ +}; + +struct qc_state { +unsigned int s_incoredqs;/* Number of dquots in core */ +/* +* Per quota type information. The array should really have +* max(MAXQUOTAS, XQM_MAXQUOTAS) entries. BUILD_BUG_ON in +* quota_getinfo() makes sure XQM_MAXQUOTAS is large enough. Once VFS +* supports project quotas, this can be changed to MAXQUOTAS +*/ +struct qc_type_state s_state[XQM_MAXQUOTAS ]; +}; +/* Operations handling requests from userspace */ struct quotactl_ops {int (*quota_on)(struct super_block *,int ,int ,struct path *);
@@ -373,10 +404,10 @@ struct quotactl_ops {int (*quota_enable)(struct super_block *,unsigned int );int (*quota_disable)(struct super_block *,unsigned int );int (*quota_sync)(struct super_block *,int ); -int (*get_info)(struct super_block *,int ,struct if_dqinfo *);int (*set_info)(struct super_block *,int ,struct if_dqinfo *);int (*get_dqblk)(struct super_block *,struct kqid ,struct qc_dqblk *);int (*set_dqblk)(struct super_block *,struct kqid ,struct qc_dqblk *); +int (*get_state)(struct super_block *,struct qc_state *);int (*get_xstate)(struct super_block *,struct fs_quota_stat *);int (*get_xstatev)(struct super_block *,struct fs_quota_statv *);int (*rm_xquota)(struct super_block *,unsigned int );
include/linux/quotaops.h +1 -1
@@ -97,7 +97,7 @@ int dquot_quota_enable(struct super_block *sb, unsigned int flags);int dquot_quota_disable (struct super_block *sb,unsigned int flags);int dquot_writeback_dquots (struct super_block *sb,int type);int dquot_quota_sync (struct super_block *sb,int type); -int dquot_get_dqinfo (struct super_block *sb,int type,struct if_dqinfo *ii); +int dquot_get_state (struct super_block *sb,struct qc_state *state);int dquot_set_dqinfo (struct super_block *sb,int type,struct if_dqinfo *ii);int dquot_get_dqblk (struct super_block *sb,struct kqid id,struct qc_dqblk *di);
Signature · 1 line
2.1.2
Re: [PATCH 10/17] quota: Make VFS quotas use new interface for getting quota info
Looks good,
Jan Kara
reviewerPATCH v3 11/17 quota: Wire up Q_GETXSTATE and Q_GETXSTATV calls to work with ->get_state
In reply to Jan KaraAdd appropriate conversion functions so that filesystems supporting ->get_state() method can be queried using Q_GETXSTATE and Q_GETXSTATV calls.
--- fs/quota/quota.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 4 deletions(-)
fs/quota/quota.c +134 -4
@@ -269,25 +269,152 @@ static int quota_disable(struct super_block *sb, void __user *addr)return sb->s_qcop->quota_disable (sb, flags); } +static int quota_state_to_flags (struct qc_state *state) +{ +int flags =0 ; + +if (state->s_state[USRQUOTA ].flags &QCI_ACCT_ENABLED ) + flags |=FS_QUOTA_UDQ_ACCT ; +if (state->s_state[USRQUOTA ].flags &QCI_LIMITS_ENFORCED ) + flags |=FS_QUOTA_UDQ_ENFD ; +if (state->s_state[GRPQUOTA ].flags &QCI_ACCT_ENABLED ) + flags |=FS_QUOTA_GDQ_ACCT ; +if (state->s_state[GRPQUOTA ].flags &QCI_LIMITS_ENFORCED ) + flags |=FS_QUOTA_GDQ_ENFD ; +if (state->s_state[PRJQUOTA ].flags &QCI_ACCT_ENABLED ) + flags |=FS_QUOTA_PDQ_ACCT ; +if (state->s_state[PRJQUOTA ].flags &QCI_LIMITS_ENFORCED ) + flags |=FS_QUOTA_PDQ_ENFD ; +return flags; +} + +static int quota_getstate (struct super_block *sb,struct fs_quota_stat *fqs) +{ +int type; +struct qc_state state; +int ret; + + ret = sb->s_qcop->get_state (sb, &state); +if (ret <0 ) +return ret; + +memset (fqs,0 ,sizeof (*fqs)); + fqs->qs_version =FS_QSTAT_VERSION ; + fqs->qs_flags =quota_state_to_flags (&state); +/* No quota enabled? */ +if (!fqs->qs_flags) +return -ENOSYS ; + fqs->qs_incoredqs = state.s_incoredqs; +/* +* GETXSTATE quotactl has space for just one set of time limits so +* report them for the first enabled quota type +*/ +for (type =0 ; type <XQM_MAXQUOTAS ; type++) +if (state.s_state[type].flags &QCI_ACCT_ENABLED ) +break ; +BUG_ON (type ==XQM_MAXQUOTAS ); + fqs->qs_btimelimit = state.s_state[type].spc_timelimit; + fqs->qs_itimelimit = state.s_state[type].ino_timelimit; + fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit; + fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit; + fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit; +if (state.s_state[USRQUOTA ].flags &QCI_ACCT_ENABLED ) { + fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA ].ino; + fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA ].blocks; + fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA ].nextents; + } +if (state.s_state[GRPQUOTA ].flags &QCI_ACCT_ENABLED ) { + fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA ].ino; + fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA ].blocks; + fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA ].nextents; + } +if (state.s_state[PRJQUOTA ].flags &QCI_ACCT_ENABLED ) { +/* +* Q_XGETQSTAT doesn't have room for both group and project +* quotas. So, allow the project quota values to be copied out +* only if there is no group quota information available. +*/ +if (!(state.s_state[GRPQUOTA ].flags &QCI_ACCT_ENABLED )) { + fqs->qs_gquota.qfs_ino = state.s_state[PRJQUOTA ].ino; + fqs->qs_gquota.qfs_nblks = + state.s_state[PRJQUOTA ].blocks; + fqs->qs_gquota.qfs_nextents = + state.s_state[PRJQUOTA ].nextents; + } + } +return 0 ; +} +static int quota_getxstate (struct super_block *sb,void __user *addr) {struct fs_quota_stat fqs;int ret; -if (!sb->s_qcop->get_xstate) +if (!sb->s_qcop->get_xstate && !sb->s_qcop->get_state)return -ENOSYS ; - ret = sb->s_qcop->get_xstate (sb, &fqs); +if (sb->s_qcop->get_state) + ret =quota_getstate (sb, &fqs); +else + ret = sb->s_qcop->get_xstate (sb, &fqs);if (!ret &©_to_user (addr, &fqs,sizeof (fqs)))return -EFAULT ;return ret; } +static int quota_getstatev (struct super_block *sb,struct fs_quota_statv *fqs) +{ +int type; +struct qc_state state; +int ret; + + ret = sb->s_qcop->get_state (sb, &state); +if (ret <0 ) +return ret; + +memset (fqs,0 ,sizeof (*fqs)); + fqs->qs_version =FS_QSTAT_VERSION ; + fqs->qs_flags =quota_state_to_flags (&state); +/* No quota enabled? */ +if (!fqs->qs_flags) +return -ENOSYS ; + fqs->qs_incoredqs = state.s_incoredqs; +/* +* GETXSTATV quotactl has space for just one set of time limits so +* report them for the first enabled quota type +*/ +for (type =0 ; type <XQM_MAXQUOTAS ; type++) +if (state.s_state[type].flags &QCI_ACCT_ENABLED ) +break ; +BUG_ON (type ==XQM_MAXQUOTAS ); + fqs->qs_btimelimit = state.s_state[type].spc_timelimit; + fqs->qs_itimelimit = state.s_state[type].ino_timelimit; + fqs->qs_rtbtimelimit = state.s_state[type].rt_spc_timelimit; + fqs->qs_bwarnlimit = state.s_state[type].spc_warnlimit; + fqs->qs_iwarnlimit = state.s_state[type].ino_warnlimit; +if (state.s_state[USRQUOTA ].flags &QCI_ACCT_ENABLED ) { + fqs->qs_uquota.qfs_ino = state.s_state[USRQUOTA ].ino; + fqs->qs_uquota.qfs_nblks = state.s_state[USRQUOTA ].blocks; + fqs->qs_uquota.qfs_nextents = state.s_state[USRQUOTA ].nextents; + } +if (state.s_state[GRPQUOTA ].flags &QCI_ACCT_ENABLED ) { + fqs->qs_gquota.qfs_ino = state.s_state[GRPQUOTA ].ino; + fqs->qs_gquota.qfs_nblks = state.s_state[GRPQUOTA ].blocks; + fqs->qs_gquota.qfs_nextents = state.s_state[GRPQUOTA ].nextents; + } +if (state.s_state[PRJQUOTA ].flags &QCI_ACCT_ENABLED ) { + fqs->qs_pquota.qfs_ino = state.s_state[PRJQUOTA ].ino; + fqs->qs_pquota.qfs_nblks = state.s_state[PRJQUOTA ].blocks; + fqs->qs_pquota.qfs_nextents = state.s_state[PRJQUOTA ].nextents; + } +return 0 ; +} +static int quota_getxstatev (struct super_block *sb,void __user *addr) {struct fs_quota_statv fqs;int ret; -if (!sb->s_qcop->get_xstatev) +if (!sb->s_qcop->get_xstatev && !sb->s_qcop->get_state)return -ENOSYS ;memset (&fqs,0 ,sizeof (fqs));
@@ -301,7 +428,10 @@ static int quota_getxstatev(struct super_block *sb, void __user *addr)default :return -EINVAL ; } - ret = sb->s_qcop->get_xstatev (sb, &fqs); +if (sb->s_qcop->get_state) + ret =quota_getstatev (sb, &fqs); +else + ret = sb->s_qcop->get_xstatev (sb, &fqs);if (!ret &©_to_user (addr, &fqs,sizeof (fqs)))return -EFAULT ;return ret;
Signature · 1 line
2.1.2
Re: [PATCH 11/17] quota: Wire up Q_GETXSTATE and Q_GETXSTATV calls to work with ->get_state
Looks good,
Christoph Hellwig <[email protected]>
Jan Kara
reviewerPATCH v3 12/17 xfs: Convert to using ->get_state callback
In reply to Jan KaraConvert xfs to use ->get_state callback instead of ->get_xstate and ->get_xstatev.
--- fs/xfs/xfs_qm.h | 6 +- fs/xfs/xfs_qm_syscalls.c | 219 ++++++++++++----------------------------------- fs/xfs/xfs_quotaops.c | 26 +----- 3 files changed, 58 insertions(+), 193 deletions(-)
fs/xfs/xfs_qm.h +2 -4
@@ -168,10 +168,8 @@ extern int xfs_qm_scall_getquota(struct xfs_mount *, xfs_dqid_t, uint, struct qc_dqblk *);extern int xfs_qm_scall_setqlim (struct xfs_mount *,xfs_dqid_t ,uint ,struct qc_dqblk *); -extern int xfs_qm_scall_getqstat (struct xfs_mount *, -struct fs_quota_stat *); -extern int xfs_qm_scall_getqstatv (struct xfs_mount *, -struct fs_quota_statv *); +extern int xfs_qm_scall_getstate (struct xfs_mount *, +struct qc_state *);extern int xfs_qm_scall_quotaon (struct xfs_mount *,uint );extern int xfs_qm_scall_quotaoff (struct xfs_mount *,uint );
fs/xfs/xfs_qm_syscalls.c +53 -166
244 lines not on this page · raw message
fs/xfs/xfs_quotaops.c +3 -23
@@ -40,28 +40,9 @@ xfs_quota_type(int type) } } -STATIC int -xfs_fs_get_xstate ( -struct super_block *sb, -struct fs_quota_stat *fqs) +static int xfs_fs_get_quota_state (struct super_block *sb,struct qc_state *s) { -struct xfs_mount *mp =XFS_M (sb); - -if (!XFS_IS_QUOTA_RUNNING (mp)) -return -ENOSYS ; -return xfs_qm_scall_getqstat (mp, fqs); -} - -STATIC int -xfs_fs_get_xstatev ( -struct super_block *sb, -struct fs_quota_statv *fqs) -{ -struct xfs_mount *mp =XFS_M (sb); - -if (!XFS_IS_QUOTA_RUNNING (mp)) -return -ENOSYS ; -return xfs_qm_scall_getqstatv (mp, fqs); +return xfs_qm_scall_getstate (XFS_M (sb), s); }static unsigned int xfs_quota_flags (unsigned int uflags)
@@ -177,8 +158,7 @@ xfs_fs_set_dqblk( }const struct quotactl_ops xfs_quotactl_operations = { - .get_xstatev = xfs_fs_get_xstatev, - .get_xstate = xfs_fs_get_xstate, + .get_state = xfs_fs_get_quota_state, .quota_enable = xfs_quota_enable, .quota_disable = xfs_quota_disable, .rm_xquota = xfs_fs_rm_xquota,
Signature · 1 line
2.1.2
Re: [PATCH 12/17] xfs: Convert to using ->get_state callback
Quoted 1 line
+static void xfs_qm_fill_state(struct
qc_type_state*tstate,
Normal xfs style would be to keep the "static void " on a separate line, as well as the arguments, e.g.
static void
xfs_qm_fill_state(
struct qc_type_state *tstate,
fs/xfs/xfs_qm_syscalls.c xfs_qm_scall_quotaon( · line 394
Quoted 4 lines
fs/xfs/xfs_qm_syscalls.c +3
-0+struct xfs_mount *mp, + struct xfs_inode *ip, + xfs_ino_t ino)
No need to pass mp, as it can be derived as ip->i_mount.
Btw, I think this code should move into xfs_quotaops.c now that it ties into the Linux quota interface, and xfs_qm_scall_getstate should be folded into xfs_fs_get_quota_state.
Jan Kara
reviewerRe: [PATCH 12/17] xfs: Convert to using ->get_state callback
Quoted 4 lines · Christoph Hellwig
Quoted 1 line
+static void xfs_qm_fill_state(struct
qc_type_state*tstate,Normal xfs style would be to keep the "static void " on a separate line, as well as the arguments, e.g.
OK, will change it to conform to the XFS coding style.
Quoted 10 lines
static void
xfs_qm_fill_state(
structqc_type_state*tstate,fs/xfs/xfs_qm_syscalls.c xfs_qm_scall_quotaon( · line 394
Quoted 4 lines
fs/xfs/xfs_qm_syscalls.c +3
-0+struct xfs_mount *mp, + struct xfs_inode *ip, + xfs_ino_t ino)No need to pass mp, as it can be derived as
ip->i_mount.
Good point.
Quoted 3 lines
Btw, I think this code should move into
xfs_quotaops.cnow that it ties into the Linux quota interface, andxfs_qm_scall_getstateshould be folded intoxfs_fs_get_quota_state.
OK, will do.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerPATCH v3 13/17 gfs2: Convert to using ->get_state callback
In reply to Jan KaraConvert gfs2 to use ->get_state callback instead of ->get_xstate.
--- fs/gfs2/quota.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
fs/gfs2/quota.c +15 -13
@@ -1467,32 +1467,34 @@ int gfs2_quotad(void *data)return 0 ; } -static int gfs2_quota_get_xstate (struct super_block *sb, -struct fs_quota_stat *fqs) +static int gfs2_quota_get_state (struct super_block *sb,struct qc_state *state) {struct gfs2_sbd *sdp = sb->s_fs_info; -memset (fqs,0 ,sizeof (struct fs_quota_stat )); - fqs->qs_version =FS_QSTAT_VERSION ; +memset (state,0 ,sizeof (*state));switch (sdp->sd_args.ar_quota) {case GFS2_QUOTA_ON : - fqs->qs_flags |= (FS_QUOTA_UDQ_ENFD |FS_QUOTA_GDQ_ENFD ); + state->s_state[USRQUOTA ].flags |=QCI_LIMITS_ENFORCED ; + state->s_state[GRPQUOTA ].flags |=QCI_LIMITS_ENFORCED ;/*FALLTHRU*/ case GFS2_QUOTA_ACCOUNT : - fqs->qs_flags |= (FS_QUOTA_UDQ_ACCT |FS_QUOTA_GDQ_ACCT ); + state->s_state[USRQUOTA ].flags |=QCI_ACCT_ENABLED | +QCI_SYSFILE ; + state->s_state[GRPQUOTA ].flags |=QCI_ACCT_ENABLED | +QCI_SYSFILE ;break ;case GFS2_QUOTA_OFF :break ; } -if (sdp->sd_quota_inode) { - fqs->qs_uquota.qfs_ino =GFS2_I (sdp->sd_quota_inode)->i_no_addr; - fqs->qs_uquota.qfs_nblks = sdp->sd_quota_inode->i_blocks; + state->s_state[USRQUOTA ].ino = +GFS2_I (sdp->sd_quota_inode)->i_no_addr; + state->s_state[USRQUOTA ].blocks = sdp->sd_quota_inode->i_blocks; } - fqs->qs_uquota.qfs_nextents =1 ;/* unsupported */ - fqs->qs_gquota = fqs->qs_uquota;/* its the same inode in both cases */ - fqs->qs_incoredqs =list_lru_count (&gfs2_qd_lru); + state->s_state[USRQUOTA ].extents =1 ;/* unsupported */ + state->s_state[GRPQUOTA ] = state->s_state[USRQUOTA ]; + state->s_incoredqs =list_lru_count (&gfs2_qd_lru);return 0 ; }
@@ -1637,7 +1639,7 @@ out_put:const struct quotactl_ops gfs2_quotactl_ops = { .quota_sync = gfs2_quota_sync, - .get_xstate = gfs2_quota_get_xstate, + .get_state = gfs2_quota_get_state, .get_dqblk = gfs2_get_dqblk, .set_dqblk = gfs2_set_dqblk, };
Signature · 1 line
2.1.2
Jan Kara
reviewerPATCH v3 14/17 quota: Remove ->get_xstate and ->get_xstatev callbacks
In reply to Jan KaraThese callbacks are now unused. Remove them.
--- fs/quota/quota.c | 14 ++++---------- include/linux/quota.h | 2 -- 2 files changed, 4 insertions(+), 12 deletions(-)
fs/quota/quota.c +4 -10
@@ -350,12 +350,9 @@ static int quota_getxstate(struct super_block *sb, void __user *addr)struct fs_quota_stat fqs;int ret; -if (!sb->s_qcop->get_xstate && !sb->s_qcop->get_state) +if (!sb->s_qcop->get_state)return -ENOSYS ; -if (sb->s_qcop->get_state) - ret =quota_getstate (sb, &fqs); -else - ret = sb->s_qcop->get_xstate (sb, &fqs); + ret =quota_getstate (sb, &fqs);if (!ret &©_to_user (addr, &fqs,sizeof (fqs)))return -EFAULT ;return ret;
@@ -414,7 +411,7 @@ static int quota_getxstatev(struct super_block *sb, void __user *addr)struct fs_quota_statv fqs;int ret; -if (!sb->s_qcop->get_xstatev && !sb->s_qcop->get_state) +if (!sb->s_qcop->get_state)return -ENOSYS ;memset (&fqs,0 ,sizeof (fqs));
@@ -428,10 +425,7 @@ static int quota_getxstatev(struct super_block *sb, void __user *addr)default :return -EINVAL ; } -if (sb->s_qcop->get_state) - ret =quota_getstatev (sb, &fqs); -else - ret = sb->s_qcop->get_xstatev (sb, &fqs); + ret =quota_getstatev (sb, &fqs);if (!ret &©_to_user (addr, &fqs,sizeof (fqs)))return -EFAULT ;return ret;
include/linux/quota.h +0 -2
@@ -408,8 +408,6 @@ struct quotactl_ops {int (*get_dqblk)(struct super_block *,struct kqid ,struct qc_dqblk *);int (*set_dqblk)(struct super_block *,struct kqid ,struct qc_dqblk *);int (*get_state)(struct super_block *,struct qc_state *); -int (*get_xstate)(struct super_block *,struct fs_quota_stat *); -int (*get_xstatev)(struct super_block *,struct fs_quota_statv *);int (*rm_xquota)(struct super_block *,unsigned int ); };
Signature · 1 line
2.1.2
Re: [PATCH 14/17] quota: Remove ->get_xstate and ->get_xstatev callbacks
Looks good,
Jan Kara
reviewerPATCH v3 15/17 quota: Make ->set_info use structure with neccesary info to VFS and XFS
In reply to Jan KaraChange ->set_info to take new qc_info structure which contains all the necessary information both for XFS and VFS. Convert Q_SETINFO handler to use this structure.
--- fs/quota/dquot.c | 27 ++++++++++++++++----------- fs/quota/quota.c | 21 ++++++++++++++++++++- include/linux/quota.h | 21 +++++++++++++++++++-- include/linux/quotaops.h | 2 +- 4 files changed, 56 insertions(+), 15 deletions(-)
fs/quota/dquot.c +16 -11
@@ -2651,33 +2651,38 @@ int dquot_get_state(struct super_block *sb, struct qc_state *state)EXPORT_SYMBOL (dquot_get_state);/* Generic routine for setting common part of quota file information */ -int dquot_set_dqinfo (struct super_block *sb,int type,struct if_dqinfo *ii) +int dquot_set_dqinfo (struct super_block *sb,int type,struct qc_info *ii) {struct mem_dqinfo *mi;int err =0 ; +if ((ii->i_fieldmask &QC_WARNS_MASK ) || + (ii->i_fieldmask &QC_RT_SPC_TIMER )) +return -EINVAL ;mutex_lock (&sb_dqopt (sb)->dqonoff_mutex);if (!sb_has_quota_active (sb, type)) { err = -ESRCH ; goto out; } mi =sb_dqopt (sb)->info + type; -if (ii->dqi_valid &IIF_FLAGS ) { -if (ii->dqi_flags & ~DQF_SETINFO_MASK || - (ii->dqi_flags &DQF_ROOT_SQUASH && +if (ii->i_fieldmask &QC_FLAGS ) { +if ((ii->i_flags &QCI_ROOT_SQUASH && mi->dqi_format->qf_fmt_id !=QFMT_VFS_OLD )) { err = -EINVAL ; goto out; } }spin_lock (&dq_data_lock); -if (ii->dqi_valid &IIF_BGRACE ) - mi->dqi_bgrace = ii->dqi_bgrace; -if (ii->dqi_valid &IIF_IGRACE ) - mi->dqi_igrace = ii->dqi_igrace; -if (ii->dqi_valid &IIF_FLAGS ) - mi->dqi_flags = (mi->dqi_flags & ~DQF_SETINFO_MASK ) | - (ii->dqi_flags &DQF_SETINFO_MASK ); +if (ii->i_fieldmask &QC_SPC_TIMER ) + mi->dqi_bgrace = ii->i_spc_timelimit; +if (ii->i_fieldmask &QC_INO_TIMER ) + mi->dqi_igrace = ii->i_ino_timelimit; +if (ii->i_fieldmask &QC_FLAGS ) { +if (ii->i_flags &QCI_ROOT_SQUASH ) + mi->dqi_flags |=DQF_ROOT_SQUASH ; +else + mi->dqi_flags &= ~DQF_ROOT_SQUASH ; + }spin_unlock (&dq_data_lock);mark_info_dirty (sb, type);/* Force write to disk */
fs/quota/quota.c +20 -1
@@ -149,12 +149,31 @@ static int quota_getinfo(struct super_block *sb, int type, void __user *addr)static int quota_setinfo (struct super_block *sb,int type,void __user *addr) {struct if_dqinfo info; +struct qc_info qinfo;if (copy_from_user (&info, addr,sizeof (info)))return -EFAULT ;if (!sb->s_qcop->set_info)return -ENOSYS ; -return sb->s_qcop->set_info (sb, type, &info); +if (info.dqi_valid & ~(IIF_FLAGS |IIF_BGRACE |IIF_IGRACE )) +return -EINVAL ; +memset (&qinfo,0 ,sizeof (qinfo)); +if (info.dqi_valid &IIF_FLAGS ) { +if (info.dqi_flags & ~DQF_SETINFO_MASK ) +return -EINVAL ; +if (info.dqi_flags &DQF_ROOT_SQUASH ) + qinfo.i_flags |=QCI_ROOT_SQUASH ; + qinfo.i_fieldmask |=QC_FLAGS ; + } +if (info.dqi_valid &IIF_BGRACE ) { + qinfo.i_spc_timelimit = info.dqi_bgrace; + qinfo.i_fieldmask |=QC_SPC_TIMER ; + } +if (info.dqi_valid &IIF_IGRACE ) { + qinfo.i_ino_timelimit = info.dqi_igrace; + qinfo.i_fieldmask |=QC_INO_TIMER ; + } +return sb->s_qcop->set_info (sb, type, &qinfo); }static inline qsize_t qbtos (qsize_t blocks)
include/linux/quota.h +19 -2
@@ -344,7 +344,10 @@ struct qc_dqblk {int d_rt_spc_warns;/* # warnings issued wrt RT space */ }; -/* Field specifiers for ->set_dqblk() in struct qc_dqblk */ +/* +* Field specifiers for ->set_dqblk() in struct qc_dqblk and also for +* ->set_info() in struct qc_info +*/ #define QC_INO_SOFT (1<<0)#define QC_INO_HARD (1<<1)#define QC_SPC_SOFT (1<<2)
@@ -365,6 +368,7 @@ struct qc_dqblk {#define QC_INO_COUNT (1<<13)#define QC_RT_SPACE (1<<14)#define QC_ACCT_MASK (QC_SPACE | QC_INO_COUNT | QC_RT_SPACE) +#define QC_FLAGS (1<<15)#define QCI_SYSFILE (1 << 0)/* Quota file is hidden from userspace */ #define QCI_ROOT_SQUASH (1 << 1)/* Root squash turned on */
@@ -397,6 +401,19 @@ struct qc_state {struct qc_type_state s_state[XQM_MAXQUOTAS ]; }; +/* Structure for communicating via ->set_info */ +struct qc_info { +int i_fieldmask;/* mask of fields to change in ->set_info() */ +unsigned int i_flags;/* Flags QCI_* */ +unsigned int i_spc_timelimit;/* Time after which space softlimit is +* enforced */ +unsigned int i_ino_timelimit;/* Ditto for inode softlimit */ +unsigned int i_rt_spc_timelimit;/* Ditto for real-time space */ +unsigned int i_spc_warnlimit;/* Limit for number of space warnings */ +unsigned int i_ino_warnlimit;/* Limit for number of inode warnings */ +unsigned int i_rt_spc_warnlimit;/* Ditto for real-time space */ +}; +/* Operations handling requests from userspace */ struct quotactl_ops {int (*quota_on)(struct super_block *,int ,int ,struct path *);
@@ -404,7 +421,7 @@ struct quotactl_ops {int (*quota_enable)(struct super_block *,unsigned int );int (*quota_disable)(struct super_block *,unsigned int );int (*quota_sync)(struct super_block *,int ); -int (*set_info)(struct super_block *,int ,struct if_dqinfo *); +int (*set_info)(struct super_block *,int ,struct qc_info *);int (*get_dqblk)(struct super_block *,struct kqid ,struct qc_dqblk *);int (*set_dqblk)(struct super_block *,struct kqid ,struct qc_dqblk *);int (*get_state)(struct super_block *,struct qc_state *);
include/linux/quotaops.h +1 -1
@@ -98,7 +98,7 @@ int dquot_quota_disable(struct super_block *sb, unsigned int flags);int dquot_writeback_dquots (struct super_block *sb,int type);int dquot_quota_sync (struct super_block *sb,int type);int dquot_get_state (struct super_block *sb,struct qc_state *state); -int dquot_set_dqinfo (struct super_block *sb,int type,struct if_dqinfo *ii); +int dquot_set_dqinfo (struct super_block *sb,int type,struct qc_info *ii);int dquot_get_dqblk (struct super_block *sb,struct kqid id,struct qc_dqblk *di); int dquot_set_dqblk(struct super_block *sb, struct kqid id,
Signature · 1 line
2.1.2
Jan Kara
reviewerPATCH v3 16/17 xfs: Add support for Q_SETINFO
In reply to Jan KaraAdd support to XFS so that time limits can be set through Q_SETINFO quotactl.
--- fs/xfs/xfs_qm.h | 2 ++ fs/xfs/xfs_qm_syscalls.c | 25 +++++++++++++++++++++++++ fs/xfs/xfs_quotaops.c | 16 ++++++++++++++++ 3 files changed, 43 insertions(+)
fs/xfs/xfs_qm.h +2 -0
@@ -170,6 +170,8 @@ extern int xfs_qm_scall_setqlim(struct xfs_mount *, xfs_dqid_t, uint, struct qc_dqblk *);extern int xfs_qm_scall_getstate (struct xfs_mount *,struct qc_state *); +extern int xfs_qm_scall_setinfo (struct xfs_mount *,uint , +struct qc_info *);extern int xfs_qm_scall_quotaon (struct xfs_mount *,uint );extern int xfs_qm_scall_quotaoff (struct xfs_mount *,uint );
fs/xfs/xfs_qm_syscalls.c +25 -0
@@ -451,6 +451,31 @@ int xfs_qm_scall_getstate(struct xfs_mount *mp, struct qc_state *state)return 0 ; } +#define XFS_QC_SETINFO_MASK (QC_TIMER_MASK | QC_WARNS_MASK) + +/* +* Adjust quota timers & warnings +*/ +int xfs_qm_scall_setinfo (struct xfs_mount *mp,uint type,struct qc_info *info) +{ +struct qc_dqblk newlim; + +if (info->i_fieldmask & ~XFS_QC_SETINFO_MASK ) +return -EINVAL ; +if ((info->i_fieldmask &XFS_QC_SETINFO_MASK ) ==0 ) +return 0 ; + + newlim.d_fieldmask = info->i_fieldmask; + newlim.d_spc_timer = info->i_spc_timelimit; + newlim.d_ino_timer = info->i_ino_timelimit; + newlim.d_rt_spc_timer = info->i_rt_spc_timelimit; + newlim.d_ino_warns = info->i_ino_warnlimit; + newlim.d_spc_warns = info->i_spc_warnlimit; + newlim.d_rt_spc_warns = info->i_rt_spc_warnlimit; + +return xfs_qm_scall_setqlim (mp,0 , type, &newlim); +} +#define XFS_QC_MASK \ (QC_LIMIT_MASK | QC_TIMER_MASK | QC_WARNS_MASK)
fs/xfs/xfs_quotaops.c +16 -0
@@ -45,6 +45,21 @@ static int xfs_fs_get_quota_state(struct super_block *sb, struct qc_state *s)return xfs_qm_scall_getstate (XFS_M (sb), s); } +static int xfs_fs_set_info (struct super_block *sb,int type, +struct qc_info *info) +{ +struct xfs_mount *mp =XFS_M (sb); + +if (sb->s_flags &MS_RDONLY ) +return -EROFS ; +if (!XFS_IS_QUOTA_RUNNING (mp)) +return -ENOSYS ; +if (!XFS_IS_QUOTA_ON (mp)) +return -ESRCH ; + +return xfs_qm_scall_setinfo (mp,xfs_quota_type (type), info); +} +static unsigned int xfs_quota_flags (unsigned int uflags) {unsigned int flags =0 ;
@@ -159,6 +174,7 @@ xfs_fs_set_dqblk(const struct quotactl_ops xfs_quotactl_operations = { .get_state = xfs_fs_get_quota_state, + .set_info = xfs_fs_set_info, .quota_enable = xfs_quota_enable, .quota_disable = xfs_quota_disable, .rm_xquota = xfs_fs_rm_xquota,
Signature · 1 line
2.1.2
Jan Kara
reviewerPATCH v3 17/17 quota: Hook up Q_XSETQLIM for id 0 to ->set_info
In reply to Jan KaraSetting timers or warning counts for id 0 via Q_XSETQLIM is used to actually set time limits and warning limits for all users. Hook up ->set_info to this so that VFS quota time limits get set the same way as XFS ones.
When doing this Q_XSETQLIM for XFS is effectively split into two independent transactions - one for setting timers and warning limits and one for setting space and inode limits. Although this is inefficient, it is rare enough that it does not matter.
--- fs/quota/quota.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
fs/quota/quota.c +39 -0
@@ -500,6 +500,30 @@ static void copy_from_xfs_dqblk(struct qc_dqblk *dst, struct fs_disk_quota *src) dst->d_fieldmask |=QC_RT_SPACE ; } +static void copy_qcinfo_from_xfs_dqblk (struct qc_info *dst, +struct fs_disk_quota *src) +{ +memset (dst,0 ,sizeof (*dst)); + dst->i_spc_timelimit = src->d_btimer; + dst->i_ino_timelimit = src->d_itimer; + dst->i_rt_spc_timelimit = src->d_rtbtimer; + dst->i_ino_warnlimit = src->d_iwarns; + dst->i_spc_warnlimit = src->d_bwarns; + dst->i_rt_spc_warnlimit = src->d_rtbwarns; +if (src->d_fieldmask &FS_DQ_BWARNS ) + dst->i_fieldmask |=QC_SPC_WARNS ; +if (src->d_fieldmask &FS_DQ_IWARNS ) + dst->i_fieldmask |=QC_INO_WARNS ; +if (src->d_fieldmask &FS_DQ_RTBWARNS ) + dst->i_fieldmask |=QC_RT_SPC_WARNS ; +if (src->d_fieldmask &FS_DQ_BTIMER ) + dst->i_fieldmask |=QC_SPC_TIMER ; +if (src->d_fieldmask &FS_DQ_ITIMER ) + dst->i_fieldmask |=QC_INO_TIMER ; +if (src->d_fieldmask &FS_DQ_RTBTIMER ) + dst->i_fieldmask |=QC_RT_SPC_TIMER ; +} +static int quota_setxquota (struct super_block *sb,int type,qid_t id,void __user *addr) {
@@ -514,6 +538,21 @@ static int quota_setxquota(struct super_block *sb, int type, qid_t id, qid =make_kqid (current_user_ns (), type, id);if (!qid_valid (qid))return -EINVAL ; +/* Are we actually setting timer / warning limits for all users? */ +if (from_kqid (&init_user_ns, qid) ==0 && + fdq.d_fieldmask & (FS_DQ_WARNS_MASK |FS_DQ_TIMER_MASK )) { +struct qc_info qinfo; +int ret; + +if (!sb->s_qcop->set_info) +return -EINVAL ; +copy_qcinfo_from_xfs_dqblk (&qinfo, &fdq); + ret = sb->s_qcop->set_info (sb, type, &qinfo); +if (ret) +return ret; +/* These are already done */ + fdq.d_fieldmask &= ~(FS_DQ_WARNS_MASK |FS_DQ_TIMER_MASK ); + }copy_from_xfs_dqblk (&qdq, &fdq);return sb->s_qcop->set_dqblk (sb, qid, &qdq); }
Signature · 1 line
2.1.2
Quoted 8 lines · Jan Kara
Hello,
this is another iteration of patches to unify VFS and XFS quota interfaces so
that XFS quotactls work for filesystems with VFS quotas and vice versa. This is useful so that userspace doesn't have to care that much about which filesystem it is using at least when using basic quota functionality. In particular we should be able to reuse project quota tests in xfstests for ext4.
Quoted 5 lines
The patches are based on quota cleanup series [1] and XFS cleanup series [2] I've sent previously and based on 3.19-rc4 + for-next branch of XFS tree. I could further split this series into per-quotactl series but frankly I don't think it will help reviewers in any way (the patches in the current series are already ordered by quotactl).
Hi Jan,
Do you have a this series in a git tree somewhere so it's easy to merge and test?
Quoted 5 lines
All the comments to the first version of the series are hopefully addressed, except for Dave's request to reduce number of copying of dquot information - I have benchmarked that reducing number of copies from 3 to 2 brings just 2% improvement in speed in my test setup and getting quota information isn't IMHO so performance critical that it would be worth the complications of the code.
I think the numbers address my concern adequately ;)
Cheers,
Dave.
Signature · 2 lines
Dave Chinner david at fromorbit.com
Jan Kara
reviewerQuoted 15 lines · Dave Chinner
Quoted 8 lines · Jan Kara
Hello,
this is another iteration of patches to unify VFS and XFS quota interfaces so
that XFS quotactls work for filesystems with VFS quotas and vice versa. This is useful so that userspace doesn't have to care that much about which filesystem it is using at least when using basic quota functionality. In particular we should be able to reuse project quota tests in xfstests for ext4.Quoted 5 lines
The patches are based on quota cleanup series [1] and XFS cleanup series [2] I've sent previously and based on 3.19-rc4 + for-next branch of XFS tree. I could further split this series into per-quotactl series but frankly I don't think it will help reviewers in any way (the patches in the current series are already ordered by quotactl).
Quoted 4 lines
Hi Jan,
Do you have a this series in a git tree somewhere so it's easy to merge and test?
I've pushed out the series to:git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git quota_interface
BTW, I've already implemented suggestions by Christoph so it's not
exactly what was sent to the list (but very close). I'd also welcome your opinion on usage of BBTOB() and BTOBB() macros in fs/quota/quota.c - to be able to use them I have to move them out of fs/xfs/libxfs/xfs_fs.h to somewhere in include/. Christoph doesn't like it much and would prefer quota code just opencoded these macros. I don't really care but you two should agree :)
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 23 lines · Jan Kara
Quoted 15 lines · Dave Chinner
Quoted 8 lines · Jan Kara
Hello,
this is another iteration of patches to unify VFS and XFS quota interfaces so
that XFS quotactls work for filesystems with VFS quotas and vice versa. This is useful so that userspace doesn't have to care that much about which filesystem it is using at least when using basic quota functionality. In particular we should be able to reuse project quota tests in xfstests for ext4.Quoted 5 lines
The patches are based on quota cleanup series [1] and XFS cleanup series [2] I've sent previously and based on 3.19-rc4 + for-next branch of XFS tree. I could further split this series into per-quotactl series but frankly I don't think it will help reviewers in any way (the patches in the current series are already ordered by quotactl).
Quoted 4 lines
Hi Jan,
Do you have a this series in a git tree somewhere so it's easy to merge and test?
I've pushed out the series to:
git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.gitquota_interface
Quoted 7 lines
BTW, I've already implemented suggestions by Christoph so it's not
exactly what was sent to the list (but very close). I'd also welcome your opinion on usage ofBBTOB()andBTOBB()macros infs/quota/quota.c- to be able to use them I have to move them out offs/xfs/libxfs/xfs_fs.hto somewhere ininclude/. Christoph doesn't like it much and would prefer quota code just opencoded these macros. I don't really care but you two should agree :)
fs/xfs/libxfs/xfs_fs.h is the XFS userspace API definition file and is shared with userspace (via xfsprogs, ends up at /usr/include/xfs/xfs_fs.h), and BBTOB() and BTOBB() are part of that API, hence they need to stay there.
ISTR that you only need them in one place in the quota translation layer, so Christoph is right - it's probably best to simply open code them with an appropriate comment somewhere in the file to explain why....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner david at fromorbit.com