Allow pquota and gquota to be used together
Subsystems (3)
v11 cover Allow pquota and gquota to be used together
Hello All,
This is the version 11 of the changes to allow pquota and gquota to be used together.
Patchset applies cleanly on top of 42c49d7f249c2487f36d3314753d5d8ebcee8249 in xfs git tree.
---
Chandra Seetharaman (4):
xfs: Add pquota fields where gquota is used.
xfs: Start using pquotaino from the superblock.
xfs: Add proper versioning support to fs_quota_stat
xfs: Use new qs_pquota field in fs_quota_stat for Q_XGETQSTAT
fs/gfs2/quota.c | 3 - fs/quota/quota.c | 67 ++++++++++- fs/xfs/xfs_dquot.c | 15 ++- fs/xfs/xfs_dquot.h | 7 +- fs/xfs/xfs_icache.c | 1 + fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_ioctl.c | 14 +- fs/xfs/xfs_iops.c | 4 +- fs/xfs/xfs_mount.c | 62 +++++++++-- fs/xfs/xfs_qm.c | 259 ++++++++++++++++++++++++++++------------ fs/xfs/xfs_qm.h | 20 ++- fs/xfs/xfs_qm_bhv.c | 10 +- fs/xfs/xfs_qm_syscalls.c | 70 +++++++++--- fs/xfs/xfs_quota.h | 32 +++-- fs/xfs/xfs_sb.h | 9 ++- fs/xfs/xfs_super.c | 19 ++-- fs/xfs/xfs_symlink.c | 10 +- fs/xfs/xfs_trans_dquot.c | 26 ++++- fs/xfs/xfs_vnodeops.c | 13 ++- include/uapi/linux/dqblk_xfs.h | 59 ++++++++- 20 files changed, 528 insertions(+), 173 deletions(-)
----------
Changes from version 10 to verion 11:
- Few of the patches have been merged.
- Localized all the logic to handle simultaneous use
of XFS_SB_GQUOTINO and XFS_SB_PQUOTINO to xfs_sb_quota_from_disk() and xfs_sb_from_disk as per Dave's suggestion.
- moved setting sb_pquotino to xfs_sb_quota_frp,_disk() as per Dave's suggestion.
- Added new Q_XGETQSTATV command to handle the new sematics of quota_stata as per Jan's comment.
- Fixed few nits as per Ben's comment
Version 10 can be found at:
http://oss.sgi.com/archives/xfs/2013-06/msg00902.html
Changes from version 9 to version 10:
- Split prep into 6 patches as per Ben and Dave's suggestion
- Added xfs_sb_quota_from_disk() as per Dave's suggestion
- Made u/g/p ordering consistent
- Fixed fields in fs_quota_stat as per Dave's suggestion
- Moved few ASSERTs to be inside error check as per Ben's suggestion
- Few cosmetic changes
Version 9 can be found at:
http://oss.sgi.com/archives/xfs/2013-06/msg00770.html
Changes from verion 8 to version 9:
- Made all the changes suggested by Dave
- Rearranged code to make the functional changes to not be cluttered.
Version 8 can be found at:
http://oss.sgi.com/archives/xfs/2013-05/msg00296.html
Changes from version 7 to version 8:
- Rebased to the current code.
- Modified code to use the new pquotino field in version 5 of the superblock.
Version 7 can be found at:
http://oss.sgi.com/archives/xfs/2013-03/msg00671.html
Changes from version 6 to version 7:
- Made all the changes suggested by Dave Chinner
- Added padding to fs_quota_stat, which made the new data structure field ordering different from the old data structure field ordering. So, copied the old version to be _v1 version and used that if old version of data structure was provided from user space.
Version 6 can be found at:
http://oss.sgi.com/archives/xfs/2012-07/msg00286.html
Changes from version 5 to version 6:
- Use radix tree instead of hash table
Version 5 can be found at:
http://oss.sgi.com/archives/xfs/2012-03/msg00310.html
Changes fron version 4 to version 5:
rebase with the current tree one simple change.
Version 4 can be found at
http://oss.sgi.com/archives/xfs/2012-02/msg00528.html
Changes from version 3 to version 4:
- Remove save_flags with storing the value (in to superblock) based on field type info
- fix checkpatch.pl warnings and errors
Version 3 of the posting can be found at
http://oss.sgi.com/archives/xfs/2012-01/msg00309.html
Changes from version 2 to version 3:
- hash table for pquota is added.
- changes to apply cleanly with the latest tree
version 2 of the posting can be found at
http://oss.sgi.com/archives/xfs/2011-10/msg00470.html
Changes from version 1 to version 2:
- Created a new prep patch to accomodate some generic changes that ease the later patches.
- Created a new patch to add a new field qs_pquota to fs_quota_stat with appropriate versioning changes
- Changed the logic to allow XFS_OQUOTA.* flags to be allowed only in the older versions.
- Changed couple of places where PQUOTA checking was on the else if construct so as to allow both GQUOTA and PQUOTA in those places.
- Fixed comments in xfs_quota.h to reflect the current changes.
- Changed the name of the macro XFS_SB_VERSION2_SEPER_PQUOTA to XFS_SB_VERSION2_NO_OQUOTA
- got rid of the macros XFS_MOUNT_QUOTA_SET1 and XFS_MOUNT_QUOTA_SET2
- added a new inline function xfs_inode_dquot(ip, type) to simplify the error path in xfs_qm_dqget()
- got rid of the macro XFS_IS_THIS_QUOTA_OFF
- added comment to explain why sb_qflags is saved and restored in xfs_sb_to_disk()
version 1 of the posting can be found at
http://oss.sgi.com/archives/xfs/2011-10/msg00341.html
Thanks & Regards,
chandra
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v11 1/4 xfs: Add pquota fields where gquota is used.
Add project quota changes to all the places where group quota field is used:
* add separate project quota members into various structures
* split project quota and group quotas so that instead of overriding the group quota members incore, the new project quota members are used instead
* get rid of usage of the OQUOTA flag incore, in favor of separate group and project quota flags.
* add a project dquot argument to various functions.
Not using the pquotino field from superblock yet.
--- fs/xfs/xfs_dquot.c | 15 +++- fs/xfs/xfs_dquot.h | 7 +- fs/xfs/xfs_icache.c | 1 + fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_ioctl.c | 14 ++-- fs/xfs/xfs_iops.c | 4 +- fs/xfs/xfs_qm.c | 243 +++++++++++++++++++++++++++++++++------------- fs/xfs/xfs_qm.h | 20 +++-- fs/xfs/xfs_qm_bhv.c | 10 +- fs/xfs/xfs_qm_syscalls.c | 19 +++- fs/xfs/xfs_quota.h | 32 ++++--- fs/xfs/xfs_symlink.c | 10 ++- fs/xfs/xfs_trans_dquot.c | 26 ++++- fs/xfs/xfs_vnodeops.c | 13 ++- 14 files changed, 291 insertions(+), 124 deletions(-)
fs/xfs/xfs_dquot.c +12 -3
@@ -936,6 +936,7 @@ xfs_qm_dqput_final( {struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo;struct xfs_dquot *gdqp; +struct xfs_dquot *pdqp;trace_xfs_dqput_free (dqp);
@@ -949,21 +950,29 @@ xfs_qm_dqput_final(/* * If we just added a udquot to the freelist, then we want to release -* the gdquot reference that it (probably) has. Otherwise it'll keep -* the gdquot from getting reclaimed. +* the gdquot/pdquot reference that it (probably) has. Otherwise it'll +* keep the gdquot/pdquot from getting reclaimed. */ gdqp = dqp->q_gdquot;if (gdqp) {xfs_dqlock (gdqp); dqp->q_gdquot =NULL ; } + + pdqp = dqp->q_pdquot; +if (pdqp) { +xfs_dqlock (pdqp); + dqp->q_pdquot =NULL ; + }xfs_dqunlock (dqp);/* -* If we had a group quota hint, release it now. +* If we had a group/project quota hint, release it now. */ if (gdqp)xfs_qm_dqput (gdqp); +if (pdqp) +xfs_qm_dqput (pdqp); }/*
fs/xfs/xfs_dquot.h +5 -2
@@ -53,6 +53,7 @@ typedef struct xfs_dquot {xfs_fileoff_t q_fileoffset;/* offset in quotas file */ struct xfs_dquot *q_gdquot;/* group dquot, hint only */ +struct xfs_dquot *q_pdquot;/* project dquot, hint only */ xfs_disk_dquot_t q_core;/* actual usage & quotas */ xfs_dq_logitem_t q_logitem;/* dquot log item */ xfs_qcnt_t q_res_bcount;/* total regular nblks used+reserved */
@@ -118,8 +119,9 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type)case XFS_DQ_USER :return XFS_IS_UQUOTA_ON (mp);case XFS_DQ_GROUP : +return XFS_IS_GQUOTA_ON (mp);case XFS_DQ_PROJ : -return XFS_IS_OQUOTA_ON (mp); +return XFS_IS_PQUOTA_ON (mp);default :return 0 ; }
@@ -131,8 +133,9 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)case XFS_DQ_USER :return ip->i_udquot;case XFS_DQ_GROUP : -case XFS_DQ_PROJ :return ip->i_gdquot; +case XFS_DQ_PROJ : +return ip->i_pdquot;default :return NULL ; }
fs/xfs/xfs_icache.c +1 -0
@@ -337,6 +337,7 @@ xfs_iget_cache_miss( iflags |=XFS_IDONTCACHE ; ip->i_udquot =NULL ; ip->i_gdquot =NULL ; + ip->i_pdquot =NULL ;xfs_iflags_set (ip, iflags);/* insert the new inode */
fs/xfs/xfs_inode.h +1 -0
@@ -250,6 +250,7 @@ typedef struct xfs_inode {struct xfs_mount *i_mount;/* fs mount struct ptr */ struct xfs_dquot *i_udquot;/* user dquot */ struct xfs_dquot *i_gdquot;/* group dquot */ +struct xfs_dquot *i_pdquot;/* project dquot */ /* Inode location stuff */ xfs_ino_t i_ino;/* inode number (agno/agino)*/
fs/xfs/xfs_ioctl.c +7 -7
@@ -928,7 +928,7 @@ xfs_ioctl_setattr(struct xfs_trans *tp;unsigned int lock_flags =0 ;struct xfs_dquot *udqp =NULL ; -struct xfs_dquot *gdqp =NULL ; +struct xfs_dquot *pdqp =NULL ;struct xfs_dquot *olddquot =NULL ;int code;
@@ -957,7 +957,7 @@ xfs_ioctl_setattr(if (XFS_IS_QUOTA_ON (mp) && (mask &FSX_PROJID )) { code =xfs_qm_vop_dqalloc (ip, ip->i_d.di_uid, ip->i_d.di_gid, fa->fsx_projid, -XFS_QMOPT_PQUOTA , &udqp, &gdqp); +XFS_QMOPT_PQUOTA , &udqp,NULL , &pdqp);if (code)return code; }
@@ -994,8 +994,8 @@ xfs_ioctl_setattr( XFS_IS_PQUOTA_ON(mp) && xfs_get_projid(ip) != fa->fsx_projid) {ASSERT (tp); - code =xfs_qm_vop_chown_reserve (tp, ip, udqp, gdqp, -capable (CAP_FOWNER ) ? + code =xfs_qm_vop_chown_reserve (tp, ip, udqp,NULL , + pdqp,capable (CAP_FOWNER ) ?XFS_QMOPT_FORCE_RES :0 );if (code)/* out of quota */ goto error_return;
@@ -1113,7 +1113,7 @@ xfs_ioctl_setattr(if (xfs_get_projid (ip) != fa->fsx_projid) {if (XFS_IS_QUOTA_RUNNING (mp) &&XFS_IS_PQUOTA_ON (mp)) { olddquot =xfs_qm_vop_chown (tp, ip, - &ip->i_gdquot, gdqp); + &ip->i_pdquot, pdqp); }xfs_set_projid (ip, fa->fsx_projid);
@@ -1160,13 +1160,13 @@ xfs_ioctl_setattr(*/ xfs_qm_dqrele (olddquot);xfs_qm_dqrele (udqp); -xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp);return code; error_return:xfs_qm_dqrele (udqp); -xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp);xfs_trans_cancel (tp,0 );if (lock_flags)xfs_iunlock (ip, lock_flags);
fs/xfs/xfs_iops.c +2 -2
@@ -539,7 +539,7 @@ xfs_setattr_nonsize(ASSERT (udqp ==NULL );ASSERT (gdqp ==NULL ); error =xfs_qm_vop_dqalloc (ip, uid, gid,xfs_get_projid (ip), - qflags, &udqp, &gdqp); + qflags, &udqp, &gdqp,NULL );if (error)return error; }
@@ -575,7 +575,7 @@ xfs_setattr_nonsize( (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {ASSERT (tp); error =xfs_qm_vop_chown_reserve (tp, ip, udqp, gdqp, -capable (CAP_FOWNER ) ? +NULL ,capable (CAP_FOWNER ) ?XFS_QMOPT_FORCE_RES :0 );if (error)/* out of quota */ goto out_trans_cancel;
fs/xfs/xfs_qm.c +174 -69
500 lines not on this page · raw message
fs/xfs/xfs_qm.h +13 -7
@@ -44,9 +44,11 @@ extern struct kmem_zone *xfs_qm_dqtrxzone; typedef struct xfs_quotainfo { struct radix_tree_root qi_uquota_tree; struct radix_tree_root qi_gquota_tree; + struct radix_tree_root qi_pquota_tree; struct mutex qi_tree_lock; - xfs_inode_t *qi_uquotaip; /* user quota inode */ - xfs_inode_t *qi_gquotaip; /* group quota inode */ + struct xfs_inode *qi_uquotaip; /* user quota inode */ + struct xfs_inode *qi_gquotaip; /* group quota inode */ + struct xfs_inode *qi_pquotaip; /* project quota inode */ struct list_head qi_lru_list; struct mutex qi_lru_lock; int qi_lru_count;
@@ -78,8 +80,9 @@ xfs_dquot_tree(case XFS_DQ_USER :return &qi->qi_uquota_tree;case XFS_DQ_GROUP : -case XFS_DQ_PROJ :return &qi->qi_gquota_tree; +case XFS_DQ_PROJ : +return &qi->qi_pquota_tree;default :ASSERT (0 ); }
@@ -93,8 +96,9 @@ xfs_dq_to_quota_inode(struct xfs_dquot *dqp)case XFS_DQ_USER :return dqp->q_mount->m_quotainfo->qi_uquotaip;case XFS_DQ_GROUP : -case XFS_DQ_PROJ :return dqp->q_mount->m_quotainfo->qi_gquotaip; +case XFS_DQ_PROJ : +return dqp->q_mount->m_quotainfo->qi_pquotaip;default :ASSERT (0 ); }
@@ -107,18 +111,20 @@ extern void xfs_trans_mod_dquot(struct xfs_trans *, struct xfs_dquot *, uint, long);extern int xfs_trans_reserve_quota_bydquots (struct xfs_trans *,struct xfs_mount *,struct xfs_dquot *, -struct xfs_dquot *,long ,long ,uint ); +struct xfs_dquot *,struct xfs_dquot *, +long ,long ,uint );extern void xfs_trans_dqjoin (struct xfs_trans *,struct xfs_dquot *);extern void xfs_trans_log_dquot (struct xfs_trans *,struct xfs_dquot *);/* -* We keep the usr and grp dquots separately so that locking will be easier -* to do at commit time. All transactions that we know of at this point +* We keep the usr, grp, and prj dquots separately so that locking will be +* easier to do at commit time. All transactions that we know of at this point * affect no more than two dquots of one type. Hence, the TRANS_MAXDQS value. */ enum {XFS_QM_TRANS_USR =0 ,XFS_QM_TRANS_GRP , +XFS_QM_TRANS_PRJ ,XFS_QM_TRANS_DQTYPES };#define XFS_QM_TRANS_MAXDQS 2
fs/xfs/xfs_qm_bhv.c +5 -5
@@ -112,16 +112,16 @@ xfs_qm_newmount(if (((uquotaondisk && !XFS_IS_UQUOTA_ON (mp)) || (!uquotaondisk &&XFS_IS_UQUOTA_ON (mp)) || - (pquotaondisk && !XFS_IS_PQUOTA_ON (mp)) || - (!pquotaondisk &&XFS_IS_PQUOTA_ON (mp)) || (gquotaondisk && !XFS_IS_GQUOTA_ON (mp)) || - (!gquotaondisk &&XFS_IS_OQUOTA_ON (mp))) && + (!gquotaondisk &&XFS_IS_GQUOTA_ON (mp)) || + (pquotaondisk && !XFS_IS_PQUOTA_ON (mp)) || + (!pquotaondisk &&XFS_IS_PQUOTA_ON (mp))) &&xfs_dev_is_read_only (mp,"changing quota state" )) {xfs_warn (mp,"please mount with%s%s%s%s." , (!quotaondisk ?"out quota" :"" ), (uquotaondisk ?" usrquota" :"" ), - (pquotaondisk ?" prjquota" :"" ), - (gquotaondisk ?" grpquota" :"" )); + (gquotaondisk ?" grpquota" :"" ), + (pquotaondisk ?" prjquota" :"" ));return XFS_ERROR (EPERM ); }
fs/xfs/xfs_qm_syscalls.c +15 -4
@@ -119,7 +119,8 @@ xfs_qm_scall_quotaoff( dqtype |=XFS_QMOPT_GQUOTA ; flags |= (XFS_GQUOTA_CHKD |XFS_GQUOTA_ENFD ); inactivate_flags |=XFS_GQUOTA_ACTIVE ; - }else if (flags &XFS_PQUOTA_ACCT ) { + } +if (flags &XFS_PQUOTA_ACCT ) { dqtype |=XFS_QMOPT_PQUOTA ; flags |= (XFS_PQUOTA_CHKD |XFS_PQUOTA_ENFD ); inactivate_flags |=XFS_PQUOTA_ACTIVE ;
@@ -213,10 +214,14 @@ xfs_qm_scall_quotaoff(IRELE (q->qi_uquotaip); q->qi_uquotaip =NULL ; } -if ((dqtype & (XFS_QMOPT_GQUOTA |XFS_QMOPT_PQUOTA )) && q->qi_gquotaip) { +if ((dqtype &XFS_QMOPT_GQUOTA ) && q->qi_gquotaip) {IRELE (q->qi_gquotaip); q->qi_gquotaip =NULL ; } +if ((dqtype &XFS_QMOPT_PQUOTA ) && q->qi_pquotaip) { +IRELE (q->qi_pquotaip); + q->qi_pquotaip =NULL ; + } out_unlock:mutex_unlock (&q->qi_quotaofflock);
@@ -858,9 +863,11 @@ xfs_dqrele_inode( {/* skip quota inodes */ if (ip == ip->i_mount->m_quotainfo->qi_uquotaip || - ip == ip->i_mount->m_quotainfo->qi_gquotaip) { + ip == ip->i_mount->m_quotainfo->qi_gquotaip || + ip == ip->i_mount->m_quotainfo->qi_pquotaip) {ASSERT (ip->i_udquot ==NULL );ASSERT (ip->i_gdquot ==NULL ); +ASSERT (ip->i_pdquot ==NULL );return 0 ; }
@@ -869,10 +876,14 @@ xfs_dqrele_inode(xfs_qm_dqrele (ip->i_udquot); ip->i_udquot =NULL ; } -if (flags & (XFS_PQUOTA_ACCT |XFS_GQUOTA_ACCT ) && ip->i_gdquot) { +if ((flags &XFS_GQUOTA_ACCT ) && ip->i_gdquot) {xfs_qm_dqrele (ip->i_gdquot); ip->i_gdquot =NULL ; } +if ((flags &XFS_PQUOTA_ACCT ) && ip->i_pdquot) { +xfs_qm_dqrele (ip->i_pdquot); + ip->i_pdquot =NULL ; + }xfs_iunlock (ip,XFS_ILOCK_EXCL );return 0 ; }
fs/xfs/xfs_quota.h +18 -14
@@ -288,10 +288,10 @@ typedef struct xfs_qoff_logformat {* we didn't have the inode locked, the appropriate dquot(s) will be * attached atomically. */ -#define XFS_NOT_DQATTACHED (mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ - (ip)->i_udquot == NULL) || \ - (XFS_IS_OQUOTA_ON(mp) && \ - (ip)->i_gdquot == NULL)) +#define XFS_NOT_DQATTACHED (mp, ip) \ + ((XFS_IS_UQUOTA_ON(mp) && (ip)->i_udquot == NULL) || \ + (XFS_IS_GQUOTA_ON(mp) && (ip)->i_gdquot == NULL) || \ + (XFS_IS_PQUOTA_ON(mp) && (ip)->i_pdquot == NULL))#define XFS_QM_NEED_QUOTACHECK (mp) \ ((XFS_IS_UQUOTA_ON(mp) && \
@@ -338,17 +338,18 @@ extern int xfs_trans_reserve_quota_nblks(struct xfs_trans *, struct xfs_inode *, long, long, uint);extern int xfs_trans_reserve_quota_bydquots (struct xfs_trans *,struct xfs_mount *,struct xfs_dquot *, -struct xfs_dquot *,long ,long ,uint ); +struct xfs_dquot *,struct xfs_dquot *,long ,long ,uint );extern int xfs_qm_vop_dqalloc (struct xfs_inode *,uid_t ,gid_t ,prid_t ,uint , -struct xfs_dquot **,struct xfs_dquot **); +struct xfs_dquot **,struct xfs_dquot **,struct xfs_dquot **);extern void xfs_qm_vop_create_dqattach (struct xfs_trans *,struct xfs_inode *, -struct xfs_dquot *,struct xfs_dquot *); +struct xfs_dquot *,struct xfs_dquot *,struct xfs_dquot *);extern int xfs_qm_vop_rename_dqattach (struct xfs_inode **);extern struct xfs_dquot *xfs_qm_vop_chown (struct xfs_trans *,struct xfs_inode *,struct xfs_dquot **,struct xfs_dquot *);extern int xfs_qm_vop_chown_reserve (struct xfs_trans *,struct xfs_inode *, -struct xfs_dquot *,struct xfs_dquot *,uint ); +struct xfs_dquot *,struct xfs_dquot *, +struct xfs_dquot *,uint );extern int xfs_qm_dqattach (struct xfs_inode *,uint );extern int xfs_qm_dqattach_locked (struct xfs_inode *,uint );extern void xfs_qm_dqdetach (struct xfs_inode *);
@@ -362,10 +363,12 @@ extern void xfs_qm_unmount_quotas(struct xfs_mount *);#else static inline int xfs_qm_vop_dqalloc (struct xfs_inode *ip,uid_t uid,gid_t gid,prid_t prid, -uint flags,struct xfs_dquot **udqp,struct xfs_dquot **gdqp) +uint flags,struct xfs_dquot **udqp,struct xfs_dquot **gdqp, +struct xfs_dquot **pdqp) { *udqp =NULL ; *gdqp =NULL ; + *pdqp =NULL ;return 0 ; }#define xfs_trans_dup_dqinfo (tp, tp2)
@@ -380,14 +383,15 @@ static inline int xfs_trans_reserve_quota_nblks(struct xfs_trans *tp, }static inline int xfs_trans_reserve_quota_bydquots (struct xfs_trans *tp,struct xfs_mount *mp,struct xfs_dquot *udqp, -struct xfs_dquot *gdqp,long nblks,long nions,uint flags) +struct xfs_dquot *gdqp,struct xfs_dquot *pdqp, +long nblks,long nions,uint flags) {return 0 ; } -#define xfs_qm_vop_create_dqattach (tp, ip, u, g) +#define xfs_qm_vop_create_dqattach (tp, ip, u, g, p)#define xfs_qm_vop_rename_dqattach (it) (0)#define xfs_qm_vop_chown (tp, ip, old, new) (NULL) -#define xfs_qm_vop_chown_reserve (tp, ip, u, g, fl) (0) +#define xfs_qm_vop_chown_reserve (tp, ip, u, g, p, fl) (0)#define xfs_qm_dqattach (ip, fl) (0)#define xfs_qm_dqattach_locked (ip, fl) (0)#define xfs_qm_dqdetach (ip)
@@ -401,8 +405,8 @@ static inline int xfs_trans_reserve_quota_bydquots(struct xfs_trans *tp,#define xfs_trans_unreserve_quota_nblks (tp, ip, nblks, ninos, flags) \ xfs_trans_reserve_quota_nblks(tp, ip, -(nblks), -(ninos), flags) -#define xfs_trans_reserve_quota (tp, mp, ud, gd, nb, ni, f) \ - xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, nb, ni, \ +#define xfs_trans_reserve_quota (tp, mp, ud, gd, pd, nb, ni, f) \ + xfs_trans_reserve_quota_bydquots(tp, mp, ud, gd, pd, nb, ni, \ f | XFS_QMOPT_RES_REGBLKS) extern int xfs_qm_dqcheck(struct xfs_mount *, xfs_disk_dquot_t *,
fs/xfs/xfs_symlink.c +7 -3
@@ -360,6 +360,7 @@ xfs_symlink(prid_t prid;struct xfs_dquot *udqp =NULL ;struct xfs_dquot *gdqp =NULL ; +struct xfs_dquot *pdqp =NULL ;uint resblks; *ipp =NULL ;
@@ -386,7 +387,7 @@ xfs_symlink(* Make sure that we have allocated dquot(s) on disk. */ error =xfs_qm_vop_dqalloc (dp,current_fsuid (),current_fsgid (), prid, -XFS_QMOPT_QUOTALL |XFS_QMOPT_INHERIT , &udqp, &gdqp); +XFS_QMOPT_QUOTALL |XFS_QMOPT_INHERIT , &udqp, &gdqp, &pdqp);if (error) goto std_return;
@@ -427,7 +428,8 @@ xfs_symlink(/* * Reserve disk quota : blocks and inode. */ - error =xfs_trans_reserve_quota (tp, mp, udqp, gdqp, resblks,1 ,0 ); + error =xfs_trans_reserve_quota (tp, mp, udqp, gdqp, + pdqp, resblks,1 ,0 );if (error) goto error_return;
@@ -465,7 +467,7 @@ xfs_symlink(/* * Also attach the dquot(s) to it, if applicable. */ -xfs_qm_vop_create_dqattach (tp, ip, udqp, gdqp); +xfs_qm_vop_create_dqattach (tp, ip, udqp, gdqp, pdqp);if (resblks) resblks -=XFS_IALLOC_SPACE_RES (mp);
@@ -563,6 +565,7 @@ xfs_symlink( error =xfs_trans_commit (tp,XFS_TRANS_RELEASE_LOG_RES );xfs_qm_dqrele (udqp);xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp); *ipp = ip;return 0 ;
@@ -576,6 +579,7 @@ xfs_symlink(xfs_trans_cancel (tp, cancel_flags);xfs_qm_dqrele (udqp);xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp);if (unlock_dp_on_error)xfs_iunlock (dp,XFS_ILOCK_EXCL );
fs/xfs/xfs_trans_dquot.c +22 -4
@@ -163,8 +163,10 @@ xfs_trans_mod_dquot_byino(if (XFS_IS_UQUOTA_ON (mp) && ip->i_udquot) (void )xfs_trans_mod_dquot (tp, ip->i_udquot, field, delta); -if (XFS_IS_OQUOTA_ON (mp) && ip->i_gdquot) +if (XFS_IS_GQUOTA_ON (mp) && ip->i_gdquot) (void )xfs_trans_mod_dquot (tp, ip->i_gdquot, field, delta); +if (XFS_IS_PQUOTA_ON (mp) && ip->i_pdquot) + (void )xfs_trans_mod_dquot (tp, ip->i_pdquot, field, delta); } STATIC struct xfs_dqtrx *
@@ -177,8 +179,12 @@ xfs_trans_get_dqtrx(if (XFS_QM_ISUDQ (dqp)) qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_USR ]; -else +else if (XFS_QM_ISGDQ (dqp)) qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_GRP ]; +else if (XFS_QM_ISPDQ (dqp)) + qa = tp->t_dqinfo->dqs[XFS_QM_TRANS_PRJ ]; +else +return NULL ;for (i =0 ; i <XFS_QM_TRANS_MAXDQS ; i++) { if (qa[i].qt_dquot == NULL ||
@@ -727,8 +733,8 @@ error_return:/* * Given dquot(s), make disk block and/or inode reservations against them. -* The fact that this does the reservation against both the usr and -* grp/prj quotas is important, because this follows a both-or-nothing +* The fact that this does the reservation against user, group and +* project quotas is important, because this follows a all-or-nothing * approach. * * flags = XFS_QMOPT_FORCE_RES evades limit enforcement. Used by chown.
@@ -743,6 +749,7 @@ xfs_trans_reserve_quota_bydquots(struct xfs_mount *mp, struct xfs_dquot *udqp, struct xfs_dquot *gdqp, + struct xfs_dquot *pdqp, long nblks, long ninos, uint flags)
@@ -770,11 +777,21 @@ xfs_trans_reserve_quota_bydquots( goto unwind_usr; } +if (pdqp) { + error =xfs_trans_dqresv (tp, mp, pdqp, nblks, ninos, flags); +if (error) + goto unwind_grp; + } +/* * Didn't change anything critical, so, no need to log */ return 0 ; +unwind_grp: + flags |=XFS_QMOPT_FORCE_RES ; +if (gdqp) +xfs_trans_dqresv (tp, mp, gdqp, -nblks, -ninos, flags); unwind_usr: flags |=XFS_QMOPT_FORCE_RES ;if (udqp)
@@ -816,6 +833,7 @@ xfs_trans_reserve_quota_nblks(*/ return xfs_trans_reserve_quota_bydquots (tp, mp, ip->i_udquot, ip->i_gdquot, + ip->i_pdquot, nblks, ninos, flags); }
fs/xfs/xfs_vnodeops.c +9 -4
@@ -489,6 +489,7 @@ xfs_create(prid_t prid;struct xfs_dquot *udqp =NULL ;struct xfs_dquot *gdqp =NULL ; +struct xfs_dquot *pdqp =NULL ;uint resblks;uint log_res;uint log_count;
@@ -507,7 +508,8 @@ xfs_create(* Make sure that we have allocated dquot(s) on disk. */ error =xfs_qm_vop_dqalloc (dp,current_fsuid (),current_fsgid (), prid, -XFS_QMOPT_QUOTALL |XFS_QMOPT_INHERIT , &udqp, &gdqp); +XFS_QMOPT_QUOTALL |XFS_QMOPT_INHERIT , + &udqp, &gdqp, &pdqp);if (error)return error;
@@ -559,7 +561,8 @@ xfs_create(/* * Reserve disk quota and the inode. */ - error =xfs_trans_reserve_quota (tp, mp, udqp, gdqp, resblks,1 ,0 ); + error =xfs_trans_reserve_quota (tp, mp, udqp, gdqp, + pdqp, resblks,1 ,0 );if (error) goto out_trans_cancel;
@@ -623,7 +626,7 @@ xfs_create(* These ids of the inode couldn't have changed since the new * inode has been locked ever since it was created. */ -xfs_qm_vop_create_dqattach (tp, ip, udqp, gdqp); +xfs_qm_vop_create_dqattach (tp, ip, udqp, gdqp, pdqp); error =xfs_bmap_finish (&tp, &free_list, &committed);if (error)
@@ -635,6 +638,7 @@ xfs_create(xfs_qm_dqrele (udqp);xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp); *ipp = ip;return 0 ;
@@ -656,6 +660,7 @@ xfs_create(xfs_qm_dqrele (udqp);xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp);if (unlock_dp_on_error)xfs_iunlock (dp,XFS_ILOCK_EXCL );
@@ -1568,7 +1573,7 @@ xfs_free_file_space( }xfs_ilock (ip,XFS_ILOCK_EXCL ); error =xfs_trans_reserve_quota (tp, mp, - ip->i_udquot, ip->i_gdquot, + ip->i_udquot, ip->i_gdquot, ip->i_pdquot, resblks,0 ,XFS_QMOPT_RES_REGBLKS );if (error) goto error1;
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 1/4] xfs: Add pquota fields where gquota is used.
Quoted 10 lines · Chandra Seetharaman
Add project quota changes to all the places where group quota field is used:
* add separate project quota members into various structures
* split project quota and group quotas so that instead of overriding the group quota members incore, the new project quota members are used instead
* get rid of usage of the OQUOTA flag incore, in favor of separate group and project quota flags.
* add a project dquot argument to various functions.
Quoted 3 lines
Not using the pquotino field from superblock yet.
Signed-off-by Chandra Seetharaman <[email protected]>
Looks good. Applied.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v11 2/4 xfs: Start using pquotaino from the superblock.
In reply to Chandra SeetharamanStart using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
--- fs/xfs/xfs_mount.c | 62 ++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_qm.c | 28 +++++++++-------- fs/xfs/xfs_qm_syscalls.c | 21 +++++++++++++- fs/xfs/xfs_sb.h | 9 +++++- fs/xfs/xfs_super.c | 19 ++++++------ include/uapi/linux/dqblk_xfs.h | 1 + 6 files changed, 108 insertions(+), 32 deletions(-)
fs/xfs/xfs_mount.c +54 -8
@@ -336,12 +336,17 @@ xfs_mount_validate_sb(return XFS_ERROR (EWRONGFS ); } -if ((sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && - (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | -XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD ))) { -xfs_notice (mp, -"Super block has XFS_OQUOTA bits along with XFS_PQUOTA and/or XFS_GQUOTA bits.\n" ); -return XFS_ERROR (EFSCORRUPTED ); +if (xfs_sb_version_has_pquota (sbp)) { +if (sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) { +xfs_notice (mp, +"Version 5 of Super block has XFS_OQUOTA bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + } + }else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | +XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) { +xfs_notice (mp, +"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); }/*
@@ -570,8 +575,13 @@ out_unwind: }static void -xfs_sb_quota_from_disk (struct xfs_sb *sbp) +xfs_sb_quota_from_disk (struct xfs_mount *mp) { +struct xfs_sb *sbp = &mp->m_sb; + +if (xfs_sb_version_has_pquota (sbp)) +return ; +if (sbp->sb_qflags &XFS_OQUOTA_ENFD ) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ;
@@ -579,6 +589,18 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + +if (!xfs_sb_version_has_pquota (sbp) && (XFS_IS_PQUOTA_ON (mp))) { +/* +* On disk superblock only has sb_gquotino, and incore +* superblock has both sb_gquotino and sb_pquotino. +* But, only one them is supported at any point of time. +* So, if PQUOTA is set in disk superblock, copy over +* sb_gquotino to sb_pquotino. +*/ + mp->m_sb.sb_pquotino = mp->m_sb.sb_gquotino; + mp->m_sb.sb_gquotino =NULLFSINO ; + } }void
@@ -650,6 +672,13 @@ xfs_sb_quota_to_disk( {__uint16_t qflags = from->sb_qflags; +/* +* We need to do these manipilations only if we are working +* with an older version of on-disk superblock. +*/ +if (xfs_sb_version_has_pquota (from)) +return ; +if (*fields &XFS_SB_QFLAGS ) {/* * The in-core version of sb_qflags do not have
@@ -669,6 +698,23 @@ xfs_sb_quota_to_disk( to->sb_qflags =cpu_to_be16 (qflags); *fields &= ~XFS_SB_QFLAGS ; } + +if (*fields &XFS_SB_PQUOTINO && *fields &XFS_SB_GQUOTINO ) { +/* +* PQUOTINO and GQUOTINO cannot be used together in versions +* of superblock that do not have pquotino. If used, use +* sb_flags to resolve which one should be set. +*/ +if (from->sb_qflags &XFS_PQUOTA_ACCT ) + *fields &= ~XFS_SB_GQUOTINO ; +else + *fields &= ~XFS_SB_PQUOTINO ; + } + +if (*fields &XFS_SB_PQUOTINO ) { + to->sb_gquotino =cpu_to_be64 (from->sb_pquotino); + *fields &= ~XFS_SB_PQUOTINO ; + } }/*
@@ -885,7 +931,7 @@ reread:*/ xfs_sb_from_disk (&mp->m_sb,XFS_BUF_TO_SBP (bp)); -xfs_sb_quota_from_disk (&mp->m_sb); +xfs_sb_quota_from_disk (mp);/* * We must be able to do sector-sized and sector-aligned IO. */
fs/xfs/xfs_qm.c +15 -13
@@ -860,21 +860,24 @@ xfs_qm_qino_alloc(if (flags &XFS_QMOPT_SBVERSION ) {ASSERT (!xfs_sb_version_hasquota (&mp->m_sb));ASSERT ((sbfields & (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS )) == - (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS )); +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO |XFS_SB_QFLAGS )) == + (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO |XFS_SB_QFLAGS ));xfs_sb_version_addquota (&mp->m_sb); mp->m_sb.sb_uquotino =NULLFSINO ; mp->m_sb.sb_gquotino =NULLFSINO ; + mp->m_sb.sb_pquotino =NULLFSINO ; -/* qflags will get updated _after_ quotacheck */ - mp->m_sb.sb_qflags =0 ; +/* qflags will get updated fully _after_ quotacheck */ + mp->m_sb.sb_qflags = mp->m_qflags &XFS_ALL_QUOTA_ACCT ; }if (flags &XFS_QMOPT_UQUOTA ) mp->m_sb.sb_uquotino = (*ip)->i_ino; -else +else if (flags &XFS_QMOPT_GQUOTA ) mp->m_sb.sb_gquotino = (*ip)->i_ino; +else + mp->m_sb.sb_pquotino = (*ip)->i_ino;spin_unlock (&mp->m_sb_lock);xfs_mod_sb (tp, sbfields);
@@ -1484,11 +1487,10 @@ xfs_qm_init_quotainos(if (error) goto error_rele; } -/* XXX: Use gquotino for now */ if (XFS_IS_PQUOTA_ON (mp) && - mp->m_sb.sb_gquotino !=NULLFSINO ) { -ASSERT (mp->m_sb.sb_gquotino >0 ); - error =xfs_iget (mp,NULL , mp->m_sb.sb_gquotino, + mp->m_sb.sb_pquotino !=NULLFSINO ) { +ASSERT (mp->m_sb.sb_pquotino >0 ); + error =xfs_iget (mp,NULL , mp->m_sb.sb_pquotino,0 ,0 , &pip);if (error) goto error_rele;
@@ -1496,7 +1498,8 @@ xfs_qm_init_quotainos( }else { flags |=XFS_QMOPT_SBVERSION ; sbflags |= (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS ); +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO | +XFS_SB_QFLAGS ); }/*
@@ -1524,9 +1527,8 @@ xfs_qm_init_quotainos( flags &= ~XFS_QMOPT_SBVERSION ; }if (XFS_IS_PQUOTA_ON (mp) && pip ==NULL ) { -/* XXX: Use XFS_SB_GQUOTINO for now */ error =xfs_qm_qino_alloc (mp, &pip, - sbflags |XFS_SB_GQUOTINO , + sbflags |XFS_SB_PQUOTINO , flags |XFS_QMOPT_PQUOTA );if (error) goto error_rele;
fs/xfs/xfs_qm_syscalls.c +20 -1
@@ -296,8 +296,10 @@ xfs_qm_scall_trunc_qfiles(if (flags &XFS_DQ_USER ) error =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_uquotino); -if (flags & (XFS_DQ_GROUP |XFS_DQ_PROJ )) +if (flags &XFS_DQ_GROUP ) error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_gquotino); +if (flags &XFS_DQ_PROJ ) + error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_pquotino);return error ? error : error2; }
@@ -413,8 +415,10 @@ xfs_qm_scall_getqstat(struct xfs_quotainfo *q = mp->m_quotainfo;struct xfs_inode *uip =NULL ;struct xfs_inode *gip =NULL ; +struct xfs_inode *pip =NULL ;bool tempuqip = false;bool tempgqip = false; +bool temppqip = false;memset (out,0 ,sizeof (fs_quota_stat_t));
@@ -422,6 +426,7 @@ xfs_qm_scall_getqstat(if (!xfs_sb_version_hasquota (&mp->m_sb)) { out->qs_uquota.qfs_ino =NULLFSINO ; out->qs_gquota.qfs_ino =NULLFSINO ; + out->qs_pquota.qfs_ino =NULLFSINO ;return (0 ); } out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags &
@@ -430,10 +435,13 @@ xfs_qm_scall_getqstat( out->qs_pad =0 ; out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; +if (&out->qs_gquota != &out->qs_pquota) + out->qs_pquota.qfs_ino = mp->m_sb.sb_pquotino;if (q) { uip = q->qi_uquotaip; gip = q->qi_gquotaip; + pip = q->qi_pquotaip; }if (!uip && mp->m_sb.sb_uquotino !=NULLFSINO ) { if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
@@ -445,6 +453,11 @@ xfs_qm_scall_getqstat( 0, 0, &gip) == 0) tempgqip = true; } +if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { +if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, +0 ,0 , &pip) ==0 ) + temppqip = true; + }if (uip) { out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; out->qs_uquota.qfs_nextents = uip->i_d.di_nextents;
@@ -457,6 +470,12 @@ xfs_qm_scall_getqstat(if (tempgqip)IRELE (gip); } +if (pip) { + out->qs_pquota.qfs_nblks = pip->i_d.di_nblocks; + out->qs_pquota.qfs_nextents = pip->i_d.di_nextents; +if (temppqip) +IRELE (pip); + }if (q) { out->qs_incoredqs = q->qi_dquots; out->qs_btimelimit = q->qi_btimelimit;
fs/xfs/xfs_sb.h +8 -1
@@ -621,7 +621,14 @@ xfs_sb_has_incompat_log_feature(static inline bool xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) { -return (ino == sbp->sb_uquotino || ino == sbp->sb_gquotino); +return (ino == sbp->sb_uquotino || + ino == sbp->sb_gquotino || + ino == sbp->sb_pquotino); +} + +static inline int xfs_sb_version_has_pquota (xfs_sb_t *sbp) +{ +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; }/*
fs/xfs/xfs_super.c +10 -9
@@ -421,12 +421,6 @@ xfs_parseargs( }#endif -if ((mp->m_qflags & (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE )) && - (mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE ))) { -xfs_warn (mp,"cannot mount with both project and group quota" ); -return EINVAL ; - } -if ((dsunit && !dswidth) || (!dsunit && dswidth)) {xfs_warn (mp,"sunit and swidth must be specified together" );return EINVAL ;
@@ -556,14 +550,13 @@ xfs_showargs(else if (mp->m_qflags &XFS_UQUOTA_ACCT )seq_puts (m,"," MNTOPT_UQUOTANOENF ); -/* Either project or group quotas can be active, not both */ -if (mp->m_qflags &XFS_PQUOTA_ACCT ) {if (mp->m_qflags &XFS_PQUOTA_ENFD )seq_puts (m,"," MNTOPT_PRJQUOTA );else seq_puts (m,"," MNTOPT_PQUOTANOENF ); - }else if (mp->m_qflags &XFS_GQUOTA_ACCT ) { + } +if (mp->m_qflags &XFS_GQUOTA_ACCT ) {if (mp->m_qflags &XFS_GQUOTA_ENFD )seq_puts (m,"," MNTOPT_GRPQUOTA );else
@@ -1396,6 +1389,14 @@ xfs_finish_flags(return XFS_ERROR (EROFS ); } +if ((mp->m_qflags & (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE )) && + (mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE )) && + !xfs_sb_version_has_pquota (&mp->m_sb)) { +xfs_warn (mp, +"Super block does not support project and group quota together" ); +return XFS_ERROR (EINVAL ); + } +return 0 ; }
include/uapi/linux/dqblk_xfs.h +1 -0
@@ -155,6 +155,7 @@ typedef struct fs_quota_stat {__s8 qs_pad;/* unused */ fs_qfilestat_t qs_uquota;/* user quota storage information */ fs_qfilestat_t qs_gquota;/* group quota storage information */ +#define qs_pquota qs_gquota__u32 qs_incoredqs;/* number of dquots incore */ __s32 qs_btimelimit;/* limit for blks timer */ __s32 qs_itimelimit;/* limit for inodes timer */
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 2/4] xfs: Start using pquotaino from the superblock.
Quoted 32 lines · Chandra Seetharaman
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
Signed-off-by Chandra Seetharaman <[email protected]>--- fs/xfs/xfs_mount.c | 62 ++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_qm.c | 28 +++++++++-------- fs/xfs/xfs_qm_syscalls.c | 21 +++++++++++++- fs/xfs/xfs_sb.h | 9 +++++- fs/xfs/xfs_super.c | 19 ++++++------ include/uapi/linux/dqblk_xfs.h | 1 + 6 files changed, 108 insertions(+), 32 deletions(-)fs/xfs/xfs_mount.c +2
-6@@ -336,12 +336,17 @@ xfs_mount_validate_sb(return XFS_ERROR (EWRONGFS ); } -if ((sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && - (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | -XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD ))) { -xfs_notice (mp, -"Super block has XFS_OQUOTA bits along with XFS_PQUOTA and/or XFS_GQUOTA bits.\n" ); -return XFS_ERROR (EFSCORRUPTED ); +if (xfs_sb_version_has_pquota (sbp)) { +if (sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) {
fs/xfs/xfs_mount.c xfs_mount_validate_sb( · line 350
Quoted 10 lines
fs/xfs/xfs_mount.c +9
-0+xfs_notice (mp, +"Version 5 of Super block has XFS_OQUOTA bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + } + }else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | +XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) { +xfs_notice (mp, +"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); }
Can you move this to after we've checked the 5 superblock feature masks for whether the kernel supports the various features the superblock defines - feature support checks need to come before checking superblock fields for validity....
Quoted 22 lines
fs/xfs/xfs_mount.c +9
-1@@ -570,8 +575,13 @@ out_unwind: }static void -xfs_sb_quota_from_disk (struct xfs_sb *sbp) +xfs_sb_quota_from_disk (struct xfs_mount *mp) { +struct xfs_sb *sbp = &mp->m_sb; + +if (xfs_sb_version_has_pquota (sbp)) +return ; +if (sbp->sb_qflags &XFS_OQUOTA_ENFD ) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ;@@ -579,6 +589,18 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + +if (!xfs_sb_version_has_pquota (sbp) && (XFS_IS_PQUOTA_ON (mp))) { +/*
fs/xfs/xfs_mount.c xfs_sb_quota_from_disk(struct xfs_sb *sbp) · line 604
Quoted 10 lines
fs/xfs/xfs_mount.c +9
-0+* On disk superblock only has sb_gquotino, and incore +* superblock has both sb_gquotino and sb_pquotino. +* But, only one them is supported at any point of time. +* So, if PQUOTA is set in disk superblock, copy over +* sb_gquotino to sb_pquotino. +*/ + mp->m_sb.sb_pquotino = mp->m_sb.sb_gquotino; + mp->m_sb.sb_gquotino =NULLFSINO ; + } }
Why is this using mp rather than sbp? Indeed, this should be passed the superblock as a parameter (as per the previous version of the code) as the superblock we are writing into is determined by the caller. e.g. what if we want to do this conversion in xfs_sb_verify() and are using the on-stack struct xfs_sb?
Also, why should a mount option determine how we interpret the on-disk format? i.e. the XFS_IS_PQUOTA_ON() check? The superblock itself describes which quota the sb_gquotino contains (i.e. what is in from->sb_qflags) and that alone determines which field the on-disk inode gets copied into.
If the mount options then don't line up with what is in the superblock, then the quota mount checks will handle that appropriately.
Quoted 17 lines
fs/xfs/xfs_mount.c +7
-0void @@ -650,6 +672,13 @@ xfs_sb_quota_to_disk( {__uint16_t qflags = from->sb_qflags; +/* +* We need to do these manipilations only if we are working +* with an older version of on-disk superblock. +*/ +if (xfs_sb_version_has_pquota (from)) +return ; +if (*fields &XFS_SB_QFLAGS ) {/* * The in-core version of sb_qflags do not have
fs/xfs/xfs_mount.c xfs_sb_quota_to_disk( · line 702
Quoted 5 lines
fs/xfs/xfs_mount.c +2
-0@@ -669,6 +698,23 @@ xfs_sb_quota_to_disk( to->sb_qflags =cpu_to_be16 (qflags); *fields &= ~XFS_SB_QFLAGS ; } + +if (*fields &XFS_SB_PQUOTINO && *fields &XFS_SB_GQUOTINO ) {
gcc will throw warnings on that code. The normal way of checking multiple flag fields is:
if ((*fields & (XFS_SB_PQUOTINO|XFS_SB_GQUOTINO)) ==
(XFS_SB_PQUOTINO|XFS_SB_GQUOTINO)) {Quoted 5 lines
fs/xfs/xfs_mount.c +5
-0+/* +* PQUOTINO and GQUOTINO cannot be used together in versions +* of superblock that do not have pquotino. If used, use +* sb_flags to resolve which one should be set. +*/
fs/xfs/xfs_mount.c xfs_sb_quota_to_disk( · line 717
Quoted 10 lines
fs/xfs/xfs_mount.c +10
-0+if (from->sb_qflags &XFS_PQUOTA_ACCT ) + *fields &= ~XFS_SB_GQUOTINO ; +else + *fields &= ~XFS_SB_PQUOTINO ; + } + +if (*fields &XFS_SB_PQUOTINO ) { + to->sb_gquotino =cpu_to_be64 (from->sb_pquotino); + *fields &= ~XFS_SB_PQUOTINO ; + }
Better yet:
/* * GQUOTINO and PQUOTINO cannot be used together in versions * of superblock that do not have pquotino. from->sb_flags * tells us which quota is active and should be copied to * disk. */ if ((*fields & XFS_SB_GQUOTINO) && (from->sb_qflags & XFS_GQUOTA_ACCT)) to->sb_gquotino = cpu_to_be64(from->sb_gquotino); else if ((*fields & XFS_SB_PQUOTINO) && (from->sb_qflags & XFS_PQUOTA_ACCT)) to->sb_gquotino = cpu_to_be64(from->sb_pquotino); *fields &= ~(XFS_SB_PQUOTINO | XFS_SB_GQUOTINO);
fs/xfs/xfs_mount.c reread: · line 934
Quoted 9 lines
fs/xfs/xfs_mount.c +1
-1}/* @@ -885,7 +931,7 @@ reread:*/ xfs_sb_from_disk (&mp->m_sb,XFS_BUF_TO_SBP (bp)); -xfs_sb_quota_from_disk (&mp->m_sb); +xfs_sb_quota_from_disk (mp);
As I commented above, we need to pass the superblock separately.
fs/xfs/xfs_sb.h xfs_sb_has_incompat_log_feature( · line 627
Quoted 13 lines
fs/xfs/xfs_sb.h +4
-1@@ -621,7 +621,14 @@ xfs_sb_has_incompat_log_feature(static inline bool xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) { -return (ino == sbp->sb_uquotino || ino == sbp->sb_gquotino); +return (ino == sbp->sb_uquotino || + ino == sbp->sb_gquotino || + ino == sbp->sb_pquotino); +}
Can you move this function down below the comment in xfs_sb.h that says:
/*
* end of superblock version macros
*/
fs/xfs/xfs_sb.h xfs_sb_has_incompat_log_feature( · line 632
Quoted 5 lines
fs/xfs/xfs_sb.h +4
-0+ +static inline int xfs_sb_version_has_pquota (xfs_sb_t *sbp) +{ +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; }
And leave this above it?
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 2/4] xfs: Start using pquotaino from the superblock.
In reply to Chandra SeetharamanHey Chandra,
Quoted 7 lines · Chandra Seetharaman
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
Signed-off-by Chandra Seetharaman <[email protected]>
Here are a few notes from my review.
Quoted 14 lines
--- fs/xfs/xfs_mount.c | 62 ++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_qm.c | 28 +++++++++-------- fs/xfs/xfs_qm_syscalls.c | 21 +++++++++++++- fs/xfs/xfs_sb.h | 9 +++++- fs/xfs/xfs_super.c | 19 ++++++------ include/uapi/linux/dqblk_xfs.h | 1 + 6 files changed, 108 insertions(+), 32 deletions(-)fs/xfs/xfs_mount.c +0
-0
fs/xfs/xfs_mount.c xfs_mount_validate_sb( · line 339
Quoted 10 lines
fs/xfs/xfs_mount.c +1
-6@@ -336,12 +336,17 @@ xfs_mount_validate_sb(return XFS_ERROR (EWRONGFS ); } -if ((sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && - (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | -XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD ))) { -xfs_notice (mp, -"Super block has XFS_OQUOTA bits along with XFS_PQUOTA and/or XFS_GQUOTA bits.\n" ); -return XFS_ERROR (EFSCORRUPTED ); +if (xfs_sb_version_has_pquota (sbp)) {
xfs_sb_version_has_pquotino might be a better name for this.
fs/xfs/xfs_mount.c xfs_mount_validate_sb( · line 344
Quoted 5 lines
fs/xfs/xfs_mount.c +5
-0+if (sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) { +xfs_notice (mp, +"Version 5 of Super block has XFS_OQUOTA bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + }
If I'm reading that right... Now if you had a v5 super block with oquota bits it will become unmountable. Could that happen if you were using crcs and quotas with a 3.10 kernel and then upgrade?
Quoted 24 lines
fs/xfs/xfs_mount.c +11
-1+ }else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | +XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) { +xfs_notice (mp, +"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); }/* @@ -570,8 +575,13 @@ out_unwind: }static void -xfs_sb_quota_from_disk (struct xfs_sb *sbp) +xfs_sb_quota_from_disk (struct xfs_mount *mp) { +struct xfs_sb *sbp = &mp->m_sb; + +if (xfs_sb_version_has_pquota (sbp)) +return ; +if (sbp->sb_qflags &XFS_OQUOTA_ENFD ) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ;
fs/xfs/xfs_mount.c xfs_sb_quota_from_disk(struct xfs_sb *sbp) · line 593
Quoted 5 lines
fs/xfs/xfs_mount.c +2
-0@@ -579,6 +589,18 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + +if (!xfs_sb_version_has_pquota (sbp) && (XFS_IS_PQUOTA_ON (mp))) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I think you already checked for that up above.
fs/xfs/xfs_mount.c xfs_sb_quota_from_disk(struct xfs_sb *sbp) · line 597
Quoted 4 lines
fs/xfs/xfs_mount.c +4
-0+/* +* On disk superblock only has sb_gquotino, and incore +* superblock has both sb_gquotino and sb_pquotino. +* But, only one them is supported at any point of time.
only one of them
Quoted 61 lines
fs/xfs/xfs_mount.c +31
-1+* So, if PQUOTA is set in disk superblock, copy over +* sb_gquotino to sb_pquotino. +*/ + mp->m_sb.sb_pquotino = mp->m_sb.sb_gquotino; + mp->m_sb.sb_gquotino =NULLFSINO ; + } }void @@ -650,6 +672,13 @@ xfs_sb_quota_to_disk( {__uint16_t qflags = from->sb_qflags; +/* +* We need to do these manipilations only if we are working +* with an older version of on-disk superblock. +*/ +if (xfs_sb_version_has_pquota (from)) +return ; +if (*fields &XFS_SB_QFLAGS ) {/* * The in-core version of sb_qflags do not have @@ -669,6 +698,23 @@ xfs_sb_quota_to_disk( to->sb_qflags =cpu_to_be16 (qflags); *fields &= ~XFS_SB_QFLAGS ; } + +if (*fields &XFS_SB_PQUOTINO && *fields &XFS_SB_GQUOTINO ) { +/* +* PQUOTINO and GQUOTINO cannot be used together in versions +* of superblock that do not have pquotino. If used, use +* sb_flags to resolve which one should be set. +*/ +if (from->sb_qflags &XFS_PQUOTA_ACCT ) + *fields &= ~XFS_SB_GQUOTINO ; +else + *fields &= ~XFS_SB_PQUOTINO ; + } + +if (*fields &XFS_SB_PQUOTINO ) { + to->sb_gquotino =cpu_to_be64 (from->sb_pquotino); + *fields &= ~XFS_SB_PQUOTINO ; + } }/* @@ -885,7 +931,7 @@ reread:*/ xfs_sb_from_disk (&mp->m_sb,XFS_BUF_TO_SBP (bp)); -xfs_sb_quota_from_disk (&mp->m_sb); +xfs_sb_quota_from_disk (mp);/* * We must be able to do sector-sized and sector-aligned IO. */ fs/xfs/xfs_qm.c +0
-0
fs/xfs/xfs_qm.c xfs_qm_qino_alloc( · line 865
Quoted 9 lines
fs/xfs/xfs_qm.c +3
-3@@ -860,21 +860,24 @@ xfs_qm_qino_alloc(if (flags &XFS_QMOPT_SBVERSION ) {ASSERT (!xfs_sb_version_hasquota (&mp->m_sb));ASSERT ((sbfields & (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS )) == - (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS )); +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO |XFS_SB_QFLAGS )) == + (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO |XFS_SB_QFLAGS ));
^^^^^^^^^^^^^^^^
Looks like some unwanted spaces in there.
fs/xfs/xfs_qm.c xfs_qm_qino_alloc( · line 873
Quoted 9 lines
fs/xfs/xfs_qm.c +3
-2xfs_sb_version_addquota (&mp->m_sb); mp->m_sb.sb_uquotino =NULLFSINO ; mp->m_sb.sb_gquotino =NULLFSINO ; + mp->m_sb.sb_pquotino =NULLFSINO ; -/* qflags will get updated _after_ quotacheck */ - mp->m_sb.sb_qflags =0 ; +/* qflags will get updated fully _after_ quotacheck */ + mp->m_sb.sb_qflags = mp->m_qflags &XFS_ALL_QUOTA_ACCT ;
I didn't quite catch why you changed from 0 to ALL_QUOTA_ACCT here, will take another look.
fs/xfs/xfs_qm_syscalls.c xfs_qm_scall_getqstat(
Quoted 64 lines
fs/xfs/xfs_qm.c +9
-8}if (flags &XFS_QMOPT_UQUOTA ) mp->m_sb.sb_uquotino = (*ip)->i_ino; -else +else if (flags &XFS_QMOPT_GQUOTA ) mp->m_sb.sb_gquotino = (*ip)->i_ino; +else + mp->m_sb.sb_pquotino = (*ip)->i_ino;spin_unlock (&mp->m_sb_lock);xfs_mod_sb (tp, sbfields);@@ -1484,11 +1487,10 @@ xfs_qm_init_quotainos(if (error) goto error_rele; } -/* XXX: Use gquotino for now */ if (XFS_IS_PQUOTA_ON (mp) && - mp->m_sb.sb_gquotino !=NULLFSINO ) { -ASSERT (mp->m_sb.sb_gquotino >0 ); - error =xfs_iget (mp,NULL , mp->m_sb.sb_gquotino, + mp->m_sb.sb_pquotino !=NULLFSINO ) { +ASSERT (mp->m_sb.sb_pquotino >0 ); + error =xfs_iget (mp,NULL , mp->m_sb.sb_pquotino,0 ,0 , &pip);if (error) goto error_rele;@@ -1496,7 +1498,8 @@ xfs_qm_init_quotainos( }else { flags |=XFS_QMOPT_SBVERSION ; sbflags |= (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS ); +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO | +XFS_SB_QFLAGS ); }/* @@ -1524,9 +1527,8 @@ xfs_qm_init_quotainos( flags &= ~XFS_QMOPT_SBVERSION ; }if (XFS_IS_PQUOTA_ON (mp) && pip ==NULL ) { -/* XXX: Use XFS_SB_GQUOTINO for now */ error =xfs_qm_qino_alloc (mp, &pip, - sbflags |XFS_SB_GQUOTINO , + sbflags |XFS_SB_PQUOTINO , flags |XFS_QMOPT_PQUOTA );if (error) goto error_rele;fs/xfs/xfs_qm_syscalls.c +3
-1@@ -296,8 +296,10 @@ xfs_qm_scall_trunc_qfiles(if (flags &XFS_DQ_USER ) error =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_uquotino); -if (flags & (XFS_DQ_GROUP |XFS_DQ_PROJ )) +if (flags &XFS_DQ_GROUP ) error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_gquotino); +if (flags &XFS_DQ_PROJ ) + error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_pquotino);return error ? error : error2; }@@ -413,8 +415,10 @@ xfs_qm_scall_getqstat(
As we discussed on the call: Now that you've decided to write a new interface for this, you can be really light touch here in xfs_qm_scall_getqstat(). The new macro in dqblk_xfs.h can also go away.
Looking good.
Regards,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 2/4] xfs: Start using pquotaino from the superblock.
Quoted 30 lines · Ben Myers
Hey Chandra,
Quoted 7 lines · Chandra Seetharaman
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
Signed-off-by Chandra Seetharaman <[email protected]>Here are a few notes from my review.
Quoted 17 lines
--- fs/xfs/xfs_mount.c | 62 ++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_qm.c | 28 +++++++++-------- fs/xfs/xfs_qm_syscalls.c | 21 +++++++++++++- fs/xfs/xfs_sb.h | 9 +++++- fs/xfs/xfs_super.c | 19 ++++++------ include/uapi/linux/dqblk_xfs.h | 1 + 6 files changed, 108 insertions(+), 32 deletions(-)fs/xfs/xfs_mount.c +0
-0@@ -336,12 +336,17 @@ xfs_mount_validate_sb(return XFS_ERROR (EWRONGFS ); }
Quoted 9 lines
fs/xfs/xfs_mount.c xfs_mount_validate_sb( · line 339
Quoted 7 lines
fs/xfs/xfs_mount.c +1
-6-if ((sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && - (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | -XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD ))) { -xfs_notice (mp, -"Super block has XFS_OQUOTA bits along with XFS_PQUOTA and/or XFS_GQUOTA bits.\n" ); -return XFS_ERROR (EFSCORRUPTED ); +if (xfs_sb_version_has_pquota (sbp)) {
xfs_sb_version_has_pquotinomight be a better name for this.
will fix
Quoted 10 lines
fs/xfs/xfs_mount.c xfs_mount_validate_sb( · line 344
Quoted 6 lines
fs/xfs/xfs_mount.c +5
-0+if (sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) { +xfs_notice (mp, +"Version 5 of Super block has XFS_OQUOTA bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + }If I'm reading that right... Now if you had a v5 super block with oquota bits it will become unmountable. Could that happen if you were using crcs and quotas with a 3.10 kernel and then upgrade?
yes. My thinking is that v5 (with crc) is still experimental and not supported yet. Not true ?
Previously this was being fixed without failing. But, Dave suggested that this certainly would be an inconsistent state and hence need to be failed. I agreed and changed the code.
The problem you stated can be fixed by adding functionality to xfs_repair.
Quoted 32 lines
Quoted 25 lines
fs/xfs/xfs_mount.c +11
-1+ }else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | +XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) { +xfs_notice (mp, +"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); }/* @@ -570,8 +575,13 @@ out_unwind: }static void -xfs_sb_quota_from_disk (struct xfs_sb *sbp) +xfs_sb_quota_from_disk (struct xfs_mount *mp) { +struct xfs_sb *sbp = &mp->m_sb; + +if (xfs_sb_version_has_pquota (sbp)) +return ; +if (sbp->sb_qflags &XFS_OQUOTA_ENFD ) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ;fs/xfs/xfs_mount.c xfs_sb_quota_from_disk(struct xfs_sb *sbp) · line 593
Quoted 5 lines
fs/xfs/xfs_mount.c +2
-0@@ -579,6 +589,18 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + +if (!xfs_sb_version_has_pquota (sbp) && (XFS_IS_PQUOTA_ON (mp))) {^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Quoted 1 line
I think you already checked for that up above.
will fix.
Quoted 78 lines
fs/xfs/xfs_mount.c xfs_sb_quota_from_disk(struct xfs_sb *sbp) · line 597
Quoted 5 lines
fs/xfs/xfs_mount.c +4
-0+/* +* On disk superblock only has sb_gquotino, and incore +* superblock has both sb_gquotino and sb_pquotino. +* But, only one them is supported at any point of time. only one of them
Quoted 61 lines
fs/xfs/xfs_mount.c +31
-1+* So, if PQUOTA is set in disk superblock, copy over +* sb_gquotino to sb_pquotino. +*/ + mp->m_sb.sb_pquotino = mp->m_sb.sb_gquotino; + mp->m_sb.sb_gquotino =NULLFSINO ; + } }void @@ -650,6 +672,13 @@ xfs_sb_quota_to_disk( {__uint16_t qflags = from->sb_qflags; +/* +* We need to do these manipilations only if we are working +* with an older version of on-disk superblock. +*/ +if (xfs_sb_version_has_pquota (from)) +return ; +if (*fields &XFS_SB_QFLAGS ) {/* * The in-core version of sb_qflags do not have @@ -669,6 +698,23 @@ xfs_sb_quota_to_disk( to->sb_qflags =cpu_to_be16 (qflags); *fields &= ~XFS_SB_QFLAGS ; } + +if (*fields &XFS_SB_PQUOTINO && *fields &XFS_SB_GQUOTINO ) { +/* +* PQUOTINO and GQUOTINO cannot be used together in versions +* of superblock that do not have pquotino. If used, use +* sb_flags to resolve which one should be set. +*/ +if (from->sb_qflags &XFS_PQUOTA_ACCT ) + *fields &= ~XFS_SB_GQUOTINO ; +else + *fields &= ~XFS_SB_PQUOTINO ; + } + +if (*fields &XFS_SB_PQUOTINO ) { + to->sb_gquotino =cpu_to_be64 (from->sb_pquotino); + *fields &= ~XFS_SB_PQUOTINO ; + } }/* @@ -885,7 +931,7 @@ reread:*/ xfs_sb_from_disk (&mp->m_sb,XFS_BUF_TO_SBP (bp)); -xfs_sb_quota_from_disk (&mp->m_sb); +xfs_sb_quota_from_disk (mp);/* * We must be able to do sector-sized and sector-aligned IO. */ fs/xfs/xfs_qm.c +0
-0fs/xfs/xfs_qm.c xfs_qm_qino_alloc( · line 865
Quoted 9 lines
fs/xfs/xfs_qm.c +3
-3@@ -860,21 +860,24 @@ xfs_qm_qino_alloc(if (flags &XFS_QMOPT_SBVERSION ) {ASSERT (!xfs_sb_version_hasquota (&mp->m_sb));ASSERT ((sbfields & (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS )) == - (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS )); +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO |XFS_SB_QFLAGS )) == + (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO |XFS_SB_QFLAGS ));^^^^^^^^^^^^^^^^
Quoted 1 line
Looks like some unwanted spaces in there.
will fix
Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_qm.c +1
-0xfs_sb_version_addquota (&mp->m_sb); mp->m_sb.sb_uquotino =NULLFSINO ; mp->m_sb.sb_gquotino =NULLFSINO ; + mp->m_sb.sb_pquotino =NULLFSINO ;
Quoted 7 lines
fs/xfs/xfs_qm.c xfs_qm_qino_alloc( · line 873
Quoted 4 lines
fs/xfs/xfs_qm.c +2
-2-/* qflags will get updated _after_ quotacheck */ - mp->m_sb.sb_qflags =0 ; +/* qflags will get updated fully _after_ quotacheck */ + mp->m_sb.sb_qflags = mp->m_qflags &XFS_ALL_QUOTA_ACCT ;I didn't quite catch why you changed from 0 to
ALL_QUOTA_ACCThere, will take another look.
We wanted to move all (well, almost all :) the logic of managing PQUOTINO/GQUOTINO in older superblock in just the two functions xfs_sb_quota_to/from_disk(). In order to do that I had to use sb_qflags (you can see that in xfs_sb_quota_to_disk()). So, we have to have sb_qflags valid before we try to write these fields to the disk. Hence this change.
Quoted 62 lines
Quoted 62 lines
fs/xfs/xfs_qm.c +9
-8}if (flags &XFS_QMOPT_UQUOTA ) mp->m_sb.sb_uquotino = (*ip)->i_ino; -else +else if (flags &XFS_QMOPT_GQUOTA ) mp->m_sb.sb_gquotino = (*ip)->i_ino; +else + mp->m_sb.sb_pquotino = (*ip)->i_ino;spin_unlock (&mp->m_sb_lock);xfs_mod_sb (tp, sbfields);@@ -1484,11 +1487,10 @@ xfs_qm_init_quotainos(if (error) goto error_rele; } -/* XXX: Use gquotino for now */ if (XFS_IS_PQUOTA_ON (mp) && - mp->m_sb.sb_gquotino !=NULLFSINO ) { -ASSERT (mp->m_sb.sb_gquotino >0 ); - error =xfs_iget (mp,NULL , mp->m_sb.sb_gquotino, + mp->m_sb.sb_pquotino !=NULLFSINO ) { +ASSERT (mp->m_sb.sb_pquotino >0 ); + error =xfs_iget (mp,NULL , mp->m_sb.sb_pquotino,0 ,0 , &pip);if (error) goto error_rele;@@ -1496,7 +1498,8 @@ xfs_qm_init_quotainos( }else { flags |=XFS_QMOPT_SBVERSION ; sbflags |= (XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO | -XFS_SB_GQUOTINO |XFS_SB_QFLAGS ); +XFS_SB_GQUOTINO |XFS_SB_PQUOTINO | +XFS_SB_QFLAGS ); }/* @@ -1524,9 +1527,8 @@ xfs_qm_init_quotainos( flags &= ~XFS_QMOPT_SBVERSION ; }if (XFS_IS_PQUOTA_ON (mp) && pip ==NULL ) { -/* XXX: Use XFS_SB_GQUOTINO for now */ error =xfs_qm_qino_alloc (mp, &pip, - sbflags |XFS_SB_GQUOTINO , + sbflags |XFS_SB_PQUOTINO , flags |XFS_QMOPT_PQUOTA );if (error) goto error_rele;fs/xfs/xfs_qm_syscalls.c +3
-1@@ -296,8 +296,10 @@ xfs_qm_scall_trunc_qfiles(if (flags &XFS_DQ_USER ) error =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_uquotino); -if (flags & (XFS_DQ_GROUP |XFS_DQ_PROJ )) +if (flags &XFS_DQ_GROUP ) error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_gquotino); +if (flags &XFS_DQ_PROJ ) + error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_pquotino);
Quoted 7 lines
fs/xfs/xfs_qm_syscalls.c xfs_qm_scall_getqstat(
Quoted 3 lines
fs/xfs/xfs_qm_syscalls.c +0
-0return error ? error : error2; }@@ -413,8 +415,10 @@ xfs_qm_scall_getqstat(As we discussed on the call: Now that you've decided to write a new interface for this, you can be really light touch here in
xfs_qm_scall_getqstat(). The new macro indqblk_xfs.hcan also go away.
yes
Quoted 6 lines
Looking good.
Regards,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 2/4] xfs: Start using pquotaino from the superblock.
Hey Chandra,
Quoted 24 lines · Chandra Seetharaman
Quoted 13 lines · Ben Myers
Hey Chandra,
Quoted 7 lines · Chandra Seetharaman
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
Signed-off-by Chandra Seetharaman <[email protected]>Here are a few notes from my review.
Quoted 9 lines
fs/xfs/xfs_mount.c xfs_mount_validate_sb( · line 344
Quoted 5 lines
fs/xfs/xfs_mount.c +5
-0+if (sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) { +xfs_notice (mp, +"Version 5 of Super block has XFS_OQUOTA bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + }If I'm reading that right... Now if you had a v5 super block with oquota bits it will become unmountable. Could that happen if you were using crcs and quotas with a 3.10 kernel and then upgrade?
Quoted 2 lines
yes. My thinking is that v5 (with crc) is still experimental and not supported yet. Not true ?
Right. v5 superblock is still experimental.
Quoted 3 lines
Previously this was being fixed without failing. But, Dave suggested that this certainly would be an inconsistent state and hence need to be failed. I agreed and changed the code.
Sounds fine. I just wanted to make sure we're all aware of this possibility.
Quoted 2 lines
The problem you stated can be fixed by adding functionality to
xfs_repair.
Maybe a workaround for those users would be to shut of quotas before upgrading,
and then turn them back on after?
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
fs/xfs/xfs_qm.c +1
-0xfs_sb_version_addquota (&mp->m_sb); mp->m_sb.sb_uquotino =NULLFSINO ; mp->m_sb.sb_gquotino =NULLFSINO ; + mp->m_sb.sb_pquotino =NULLFSINO ;Quoted 7 lines
fs/xfs/xfs_qm.c xfs_qm_qino_alloc( · line 873
Quoted 4 lines
fs/xfs/xfs_qm.c +2
-2-/* qflags will get updated _after_ quotacheck */ - mp->m_sb.sb_qflags =0 ; +/* qflags will get updated fully _after_ quotacheck */ + mp->m_sb.sb_qflags = mp->m_qflags &XFS_ALL_QUOTA_ACCT ;I didn't quite catch why you changed from 0 to
ALL_QUOTA_ACCThere, will take another look.
Quoted 6 lines
We wanted to move all (well, almost all :) the logic of managing PQUOTINO/GQUOTINO in older superblock in just the two functions xfs_sb_quota_to/from_disk(). In order to do that I had to use
sb_qflags(you can see that inxfs_sb_quota_to_disk()). So, we have to havesb_qflagsvalid before we try to write these fields to the disk. Hence this change.
Oh, that explains it. Thanks.
-Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 2/4] xfs: Start using pquotaino from the superblock.
Quoted 36 lines · Ben Myers
Hey Chandra,
Quoted 24 lines · Chandra Seetharaman
Quoted 13 lines · Ben Myers
Hey Chandra,
Quoted 7 lines · Chandra Seetharaman
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
Signed-off-by Chandra Seetharaman <[email protected]>Here are a few notes from my review.
Quoted 9 lines
fs/xfs/xfs_mount.c xfs_mount_validate_sb( · line 344
Quoted 5 lines
fs/xfs/xfs_mount.c +5
-0+if (sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) { +xfs_notice (mp, +"Version 5 of Super block has XFS_OQUOTA bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + }If I'm reading that right... Now if you had a v5 super block with oquota bits it will become unmountable. Could that happen if you were using crcs and quotas with a 3.10 kernel and then upgrade?
Quoted 2 lines
yes. My thinking is that v5 (with crc) is still experimental and not supported yet. Not true ?
Right. v5 superblock is still experimental.
Quoted 3 lines
Previously this was being fixed without failing. But, Dave suggested that this certainly would be an inconsistent state and hence need to be failed. I agreed and changed the code.
Quoted 7 lines
Sounds fine. I just wanted to make sure we're all aware of this possibility.
Quoted 2 lines
The problem you stated can be fixed by adding functionality to
xfs_repair.Maybe a workaround for those users would be to shut of quotas before upgrading,
and then turn them back on after?
That would work too.
Quoted 22 lines
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
fs/xfs/xfs_qm.c +1
-0xfs_sb_version_addquota (&mp->m_sb); mp->m_sb.sb_uquotino =NULLFSINO ; mp->m_sb.sb_gquotino =NULLFSINO ; + mp->m_sb.sb_pquotino =NULLFSINO ;Quoted 7 lines
fs/xfs/xfs_qm.c xfs_qm_qino_alloc( · line 873
Quoted 4 lines
fs/xfs/xfs_qm.c +2
-2-/* qflags will get updated _after_ quotacheck */ - mp->m_sb.sb_qflags =0 ; +/* qflags will get updated fully _after_ quotacheck */ + mp->m_sb.sb_qflags = mp->m_qflags &XFS_ALL_QUOTA_ACCT ;I didn't quite catch why you changed from 0 to
ALL_QUOTA_ACCThere, will take another look.Quoted 6 lines
We wanted to move all (well, almost all :) the logic of managing PQUOTINO/GQUOTINO in older superblock in just the two functions xfs_sb_quota_to/from_disk(). In order to do that I had to use
sb_qflags(you can see that inxfs_sb_quota_to_disk()). So, we have to havesb_qflagsvalid before we try to write these fields to the disk. Hence this change.
Quoted 4 lines
Oh, that explains it. Thanks.
-Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
PATCH v11 3/4 xfs: Add proper versioning support to fs_quota_stat
In reply to Chandra SeetharamanAdded appropriate pads and code for backward compatibility.
Copied over the old version as it is different from the newer padded version.
New callers of the system call have to set the version of the data structure being passed, and kernel will fill as much data as requested.
--- fs/gfs2/quota.c | 3 -- fs/quota/quota.c | 67 +++++++++++++++++++++++++++++++++++++-- fs/xfs/xfs_qm_syscalls.c | 4 -- include/uapi/linux/dqblk_xfs.h | 60 +++++++++++++++++++++++++++++++---- 4 files changed, 116 insertions(+), 18 deletions(-)
fs/gfs2/quota.c +0 -3
@@ -1443,9 +1443,6 @@ static int gfs2_quota_get_xstate(struct super_block *sb, {struct gfs2_sbd *sdp = sb->s_fs_info; -memset (fqs,0 ,sizeof (struct fs_quota_stat )); - fqs->qs_version =FS_QSTAT_VERSION ; -switch (sdp->sd_args.ar_quota) {case GFS2_QUOTA_ON : fqs->qs_flags |= (FS_QUOTA_UDQ_ENFD |FS_QUOTA_GDQ_ENFD );
fs/quota/quota.c +63 -4
85 lines not on this page · raw message
fs/xfs/xfs_qm_syscalls.c +0 -4
@@ -420,9 +420,6 @@ xfs_qm_scall_getqstat(bool tempgqip = false;bool temppqip = false; -memset (out,0 ,sizeof (fs_quota_stat_t)); - - out->qs_version =FS_QSTAT_VERSION ;if (!xfs_sb_version_hasquota (&mp->m_sb)) { out->qs_uquota.qfs_ino =NULLFSINO ; out->qs_gquota.qfs_ino =NULLFSINO ;
@@ -432,7 +429,6 @@ xfs_qm_scall_getqstat( out->qs_flags = (__uint16_t )xfs_qm_export_flags (mp->m_qflags & (XFS_ALL_QUOTA_ACCT |XFS_ALL_QUOTA_ENFD )); - out->qs_pad =0 ; out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino;if (&out->qs_gquota != &out->qs_pquota)
include/uapi/linux/dqblk_xfs.h +53 -7
96 lines not on this page · raw message
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 3/4] xfs: Add proper versioning support to fs_quota_stat
Quoted 35 lines · Chandra Seetharaman
Added appropriate pads and code for backward compatibility.
Copied over the old version as it is different from the newer padded version.
New callers of the system call have to set the version of the data structure being passed, and kernel will fill as much data as requested.
Signed-off-by Chandra Seetharaman <[email protected]>--- fs/gfs2/quota.c | 3 -- fs/quota/quota.c | 67 +++++++++++++++++++++++++++++++++++++-- fs/xfs/xfs_qm_syscalls.c | 4 -- include/uapi/linux/dqblk_xfs.h | 60 +++++++++++++++++++++++++++++++---- 4 files changed, 116 insertions(+), 18 deletions(-)fs/gfs2/quota.c +0
-3@@ -1443,9 +1443,6 @@ static int gfs2_quota_get_xstate(struct super_block *sb, {struct gfs2_sbd *sdp = sb->s_fs_info; -memset (fqs,0 ,sizeof (struct fs_quota_stat )); - fqs->qs_version =FS_QSTAT_VERSION ; -switch (sdp->sd_args.ar_quota) {case GFS2_QUOTA_ON : fqs->qs_flags |= (FS_QUOTA_UDQ_ENFD |FS_QUOTA_GDQ_ENFD );fs/quota/quota.c +0
-0
fs/quota/quota.c static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr) · line 208
Quoted 6 lines
fs/quota/quota.c +2
-1@@ -204,15 +204,72 @@ static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr)return sb->s_qcop->set_xstate (sb, flags, cmd); } -static int quota_getxstate (struct super_block *sb,void __user *addr) +static int quota_getxstate (struct super_block *sb,void __user *addr, +bool older_version)
I'd suggest that the two API calls should be handled by separate functions so there are no overlapping, dependent branches in the code.
fs/quota/quota.c static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr) · line 216
Quoted 9 lines
fs/quota/quota.c +3
-1{struct fs_quota_stat fqs; -int ret; +struct fs_quota_stat_v1 fqs_v1; +int ret, size; +void *fqsp;if (!sb->s_qcop->get_xstate)return -ENOSYS ;
I'd also suggest that a sb->s_qcop->get_xstatev vector is added so that filesystems keep the separate as well.
And that means we don't need to play the fs_quota_stat and conversion-to-fs_quota_stat_v1 games. i.e. the existing quota_getxstate() remains and uses the existing struct fs_quota_stat, and the new Q_XGETQSTATV calls quota_getxstatev() and uses the newly defined struct fs_quota_statv and ->get_xstatev() call....
Quoted 4 lines
fs/quota/quota.c +0
-0@@ -137,31 +139,75 @@ typedef struct fs_disk_quota {* Provides a centralized way to get meta information about the quota subsystem. * eg. space taken up for user and group quotas, number of dquots currently * incore.
fs/quota/quota.c typedef struct fs_disk_quota { · line 151
Quoted 10 lines
fs/quota/quota.c +8
-0+* With version FS_QSTAT_VERSION, user space can send in an uninitialized +* buffer and data will be filled by the kernel. +* Starting FS_QSTAT_VERSION_2, to be used with Q_XGETQSTATV, user space +* caller should set qs_version to the appropriate version of the +* fs_quota_stat data structure they are providing. On return, user +* space should check qs_version and use appropriate fields supported by +* that version. */ #define FS_QSTAT_VERSION 1/* fs_quota_stat.qs_version */ +#define FS_QSTAT_VERSION_2 2/* new field qs_pquota; realignment */
As per above, this reasoning and logic is all invalid now because we aren't trying to maintain compatibility between users of the same quotactl.
We are using a new quotactl, so we do not need to overload the existing structure or versions.
Quoted 15 lines
fs/quota/quota.c +15
-0+/* +* Some basic information about 'quota files'. Version 2. +*/ +struct fs_qfilestat { +__u64 qfs_ino;/* inode number */ +__u64 qfs_nblks;/* number of BBs 512-byte-blks */ +__u32 qfs_nextents;/* number of extents */ +__u32 qfs_pad;/* pad for 8-byte alignment */ +}; + +struct fs_quota_stat { +__s8 qs_version;/* version for future changes */ +__u8 qs_pad1;/* pad for 16bit alignment */ +__u16 qs_flags;/* FS_QUOTA_.* flags */ +__u32 qs_incoredqs;/* number of dquots incore */
fs/quota/quota.c typedef struct fs_disk_quota { · line 176
Quoted 10 lines
fs/quota/quota.c +10
-0+struct fs_qfilestat qs_uquota;/* user quota information */ +struct fs_qfilestat qs_gquota;/* group quota information */ +struct fs_qfilestat qs_pquota;/* project quota information */ +__s32 qs_btimelimit;/* limit for blks timer */ +__s32 qs_itimelimit;/* limit for inodes timer */ +__s32 qs_rtbtimelimit;/* limit for rt blks timer */ +__u16 qs_bwarnlimit;/* limit for num warnings */ +__u16 qs_iwarnlimit;/* limit for num warnings */ +__u64 qs_pad2[8 ];/* for future proofing */ +};
these are what become fs_quota_statv and fs_qfilestatv structures for the new quotactl.
fs/quota/quota.c typedef struct fs_disk_quota { · line 186
Quoted 10 lines
fs/quota/quota.c +10
-0+/* +* Since Version 1 did not have padding at appropriate places, +* a new data structure has been defined for the older version to +* provide backward compatibility. +* Future extentions of this data structure won't require new +* data structure definitions as the current one can be extended +* with the logic and padding in place now. +*/ +#define FS_QSTAT_V1_SIZE (sizeof(struct fs_quota_stat_v1)) +#define FS_QSTAT_V2_SIZE (sizeof(struct fs_quota_stat))
And these can go away completely.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 3/4] xfs: Add proper versioning support to fs_quota_stat
Hi,
Please keep Abhi cc'd on this thread. Thanks,
Steve.
Quoted 131 lines · Dave Chinner
Quoted 35 lines · Chandra Seetharaman
Added appropriate pads and code for backward compatibility.
Copied over the old version as it is different from the newer padded version.
New callers of the system call have to set the version of the data structure being passed, and kernel will fill as much data as requested.
Signed-off-by Chandra Seetharaman <[email protected]>--- fs/gfs2/quota.c | 3 -- fs/quota/quota.c | 67 +++++++++++++++++++++++++++++++++++++-- fs/xfs/xfs_qm_syscalls.c | 4 -- include/uapi/linux/dqblk_xfs.h | 60 +++++++++++++++++++++++++++++++---- 4 files changed, 116 insertions(+), 18 deletions(-)fs/gfs2/quota.c +0
-3@@ -1443,9 +1443,6 @@ static int gfs2_quota_get_xstate(struct super_block *sb, {struct gfs2_sbd *sdp = sb->s_fs_info; -memset (fqs,0 ,sizeof (struct fs_quota_stat )); - fqs->qs_version =FS_QSTAT_VERSION ; -switch (sdp->sd_args.ar_quota) {case GFS2_QUOTA_ON : fqs->qs_flags |= (FS_QUOTA_UDQ_ENFD |FS_QUOTA_GDQ_ENFD );fs/quota/quota.c +0
-0fs/quota/quota.c static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr) · line 208
Quoted 6 lines
fs/quota/quota.c +2
-1@@ -204,15 +204,72 @@ static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr)return sb->s_qcop->set_xstate (sb, flags, cmd); } -static int quota_getxstate (struct super_block *sb,void __user *addr) +static int quota_getxstate (struct super_block *sb,void __user *addr, +bool older_version)I'd suggest that the two API calls should be handled by separate functions so there are no overlapping, dependent branches in the code.
fs/quota/quota.c static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr) · line 216
Quoted 9 lines
fs/quota/quota.c +3
-1{struct fs_quota_stat fqs; -int ret; +struct fs_quota_stat_v1 fqs_v1; +int ret, size; +void *fqsp;if (!sb->s_qcop->get_xstate)return -ENOSYS ;I'd also suggest that a
sb->s_qcop->get_xstatevvector is added so that filesystems keep the separate as well.And that means we don't need to play the
fs_quota_statand conversion-to-fs_quota_stat_v1 games. i.e. the existingquota_getxstate()remains and uses the existing structfs_quota_stat, and the newQ_XGETQSTATVcallsquota_getxstatev()and uses the newly defined structfs_quota_statvand ->get_xstatev() call....Quoted 4 lines
fs/quota/quota.c +0
-0@@ -137,31 +139,75 @@ typedef struct fs_disk_quota {* Provides a centralized way to get meta information about the quota subsystem. * eg. space taken up for user and group quotas, number of dquots currently * incore. fs/quota/quota.c typedef struct fs_disk_quota { · line 151
Quoted 10 lines
fs/quota/quota.c +8
-0+* With version FS_QSTAT_VERSION, user space can send in an uninitialized +* buffer and data will be filled by the kernel. +* Starting FS_QSTAT_VERSION_2, to be used with Q_XGETQSTATV, user space +* caller should set qs_version to the appropriate version of the +* fs_quota_stat data structure they are providing. On return, user +* space should check qs_version and use appropriate fields supported by +* that version. */ #define FS_QSTAT_VERSION 1/* fs_quota_stat.qs_version */ +#define FS_QSTAT_VERSION_2 2/* new field qs_pquota; realignment */ As per above, this reasoning and logic is all invalid now because we aren't trying to maintain compatibility between users of the same quotactl.
We are using a new quotactl, so we do not need to overload the existing structure or versions.
Quoted 15 lines
fs/quota/quota.c +15
-0+/* +* Some basic information about 'quota files'. Version 2. +*/ +struct fs_qfilestat { +__u64 qfs_ino;/* inode number */ +__u64 qfs_nblks;/* number of BBs 512-byte-blks */ +__u32 qfs_nextents;/* number of extents */ +__u32 qfs_pad;/* pad for 8-byte alignment */ +}; + +struct fs_quota_stat { +__s8 qs_version;/* version for future changes */ +__u8 qs_pad1;/* pad for 16bit alignment */ +__u16 qs_flags;/* FS_QUOTA_.* flags */ +__u32 qs_incoredqs;/* number of dquots incore */ fs/quota/quota.c typedef struct fs_disk_quota { · line 176
Quoted 10 lines
fs/quota/quota.c +10
-0+struct fs_qfilestat qs_uquota;/* user quota information */ +struct fs_qfilestat qs_gquota;/* group quota information */ +struct fs_qfilestat qs_pquota;/* project quota information */ +__s32 qs_btimelimit;/* limit for blks timer */ +__s32 qs_itimelimit;/* limit for inodes timer */ +__s32 qs_rtbtimelimit;/* limit for rt blks timer */ +__u16 qs_bwarnlimit;/* limit for num warnings */ +__u16 qs_iwarnlimit;/* limit for num warnings */ +__u64 qs_pad2[8 ];/* for future proofing */ +};these are what become
fs_quota_statvandfs_qfilestatvstructures for the new quotactl.fs/quota/quota.c typedef struct fs_disk_quota { · line 186
Quoted 10 lines
fs/quota/quota.c +10
-0+/* +* Since Version 1 did not have padding at appropriate places, +* a new data structure has been defined for the older version to +* provide backward compatibility. +* Future extentions of this data structure won't require new +* data structure definitions as the current one can be extended +* with the logic and padding in place now. +*/ +#define FS_QSTAT_V1_SIZE (sizeof(struct fs_quota_stat_v1)) +#define FS_QSTAT_V2_SIZE (sizeof(struct fs_quota_stat))And these can go away completely.
Quoted 3 lines
Cheers,
Dave.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [PATCH v11 3/4] xfs: Add proper versioning support to fs_quota_stat
In reply to Chandra SeetharamanQuoted 9 lines · Chandra Seetharaman
Added appropriate pads and code for backward compatibility.
Copied over the old version as it is different from the newer padded version.
New callers of the system call have to set the version of the data structure being passed, and kernel will fill as much data as requested.
Signed-off-by Chandra Seetharaman <[email protected]>
Oh, and I forgot to mention:
fs/quota/quota.c static int quota_setxstate(struct super_block *sb, int cmd, void __user *addr) · line 234
Quoted 8 lines
fs/quota/quota.c +8
-0+/* +* For forward compatibility. Check against all supported +* versions, and if the version provided is not supported +* by the kernel, set to the highest version supported. +* For now only FS_QSTAT_VERSION_2 is supported. +*/ +if (fqs.qs_version !=FS_QSTAT_VERSION_2 ) + fqs.qs_version =FS_QSTAT_VERSION_2 ;
New API, new version number and enforcement: if the version number passed in from userspace is not understood, -EINVAL or an equivalent "parameter not understood" error should be returned. If the kernel doesn't understand what it is being passed, then there's no guarantee that anything quota info we return can be understood by the caller.
And while I remember, we'll also need quotactl(2) man page updates for the new API.
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
PATCH v11 4/4 xfs: Use new qs_pquota field in fs_quota_stat for Q_XGETQSTATV
In reply to Chandra SeetharamanFor the Q_XGETQSTATV quota command, if the new version of fs_quota_stat data structure is used, fill the project quota information.
--- fs/xfs/xfs_qm_syscalls.c | 38 ++++++++++++++++++++++++++------------ 1 files changed, 26 insertions(+), 12 deletions(-)
fs/xfs/xfs_qm_syscalls.c +26 -12
@@ -406,6 +406,14 @@ xfs_qm_scall_quotaon(/* * Return quota status information, such as uquota-off, enforcements, etc. +* +* We support two different versions of the fs_quota_stat structure +* here. If the version is FS_QSTAT_VERSION, then there is no +* separate project quota fields, and so we write project quota +* information into the group quota fields. With FS_QSTAT_VERSION_2, +* there is a separate project quota field so we can use that +* instead to pass both group and project quota back to user space. +* */ int xfs_qm_scall_getqstat(
@@ -420,19 +428,15 @@ xfs_qm_scall_getqstat(bool tempgqip = false;bool temppqip = false; -if (!xfs_sb_version_hasquota (&mp->m_sb)) { - out->qs_uquota.qfs_ino =NULLFSINO ; - out->qs_gquota.qfs_ino =NULLFSINO ; - out->qs_pquota.qfs_ino =NULLFSINO ; -return (0 ); - } + out->qs_uquota.qfs_ino =NULLFSINO ; + out->qs_gquota.qfs_ino =NULLFSINO ; + out->qs_pquota.qfs_ino =NULLFSINO ; +if (!xfs_sb_version_hasquota (&mp->m_sb)) +return 0 ; + out->qs_flags = (__uint16_t )xfs_qm_export_flags (mp->m_qflags & (XFS_ALL_QUOTA_ACCT |XFS_ALL_QUOTA_ENFD )); - out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; - out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; -if (&out->qs_gquota != &out->qs_pquota) - out->qs_pquota.qfs_ino = mp->m_sb.sb_pquotino;if (q) { uip = q->qi_uquotaip;
@@ -454,21 +458,31 @@ xfs_qm_scall_getqstat( 0, 0, &pip) == 0) temppqip = true; } +if (uip) { + out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; out->qs_uquota.qfs_nextents = uip->i_d.di_nextents;if (tempuqip)IRELE (uip); }if (gip) { + out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; out->qs_gquota.qfs_nblks = gip->i_d.di_nblocks; out->qs_gquota.qfs_nextents = gip->i_d.di_nextents;if (tempgqip)IRELE (gip); }if (pip) { - out->qs_pquota.qfs_nblks = pip->i_d.di_nblocks; - out->qs_pquota.qfs_nextents = pip->i_d.di_nextents; +if (out->qs_version >=FS_QSTAT_VERSION_2 ) { + out->qs_pquota.qfs_ino = mp->m_sb.sb_pquotino; + out->qs_pquota.qfs_nblks = pip->i_d.di_nblocks; + out->qs_pquota.qfs_nextents = pip->i_d.di_nextents; + }else { + out->qs_gquota.qfs_ino = mp->m_sb.sb_pquotino; + out->qs_gquota.qfs_nblks = pip->i_d.di_nblocks; + out->qs_gquota.qfs_nextents = pip->i_d.di_nextents; + }if (temppqip)IRELE (pip); }
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs