quota: Unify VFS and XFS quota interfaces
Subsystems (6)
Jan Kara
reviewercover quota: Unify VFS and XFS quota interfaces
Hello,
this is a first (still partial) attempt 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.
In this patch set I unify quotaon / quotaoff handling (Q_QUOTAON, Q_QUOTAOFF, Q_XQUOTAON, Q_XQUOTAOFF calls) and fix some bugs in the Q_XGETQUOTA, Q_XSETQLIM, Q_GETQUOTA, Q_SETQUOTA calls done by Christoph some time ago. I have actually verified that xfs_quota is able to work with ext4 filesystem (after tweaking it to not check fs type) when these patches are applied.
What is still missing is unification of Q_XGETQSTATV, Q_GETINFO, Q_SETINFO.
Comments are welcome.
Honza
Jan Kara
reviewerPATCH 1/11 xfs: Remove useless test
Q_XQUOTARM is never passed to xfs_fs_set_xstate() so remove the test.
--- fs/xfs/xfs_quotaops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_quotaops.c +1 -1
@@ -77,7 +77,7 @@ xfs_fs_set_xstate(if (sb->s_flags &MS_RDONLY )return -EROFS ; -if (op !=Q_XQUOTARM && !XFS_IS_QUOTA_RUNNING (mp)) +if (!XFS_IS_QUOTA_RUNNING (mp))return -ENOSYS ;if (uflags &FS_QUOTA_UDQ_ACCT )
Signature · 1 line
1.8.1.4
Jan Kara
reviewerPATCH 2/11 xfs: Remove unused variable in xfs_qm_scall_quotaon()
In reply to Jan Karasbflags variable in xfs_qm_scall_quotaon() was practically unused (we only set it to constant at one place and used it elsewhere). Remove it.
--- fs/xfs/xfs_qm_syscalls.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
fs/xfs/xfs_qm_syscalls.c +2 -6
@@ -315,7 +315,6 @@ xfs_qm_scall_quotaon( {int error;uint qf; -__int64_t sbflags; flags &= (XFS_ALL_QUOTA_ACCT |XFS_ALL_QUOTA_ENFD );/*
@@ -323,8 +322,6 @@ xfs_qm_scall_quotaon(*/ flags &= ~(XFS_ALL_QUOTA_ACCT ); - sbflags =0 ; -if (flags ==0 ) {xfs_debug (mp,"%s: zero flags, m_qflags=%x" , __func__, mp->m_qflags);
@@ -371,11 +368,10 @@ xfs_qm_scall_quotaon(/* * There's nothing to change if it's the same. */ -if ((qf & flags) == flags && sbflags ==0 ) +if ((qf & flags) == flags)return -EEXIST ; - sbflags |=XFS_SB_QFLAGS ; -if ((error =xfs_qm_write_sb_changes (mp, sbflags))) +if ((error =xfs_qm_write_sb_changes (mp,XFS_SB_QFLAGS )))return error;/* * If we aren't trying to switch on quota enforcement, we are done.
Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerPATCH 3/11 xfs: Remove some useless flags tests
In reply to Jan Kara'flags' have XFS_ALL_QUOTA_ACCT cleared immediately on function entry. There's no point in checking these bits later in the function. Also because we check something is going to change, we know some enforcement bits are being added and thus there's no point in testing that later.
--- fs/xfs/xfs_qm_syscalls.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
fs/xfs/xfs_qm_syscalls.c +4 -11
@@ -328,22 +328,16 @@ xfs_qm_scall_quotaon(return -EINVAL ; } -/* No fs can turn on quotas with a delayed effect */ -ASSERT ((flags &XFS_ALL_QUOTA_ACCT ) ==0 ); -/* * Can't enforce without accounting. We check the superblock * qflags here instead of m_qflags because rootfs can have * quota acct on ondisk without m_qflags' knowing. */ -if (((flags &XFS_UQUOTA_ACCT ) ==0 && - (mp->m_sb.sb_qflags &XFS_UQUOTA_ACCT ) ==0 && +if (((mp->m_sb.sb_qflags &XFS_UQUOTA_ACCT ) ==0 && (flags &XFS_UQUOTA_ENFD )) || - ((flags &XFS_GQUOTA_ACCT ) ==0 && - (mp->m_sb.sb_qflags &XFS_GQUOTA_ACCT ) ==0 && + ((mp->m_sb.sb_qflags &XFS_GQUOTA_ACCT ) ==0 && (flags &XFS_GQUOTA_ENFD )) || - ((flags &XFS_PQUOTA_ACCT ) ==0 && - (mp->m_sb.sb_qflags &XFS_PQUOTA_ACCT ) ==0 && + ((mp->m_sb.sb_qflags &XFS_PQUOTA_ACCT ) ==0 && (flags &XFS_PQUOTA_ENFD ))) { xfs_debug(mp, "%s: Can't enforce without acct, flags=%x sbflags=%x",
@@ -381,8 +375,7 @@ xfs_qm_scall_quotaon( ((mp->m_sb.sb_qflags &XFS_PQUOTA_ACCT ) != (mp->m_qflags &XFS_PQUOTA_ACCT )) || ((mp->m_sb.sb_qflags &XFS_GQUOTA_ACCT ) != - (mp->m_qflags &XFS_GQUOTA_ACCT )) || - (flags & XFS_ALL_QUOTA_ENFD) == 0) + (mp->m_qflags & XFS_GQUOTA_ACCT))) return 0;if (!XFS_IS_QUOTA_RUNNING (mp))
Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerPATCH 4/11 quota: Split ->set_xstate callback into two
In reply to Jan KaraSplit ->set_xstate callback into two callbacks - one for turning quotas on (->sysquota_on) and one for turning quotas off (->sysquota_off). 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
@@ -195,15 +195,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_sysquota_on (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->sysquota_on)return -ENOSYS ; -return sb->s_qcop->set_xstate (sb, flags, cmd); +return sb->s_qcop->sysquota_on (sb, flags); +} + +static int quota_sysquota_off (struct super_block *sb,void __user *addr) +{ +__u32 flags; + +if (copy_from_user (&flags, addr,sizeof (flags))) +return -EFAULT ; +if (!sb->s_qcop->sysquota_off) +return -ENOSYS ; +return sb->s_qcop->sysquota_off (sb, flags); }static int quota_getxstate (struct super_block *sb,void __user *addr)
@@ -326,8 +337,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_sysquota_on (sb, addr);case Q_XQUOTAOFF : -return quota_setxstate (sb, cmd, addr); +return quota_sysquota_off (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
@@ -326,8 +326,9 @@ struct quotactl_ops {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 (*sysquota_on)(struct super_block *,unsigned int ); +int (*sysquota_off)(struct super_block *,unsigned int );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 · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerPATCH 5/11 quota: Wire up ->sysquota_{on,off} callbacks into Q_QUOTA{ON,OFF}
In reply to Jan KaraMake Q_QUOTAON / Q_QUOTAOFF quotactl call ->sysquota_on / ->sysquota_off 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
@@ -63,18 +63,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->sysquota_on)return -ENOSYS ;if (sb->s_qcop->quota_on_meta)return sb->s_qcop->quota_on_meta (sb, type, id); +if (sb->s_qcop->sysquota_on) +return sb->s_qcop->sysquota_on (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->sysquota_off) +return -ENOSYS ; +if (sb->s_qcop->sysquota_off) +return sb->s_qcop->sysquota_off (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;
@@ -319,9 +344,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
1.8.1.4
Jan Kara
reviewerPATCH 6/11 quota: Add ->sysquota_{on,off} callbacks for VFS quotas
In reply to Jan KaraAdd functions which translate ->sysquota_on / ->sysquota_off 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.
--- fs/quota/dquot.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/quotaops.h | 2 ++ 2 files changed, 84 insertions(+)
fs/quota/dquot.c +82 -0
@@ -2380,6 +2380,88 @@ out: }EXPORT_SYMBOL (dquot_quota_on_mount); +int dquot_sysquota_on (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_sysquota_on); + +int dquot_sysquota_off (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_sysquota_off); +static inline qsize_t qbtos (qsize_t blocks) {return blocks <<QIF_DQBLKSIZE_BITS ;
include/linux/quotaops.h +2 -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_sysquota_on (struct super_block *sb,unsigned int flags); +int dquot_sysquota_off (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);
Signature · 1 line
1.8.1.4
Jan Kara
reviewerPATCH 7/11 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_sysquota_on() 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 | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-)
fs/ext4/super.c +2 -32
@@ -1055,10 +1055,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);
@@ -1090,8 +1087,8 @@ static const struct quotactl_ops ext4_qctl_operations = { };static const struct quotactl_ops ext4_qctl_sysfile_operations = { - .quota_on_meta = ext4_quota_on_sysfile, - .quota_off = ext4_quota_off_sysfile, + .sysquota_on = dquot_sysquota_on, + .sysquota_off = dquot_sysquota_off, .quota_sync = dquot_quota_sync, .get_info = dquot_get_dqinfo, .set_info = dquot_set_dqinfo,
@@ -5273,21 +5270,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];
@@ -5314,18 +5296,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 · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerPATCH 8/11 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_sysquota_on() checking whether usage tracking is enabled (which can happen only if the filesystem has the quota feature set).
--- fs/ocfs2/super.c | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-)
fs/ocfs2/super.c +2 -22
@@ -993,29 +993,9 @@ 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, + .sysquota_on = dquot_sysquota_on, + .sysquota_off = dquot_sysquota_off, .quota_sync = dquot_quota_sync, .get_info = dquot_get_dqinfo, .set_info = dquot_set_dqinfo,
Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerPATCH 9/11 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
@@ -79,11 +79,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->sysquota_on) +if (!sb->s_qcop->quota_on && !sb->s_qcop->sysquota_on)return -ENOSYS ; -if (sb->s_qcop->quota_on_meta) -return sb->s_qcop->quota_on_meta (sb, type, id);if (sb->s_qcop->sysquota_on)return sb->s_qcop->sysquota_on (sb,qtype_limit_flag (type));if (IS_ERR (path))
include/linux/quota.h +0 -1
@@ -319,7 +319,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_sync)(struct super_block *,int );int (*get_info)(struct super_block *,int ,struct if_dqinfo *);
Signature · 6 lines
1.8.1.4 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerPATCH 10/11 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 | 157 +++++++++++++++++++++++++++++++++++++++-------- 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 +- 8 files changed, 313 insertions(+), 195 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; } }
@@ -1502,7 +1502,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;
@@ -1510,7 +1510,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 */
@@ -1527,12 +1527,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:
@@ -1541,10 +1538,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);
@@ -1588,17 +1585,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 +132 -25
223 lines not on this page · raw message
fs/xfs/xfs_qm.h +2 -2
@@ -166,9 +166,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
@@ -146,7 +146,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);
@@ -156,14 +156,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);
@@ -175,7 +175,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);
Signature · 1 line
1.8.1.4
Jan Kara
reviewerPATCH 11/11 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
@@ -2462,16 +2462,6 @@ out_err: }EXPORT_SYMBOL (dquot_sysquota_off); -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) {
@@ -2521,13 +2511,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
@@ -211,8 +211,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
1.8.1.4
Re: [PATCH 02/11] xfs: Remove unused variable in xfs_qm_scall_quotaon()
In reply to Jan KaraQuoted 4 lines · Jan Kara
sbflags variable in
xfs_qm_scall_quotaon()was practically unused (we only set it to constant at one place and used it elsewhere). Remove it.Signed-off-by Jan Kara <[email protected]>
I have patches in my queue that change the superblock logging quite a bit and remove the functionality you're changing in this patch, so eventually you'll be able to drop this patch.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 03/11] xfs: Remove some useless flags tests
In reply to Jan KaraQuoted 6 lines · Jan Kara
'flags' have
XFS_ALL_QUOTA_ACCTcleared immediately on function entry. There's no point in checking these bits later in the function. Also because we check something is going to change, we know some enforcement bits are being added and thus there's no point in testing that later.Signed-off-by Jan Kara <[email protected]>
Looks sane. I'll pick this up straight away.
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Re: [PATCH 01/11] xfs: Remove useless test
In reply to Jan KaraQuoted 3 lines · Jan Kara
Q_XQUOTARMis never passed toxfs_fs_set_xstate()so remove the test.Signed-off-by Jan Kara <[email protected]>
Looks fine - the higher layers ahave changed since this was added. I'll pick this one up straight away.
-Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH 04/11] quota: Split ->set_xstate callback into two
In reply to Jan KaraQuoted 4 lines · Jan Kara
Split ->set_xstate callback into two callbacks - one for turning quotas on (->sysquota_on) and one for turning quotas off (->sysquota_off). That way we don't have to pass quotactl command into the callback which seems cleaner.
Yes, I much prefer these to be split. But the names seem a little odd, why not enable_quota/disable_quota?
Quoted 1 line
+static unsigned int
generic_to_xfs_flags(unsigned int uflags)
xfs_quota_flags() ?
Re: [PATCH 07/11] ext4: Use generic helpers for quotaon and quotaoff
In reply to Jan Karafs/ext4/super.c static const struct quotactl_ops ext4_qctl_operations = { · line 1094
Quoted 8 lines
static const struct
quotactl_opsext4_qctl_sysfile_operations= {fs/ext4/super.c +2
-2- .quota_on_meta = ext4_quota_on_sysfile, - .quota_off = ext4_quota_off_sysfile, + .sysquota_on = dquot_sysquota_on, + .sysquota_off = dquot_sysquota_off, .quota_sync = dquot_quota_sync, .get_info = dquot_get_dqinfo, .set_info = dquot_set_dqinfo,
This vector now only has generic dquot_ methods. Maybe move the vector to fs/quota/dquot.c and allow multiple filesystems to share it?
Jan Kara
reviewerRe: [PATCH 04/11] quota: Split ->set_xstate callback into two
In reply to Christoph HellwigQuoted 8 lines · Christoph Hellwig
Quoted 4 lines · Jan Kara
Split ->set_xstate callback into two callbacks - one for turning quotas on (->sysquota_on) and one for turning quotas off (->sysquota_off). That way we don't have to pass quotactl command into the callback which seems cleaner.
Yes, I much prefer these to be split. But the names seem a little odd, why not enable_quota/disable_quota?
I wanted to clearly separate this from quota_on() / quota_off() callbacks
which are for userspace visible quota files. However enable_quota / disable_quota sound fine as well.
Quoted 3 lines
Quoted 1 line
+static unsigned int
generic_to_xfs_flags(unsigned int uflags)
xfs_quota_flags()?
OK.
Honza
Signature · 7 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Jan Kara
reviewerRe: [PATCH 07/11] ext4: Use generic helpers for quotaon and quotaoff
In reply to Christoph HellwigQuoted 11 lines · Christoph Hellwig
fs/ext4/super.c static const struct quotactl_ops ext4_qctl_operations = { · line 1094
Quoted 8 lines
static const struct
quotactl_opsext4_qctl_sysfile_operations= {fs/ext4/super.c +2
-2- .quota_on_meta = ext4_quota_on_sysfile, - .quota_off = ext4_quota_off_sysfile, + .sysquota_on = dquot_sysquota_on, + .sysquota_off = dquot_sysquota_off, .quota_sync = dquot_quota_sync, .get_info = dquot_get_dqinfo, .set_info = dquot_set_dqinfo,This vector now only has generic
dquot_methods. Maybe move the vector tofs/quota/dquot.cand allow multiple filesystems to share it?
Right. ocfs2 actually has the same vector now. I'll unify it.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 10/11] quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units
In reply to Jan KaraQuoted 10 lines · Jan Kara
Currently ->get_dqblk() and ->set_dqblk() use struct
fs_disk_quotawhich 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 intod_bcountfield of structfd_disk_quota). Only if you tried to useQ_XGETQUOTAorQ_XSETQLIMfor VFS quotas (orQ_GETQUOTA/Q_SETQUOTAfor XFS quotas), you got bogus results but noone really tried that. But when we want interfaces compatible we need to fix this.
Quoted 4 lines
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.cbut it seems cleaner than overloading e.g. units ofd_bcountto bytes.
I don't really like the idea of having to copy the dquot information an extra time. We now:
- copy from internal dquot to the new qc_dqblk
- copy from the new qc_dqblk to if_dqblk/xfs_dqblk
- copy if_dqblk/xfs_dqblk to the user buffer.
That's now three copies, and when we are having to deal with quota reports containing hundreds of thousands of dquots that's going to hrut performance.
We could probably get away with just one copy by passing a filldir()-like context down into the filesystems to format their internal dquot information directly into the user buffer in the appropriate format. That way fs/quota/quota.c doesn't need conversion routines, filesystems can optimise the formating to minimise copying, and we can still provide generic routines for filesystems using the generic quota infrastructure....
[...]
Quoted 5 lines
fs/quota/quota.c +1
-0@@ -277,10 +287,73 @@ static int quota_getxstatev(struct super_block *sb, void __user *addr)return ret; } +/* XFS blocks to space conversion */
fs/quota/quota.c static int quota_getxstatev(struct super_block *sb, void __user *addr) · line 300
Quoted 10 lines
fs/quota/quota.c +10
-0+static u64 xfs_btos (u64 blocks) +{ +return blocks <<9 ; +} + +/* Space to XFS blocks conversion */ +static u64 xfs_stob (u64 space) +{ +return (space +511 ) >>9 ; +}
Which is just redefining BBTOB() [Basic Blocks to Bytes] and BTOBB() with magic numbers and no explanation of what a "block" actually is. We already export those macros to userspace, and they are used by xfs_quota to convert the block counts to bytes....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Jan Kara
reviewerRe: [PATCH 10/11] quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units
Quoted 27 lines · Dave Chinner
Quoted 10 lines · Jan Kara
Currently ->get_dqblk() and ->set_dqblk() use struct
fs_disk_quotawhich 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 intod_bcountfield of structfd_disk_quota). Only if you tried to useQ_XGETQUOTAorQ_XSETQLIMfor VFS quotas (orQ_GETQUOTA/Q_SETQUOTAfor XFS quotas), you got bogus results but noone really tried that. But when we want interfaces compatible we need to fix this.Quoted 4 lines
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.cbut it seems cleaner than overloading e.g. units ofd_bcountto bytes.I don't really like the idea of having to copy the dquot information an extra time. We now:
- copy from internal dquot to the new
qc_dqblk
- copy from the newqc_dqblkto if_dqblk/xfs_dqblk
- copy if_dqblk/xfs_dqblk to the user buffer.That's now three copies, and when we are having to deal with quota reports containing hundreds of thousands of dquots that's going to hrut performance.
Quoted 7 lines
We could probably get away with just one copy by passing a filldir()-like context down into the filesystems to format their internal dquot information directly into the user buffer in the appropriate format. That way
fs/quota/quota.cdoesn't need conversion routines, filesystems can optimise the formating to minimise copying, and we can still provide generic routines for filesystems using the generic quota infrastructure....
I was thinking about how this would look like. I don't have a problem to
create a filldir() like callback that will be used for getting quota structures. However I don't see how we could reasonably get away with just one copy in general - that would mean that the interface functions in fs/quota.c (e.g. quota_getquota()) would have to determine whether XFS of VFS quota structures are used in the backing filesystem to provide proper callback and that's IMO too ugly to live.
We could definitely reduce the number of copies to two by changing e.g. copy_to_xfs_dqblk() to directly use __put_user() instead of first formatting proper structure on stack and then using copy_to_user(). However I'm not sure whether this will be any real performance win and using copy_to_user() seems easier to me...
Anyway I'll probably try changing number of copies to two and see whether there's any measurable impact.
Quoted 4 lines
Quoted 4 lines
fs/quota/quota.c +0
-0@@ -277,10 +287,73 @@ static int quota_getxstatev(struct super_block *sb, void __user *addr)return ret; }
Quoted 16 lines
fs/quota/quota.c static int quota_getxstatev(struct super_block *sb, void __user *addr) · line 300
Quoted 11 lines
fs/quota/quota.c +11
-0+/* XFS blocks to space conversion */ +static u64 xfs_btos (u64 blocks) +{ +return blocks <<9 ; +} + +/* Space to XFS blocks conversion */ +static u64 xfs_stob (u64 space) +{ +return (space +511 ) >>9 ; +}Which is just redefining
BBTOB()[Basic Blocks to Bytes] andBTOBB()with magic numbers and no explanation of what a "block" actually is. We already export those macros to userspace, and they are used byxfs_quotato convert the block counts to bytes....
Sure, I will use XFS macros.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Jan Kara
reviewerRe: [PATCH 10/11] quota: Switch ->get_dqblk() and ->set_dqblk() to use bytes as space units
Quoted 43 lines · Jan Kara
Quoted 27 lines · Dave Chinner
Quoted 10 lines · Jan Kara
Currently ->get_dqblk() and ->set_dqblk() use struct
fs_disk_quotawhich 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 intod_bcountfield of structfd_disk_quota). Only if you tried to useQ_XGETQUOTAorQ_XSETQLIMfor VFS quotas (orQ_GETQUOTA/Q_SETQUOTAfor XFS quotas), you got bogus results but noone really tried that. But when we want interfaces compatible we need to fix this.Quoted 4 lines
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.cbut it seems cleaner than overloading e.g. units ofd_bcountto bytes.I don't really like the idea of having to copy the dquot information an extra time. We now:
- copy from internal dquot to the new
qc_dqblk
- copy from the newqc_dqblkto if_dqblk/xfs_dqblk
- copy if_dqblk/xfs_dqblk to the user buffer.That's now three copies, and when we are having to deal with quota reports containing hundreds of thousands of dquots that's going to hrut performance.
Quoted 7 lines
We could probably get away with just one copy by passing a filldir()-like context down into the filesystems to format their internal dquot information directly into the user buffer in the appropriate format. That way
fs/quota/quota.cdoesn't need conversion routines, filesystems can optimise the formating to minimise copying, and we can still provide generic routines for filesystems using the generic quota infrastructure....I was thinking about how this would look like. I don't have a problem to
create afilldir()like callback that will be used for getting quota structures. However I don't see how we could reasonably get away with just one copy in general - that would mean that the interface functions infs/quota.c(e.g.quota_getquota()) would have to determine whether XFS of VFS quota structures are used in the backing filesystem to provide proper callback and that's IMO too ugly to live.
Quoted 8 lines
We could definitely reduce the number of copies to two by changing e.g.
copy_to_xfs_dqblk()to directly use__put_user()instead of first formatting proper structure on stack and then usingcopy_to_user(). However I'm not sure whether this will be any real performance win and usingcopy_to_user()seems easier to me...Anyway I'll probably try changing number of copies to two and see whether there's any measurable impact.
So when I change the number of copies to two by using __put_user, I get
about about 2.3% reduction in time for getting quota information for vfs quotas (fully cached) and about 1.7% reduction in time for getting quota information for xfs quotas.
For VFS quotas numbers are:
Average of 4 runs with 3 copies is 2.212286s (for 100000 getquota calls). Average of 4 runs with 2 copies is 2.160500s (for 100000 getquota calls).
For XFS quotas numbers are:
Average of 4 runs with 3 copies is 1.584250s (for 100000 getquota calls). Average of 4 runs with 2 copies is 1.557250s (for 100000 getquota calls).
So overall it seems to me that avoiding another copy is not worth the bother...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR