xfs: Allow pquota and gquota to be used together
Subsystems (2)
v3 cover xfs: Allow pquota and gquota to be used together
Hello All,
This is the version 2 of the changes to allow pquota and gquota to be used together.
version 2 of the posting can be found at
http://marc.info/?l=linux-xfs&m=131966420607401&w=2
Changes from version 2 to version 3:
- hash table for pquota is added.
- changes to apply cleanly with the latest tree
version 1 of the posting can be found at
http://article.gmane.org/gmane.comp.file-systems.xfs.general/41284
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()
Thanks & Regards,
chandra
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
RFC PATCH v3 1/4 xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
Define new macros XFS_GQUOTA_ENFD, XFS_GQUOTA_CHKD, XFS_PQUOTA_ENFD, and XFS_PQUOTA_CHKD.
Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD. Instead, start using XFS_GQUOTA_.* XFS_PQUOTA_.* counterparts.
No changes is made to the on-disk version of the superblock yet. On-disk copy still uses XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD.
--- fs/xfs/xfs_mount.c | 30 ++++++++++++++++++++++++++++++ fs/xfs/xfs_qm.c | 9 ++++++--- fs/xfs/xfs_qm_syscalls.c | 26 ++++++++++++++------------ fs/xfs/xfs_quota.h | 36 +++++++++++++++++++++++++----------- fs/xfs/xfs_quotaops.c | 6 ++++-- fs/xfs/xfs_super.c | 16 ++++++++-------- fs/xfs/xfs_trans_dquot.c | 4 ++-- 7 files changed, 89 insertions(+), 38 deletions(-)
fs/xfs/xfs_quota.h +25 -11
@@ -152,19 +152,34 @@ typedef struct xfs_qoff_logformat {#define XFS_GQUOTA_ACCT 0x0040/* group quota accounting ON */ /* +* Start differentiating group quota and project quota in-core +* using distinct flags, instead of using the combined OQUOTA flags. +* +* Conversion to and from the combined OQUOTA flag (if necessary) +* is done only in xfs_sb_{to,from}_disk() +*/ +#define XFS_GQUOTA_ENFD 0x0080/* group quota limits enforced */ +#define XFS_GQUOTA_CHKD 0x0100/* quotacheck run on group quotas */ +#define XFS_PQUOTA_ENFD 0x0200/* project quota limits enforced */ +#define XFS_PQUOTA_CHKD 0x0400/* quotacheck run on project quotas */ + +/* * Quota Accounting/Enforcement flags */ #define XFS_ALL_QUOTA_ACCT \ (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) -#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) -#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) +#define XFS_ALL_QUOTA_ENFD \ + (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) +#define XFS_ALL_QUOTA_CHKD \ + (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)#define XFS_IS_QUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)#define XFS_IS_UQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)#define XFS_IS_PQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)#define XFS_IS_GQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)#define XFS_IS_UQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) -#define XFS_IS_OQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD) +#define XFS_IS_PQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) +#define XFS_IS_GQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)/* * Incore only flags for quotaoff - these bits get cleared when quota(s)
@@ -259,24 +274,23 @@ typedef struct xfs_qoff_logformat { ((XFS_IS_UQUOTA_ON (mp) && \ (mp->m_sb.sb_qflags &XFS_UQUOTA_CHKD ) ==0 ) || \ (XFS_IS_GQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags &XFS_PQUOTA_ACCT ))) || \ + (mp->m_sb.sb_qflags &XFS_GQUOTA_CHKD ) ==0 ) || \ (XFS_IS_PQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) + (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD)#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD)#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ - XFS_GQUOTA_ACCT) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD|\ + XFS_GQUOTA_ACCT|XFS_GQUOTA_ENFD|\ + XFS_GQUOTA_CHKD)/*
fs/xfs/xfs_mount.c +30 -0
@@ -593,6 +593,20 @@ xfs_sb_from_disk( to->sb_uquotino =be64_to_cpu (from->sb_uquotino); to->sb_gquotino =be64_to_cpu (from->sb_gquotino); to->sb_qflags =be16_to_cpu (from->sb_qflags); +if ((to->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && + (to->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. Fixing it.\n" ); + } +if (to->sb_qflags &XFS_OQUOTA_ENFD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ; +if (to->sb_qflags &XFS_OQUOTA_CHKD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; + to->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + to->sb_flags = from->sb_flags; to->sb_shared_vn = from->sb_shared_vn; to->sb_inoalignmt =be32_to_cpu (from->sb_inoalignmt);
@@ -622,11 +636,26 @@ xfs_sb_to_disk(xfs_sb_field_t f;int first;int size; +__be16 saved_qflags;ASSERT (fields);if (!fields)return ; +/* +* in-core version of qflags do not have XFS_OQUOTA.*, whereas the +* on-disk version does. So, save the in-core sb_qflags and restore +* it after we modify and copy it to the buffer to be copied to +* disk. +*/ + saved_qflags = from->sb_qflags; + +if (from->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD )) + from->sb_qflags |=XFS_OQUOTA_ENFD ; +if (from->sb_qflags & (XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) + from->sb_qflags |=XFS_OQUOTA_CHKD ; + from->sb_qflags &= ~(XFS_PQUOTA_ENFD |XFS_PQUOTA_CHKD | +XFS_GQUOTA_ENFD |XFS_GQUOTA_CHKD );while (fields) { f = (xfs_sb_field_t )xfs_lowbit64 ((__uint64_t )fields); first = xfs_sb_info[f].offset;
@@ -657,6 +686,7 @@ xfs_sb_to_disk( fields &= ~(1LL << f); } + from->sb_qflags = saved_qflags; }/*
fs/xfs/xfs_qm.c +6 -3
@@ -313,8 +313,10 @@ xfs_qm_mount_quotas(*/ if (!XFS_IS_UQUOTA_ON (mp)) mp->m_qflags &= ~XFS_UQUOTA_CHKD ; -if (!(XFS_IS_GQUOTA_ON (mp) ||XFS_IS_PQUOTA_ON (mp))) - mp->m_qflags &= ~XFS_OQUOTA_CHKD ; +if (!XFS_IS_GQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_GQUOTA_CHKD ; +if (!XFS_IS_PQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_PQUOTA_CHKD ; write_changes:/*
@@ -1449,7 +1451,8 @@ xfs_qm_quotacheck( XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);if (error) goto error_return; - flags |=XFS_OQUOTA_CHKD ; + flags |=XFS_IS_GQUOTA_ON (mp) ? +XFS_GQUOTA_CHKD :XFS_PQUOTA_CHKD ; } do {
fs/xfs/xfs_qm_syscalls.c +14 -12
@@ -121,11 +121,11 @@ xfs_qm_scall_quotaoff( }if (flags &XFS_GQUOTA_ACCT ) { dqtype |=XFS_QMOPT_GQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_GQUOTA_CHKD |XFS_GQUOTA_ENFD ); inactivate_flags |=XFS_GQUOTA_ACTIVE ; }else if (flags &XFS_PQUOTA_ACCT ) { dqtype |=XFS_QMOPT_PQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_PQUOTA_CHKD |XFS_PQUOTA_ENFD ); inactivate_flags |=XFS_PQUOTA_ACTIVE ; }
@@ -349,9 +349,11 @@ xfs_qm_scall_quotaon( || ((flags & XFS_PQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && - (flags & XFS_GQUOTA_ACCT) == 0 && + (flags & XFS_PQUOTA_ENFD)) + || + ((flags & XFS_GQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && - (flags & XFS_OQUOTA_ENFD))) { + (flags & XFS_GQUOTA_ENFD))) {xfs_debug (mp,"%s: Can't enforce without acct, flags=%x sbflags=%x\n" , __func__, flags, mp->m_sb.sb_qflags);
@@ -801,8 +803,8 @@ xfs_qm_export_dquot(* so return zeroes in that case. */ if ((!XFS_IS_UQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_USER ) || - (!XFS_IS_OQUOTA_ENFORCED (mp) && - (src->d_flags & (XFS_DQ_PROJ |XFS_DQ_GROUP )))) { + (!XFS_IS_PQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_PROJ ) || + (!XFS_IS_GQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_GROUP )) { dst->d_btimer =0 ; dst->d_itimer =0 ; dst->d_rtbtimer =0 ;
@@ -810,8 +812,8 @@ xfs_qm_export_dquot(#ifdef DEBUG if (((XFS_IS_UQUOTA_ENFORCED (mp) && dst->d_flags ==FS_USER_QUOTA ) || - (XFS_IS_OQUOTA_ENFORCED (mp) && - (dst->d_flags & (FS_PROJ_QUOTA |FS_GROUP_QUOTA )))) && + (XFS_IS_PQUOTA_ENFORCED (mp) && dst->d_flags ==FS_PROJ_QUOTA ) || + (XFS_IS_GQUOTA_ENFORCED (mp) && dst->d_flags ==FS_GROUP_QUOTA )) && dst->d_id !=0 ) {if (((int ) dst->d_bcount >= (int ) dst->d_blk_softlimit) && (dst->d_blk_softlimit >0 )) {
@@ -860,10 +862,10 @@ xfs_qm_export_flags( uflags |=FS_QUOTA_GDQ_ACCT ;if (flags &XFS_UQUOTA_ENFD ) uflags |=FS_QUOTA_UDQ_ENFD ; -if (flags & (XFS_OQUOTA_ENFD )) { - uflags |= (flags &XFS_GQUOTA_ACCT ) ? -FS_QUOTA_GDQ_ENFD :FS_QUOTA_PDQ_ENFD ; - } +if (flags &XFS_PQUOTA_ENFD ) + uflags |=FS_QUOTA_PDQ_ENFD ; +if (flags &XFS_GQUOTA_ENFD ) + uflags |=FS_QUOTA_GDQ_ENFD ;return (uflags); }
fs/xfs/xfs_quotaops.c +4 -2
@@ -76,8 +76,10 @@ xfs_fs_set_xstate( flags |=XFS_GQUOTA_ACCT ;if (uflags &FS_QUOTA_UDQ_ENFD ) flags |=XFS_UQUOTA_ENFD ; -if (uflags & (FS_QUOTA_PDQ_ENFD |FS_QUOTA_GDQ_ENFD )) - flags |=XFS_OQUOTA_ENFD ; +if (uflags &FS_QUOTA_PDQ_ENFD ) + flags |=XFS_PQUOTA_ENFD ; +if (uflags &FS_QUOTA_GDQ_ENFD ) + flags |=XFS_GQUOTA_ENFD ;switch (op) {case Q_XQUOTAON :
fs/xfs/xfs_super.c +8 -8
@@ -339,17 +339,17 @@ xfs_parseargs( }else if (!strcmp (this_char,MNTOPT_PQUOTA ) || !strcmp (this_char,MNTOPT_PRJQUOTA )) { mp->m_qflags |= (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE | -XFS_OQUOTA_ENFD ); +XFS_PQUOTA_ENFD ); }else if (!strcmp (this_char,MNTOPT_PQUOTANOENF )) { mp->m_qflags |= (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE ); - mp->m_qflags &= ~XFS_OQUOTA_ENFD ; + mp->m_qflags &= ~XFS_PQUOTA_ENFD ; }else if (!strcmp (this_char,MNTOPT_GQUOTA ) || !strcmp (this_char,MNTOPT_GRPQUOTA )) { mp->m_qflags |= (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE | -XFS_OQUOTA_ENFD ); +XFS_GQUOTA_ENFD ); }else if (!strcmp (this_char,MNTOPT_GQUOTANOENF )) { mp->m_qflags |= (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE ); - mp->m_qflags &= ~XFS_OQUOTA_ENFD ; + mp->m_qflags &= ~XFS_GQUOTA_ENFD ; }else if (!strcmp (this_char,MNTOPT_DELAYLOG )) {xfs_warn (mp,"delaylog is the default now, option is deprecated." );
@@ -542,12 +542,12 @@ xfs_showargs(/* Either project or group quotas can be active, not both */ if (mp->m_qflags &XFS_PQUOTA_ACCT ) { -if (mp->m_qflags &XFS_OQUOTA_ENFD ) +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_OQUOTA_ENFD ) +if (mp->m_qflags &XFS_GQUOTA_ENFD )seq_puts (m,"," MNTOPT_GRPQUOTA );else seq_puts (m,"," MNTOPT_GQUOTANOENF );
@@ -1059,8 +1059,8 @@ xfs_fs_statfs(spin_unlock (&mp->m_sb_lock);if ((ip->i_d.di_flags &XFS_DIFLAG_PROJINHERIT ) || - ((mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_OQUOTA_ENFD ))) == - (XFS_PQUOTA_ACCT |XFS_OQUOTA_ENFD )) + ((mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ENFD ))) == + (XFS_PQUOTA_ACCT |XFS_PQUOTA_ENFD ))xfs_qm_statvfs (ip, statp);return 0 ; }
fs/xfs/xfs_trans_dquot.c +2 -2
@@ -640,8 +640,8 @@ xfs_trans_dqresv(if ((flags &XFS_QMOPT_FORCE_RES ) ==0 && dqp->q_core.d_id && ((XFS_IS_UQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISUDQ (dqp)) || - (XFS_IS_OQUOTA_ENFORCED (dqp->q_mount) && - (XFS_QM_ISPDQ (dqp) ||XFS_QM_ISGDQ (dqp))))) { + (XFS_IS_PQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISPDQ (dqp)) || + (XFS_IS_GQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISGDQ (dqp)))) {if (nblks >0 ) {/* * dquot is locked already. See if we'd go over the
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
RFC PATCH v3 1/4 xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
#pwhite: The only questionable bit of code here is when transferring the #superblock back and forth to disk. At present, we maintain XFS_OQUOTA #settings on the disk and guess at whether that meant PQUOTA or GQUOTA when #we get it into core from the ACCT settings. That works for now, but we'll #want to eliminate that eventually.
Define new macros XFS_GQUOTA_ENFD, XFS_GQUOTA_CHKD, XFS_PQUOTA_ENFD, and XFS_PQUOTA_CHKD.
Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD. Instead, start using XFS_GQUOTA_.* XFS_PQUOTA_.* counterparts.
No changes is made to the on-disk version of the superblock yet. On-disk copy still uses XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD.
--- fs/xfs/xfs_mount.c | 30 ++++++++++++++++++++++++++++++ fs/xfs/xfs_qm.c | 9 ++++++--- fs/xfs/xfs_qm_syscalls.c | 26 ++++++++++++++------------ fs/xfs/xfs_quota.h | 36 +++++++++++++++++++++++++----------- fs/xfs/xfs_quotaops.c | 6 ++++-- fs/xfs/xfs_super.c | 16 ++++++++-------- fs/xfs/xfs_trans_dquot.c | 4 ++-- 7 files changed, 89 insertions(+), 38 deletions(-)
fs/xfs/xfs_quota.h +0 -0
@@ -152,19 +152,34 @@ typedef struct xfs_qoff_logformat {#define XFS_GQUOTA_ACCT 0x0040/* group quota accounting ON */
#pwhite: OQUOTA_ENFD == 0x10, OQUOTA_CHKD=0x20. Those values don't overlap #with the GQUOTA or PQUOTA flags.
/*
+ * Start differentiating group quota and project quota in-core
+ * using distinct flags, instead of using the combined OQUOTA flags.
+ *
+ * Conversion to and from the combined OQUOTA flag (if necessary)
+ * is done only in xfs_sb_{to,from}_disk()
+ */
+#define XFS_GQUOTA_ENFD 0x0080 /* group quota limits enforced */ +#define XFS_GQUOTA_CHKD 0x0100 /* quotacheck run on group quotas */ +#define XFS_PQUOTA_ENFD 0x0200 /* project quota limits enforced */ +#define XFS_PQUOTA_CHKD 0x0400 /* quotacheck run on project quotas */
+
+/*
* Quota Accounting/Enforcement flags
*/
#define XFS_ALL_QUOTA_ACCT \
(XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT)
-#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD)
-#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD)
+#define XFS_ALL_QUOTA_ENFD \
+ (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD)
+#define XFS_ALL_QUOTA_CHKD \
+ (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)
#pwhite: I'm not sure why we remove OQUOTA_ENFD and OQUOTA_CHKD here. It #seems like if we're setting those flags, then they're indicative of quotas #being set, therefore we should check them out.
#define XFS_IS_QUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)
#define XFS_IS_UQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)
#define XFS_IS_PQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)
#define XFS_IS_GQUOTA_RUNNING(mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)
#define XFS_IS_UQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD)
-#define XFS_IS_OQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD)
+#define XFS_IS_PQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD)
+#define XFS_IS_GQUOTA_ENFORCED(mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)
#pwhite: It's implied that if PQUOTA or GQUOTA, then also OQUOTA. I'd like to #see these also do a check against OQUOTA_ENFD even though it may be redundant.
/*
* Incore only flags for quotaoff - these bits get cleared when quota(s)
@@ -259,24 +274,23 @@ typedef struct xfs_qoff_logformat {
((XFS_IS_UQUOTA_ON(mp) && \
(mp->m_sb.sb_qflags & XFS_UQUOTA_CHKD) == 0) || \
(XFS_IS_GQUOTA_ON(mp) && \
- ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
- (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT))) || \
+ (mp->m_sb.sb_qflags & XFS_GQUOTA_CHKD) == 0) || \
(XFS_IS_PQUOTA_ON(mp) && \
- ((mp->m_sb.sb_qflags & XFS_OQUOTA_CHKD) == 0 || \
- (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT))))
+ (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))
#pwhite: These seem reasonable, but I'd like to see a separate term for #XFS_IS_OQUOTA_ON(mp) && ((mp->m_sb.sb_qflags & OQUOTA_CHKD) == 0)
#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD)
#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD)
#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\
XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ - XFS_GQUOTA_ACCT) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD|\ + XFS_GQUOTA_ACCT|XFS_GQUOTA_ENFD|\
+ XFS_GQUOTA_CHKD)
/*
fs/xfs/xfs_mount.c +29 -0
@@ -593,6 +593,20 @@ xfs_sb_from_disk( to->sb_uquotino =be64_to_cpu (from->sb_uquotino); to->sb_gquotino =be64_to_cpu (from->sb_gquotino); to->sb_qflags =be16_to_cpu (from->sb_qflags); +if ((to->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && + (to->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. Fixing it.\n" ); + } +if (to->sb_qflags &XFS_OQUOTA_ENFD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ; +if (to->sb_qflags &XFS_OQUOTA_CHKD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; + to->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + to->sb_flags = from->sb_flags; to->sb_shared_vn = from->sb_shared_vn; to->sb_inoalignmt =be32_to_cpu (from->sb_inoalignmt);
@@ -622,11 +636,26 @@ xfs_sb_to_disk(xfs_sb_field_t f;int first;int size; +__be16 saved_qflags;ASSERT (fields);if (!fields)return ; +/* +* in-core version of qflags do not have XFS_OQUOTA.*, whereas the +* on-disk version does. So, save the in-core sb_qflags and restore +* it after we modify and copy it to the buffer to be copied to +* disk. +*/ + saved_qflags = from->sb_qflags; + +if (from->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD )) + from->sb_qflags |=XFS_OQUOTA_ENFD ; +if (from->sb_qflags & (XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) + from->sb_qflags |=XFS_OQUOTA_CHKD ; + from->sb_qflags &= ~(XFS_PQUOTA_ENFD |XFS_PQUOTA_CHKD | +XFS_GQUOTA_ENFD |XFS_GQUOTA_CHKD );
#pwhite: We translate back and forth from [GP]QUOTA to OQUOTA for now, but in #the third patch of the series, we'll do away with that and add [GP]QUOTA as #valid flags
while (fields) {
f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); first = xfs_sb_info[f].offset;
@@ -657,6 +686,7 @@ xfs_sb_to_disk(
fields &= ~(1LL << f);
}
+ from->sb_qflags = saved_qflags;
}
/*
fs/xfs/xfs_qm.c +6 -3
@@ -313,8 +313,10 @@ xfs_qm_mount_quotas(*/ if (!XFS_IS_UQUOTA_ON (mp)) mp->m_qflags &= ~XFS_UQUOTA_CHKD ; -if (!(XFS_IS_GQUOTA_ON (mp) ||XFS_IS_PQUOTA_ON (mp))) - mp->m_qflags &= ~XFS_OQUOTA_CHKD ; +if (!XFS_IS_GQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_GQUOTA_CHKD ; +if (!XFS_IS_PQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_PQUOTA_CHKD ; write_changes:/*
@@ -1449,7 +1451,8 @@ xfs_qm_quotacheck( XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);if (error) goto error_return; - flags |=XFS_OQUOTA_CHKD ; + flags |=XFS_IS_GQUOTA_ON (mp) ? +XFS_GQUOTA_CHKD :XFS_PQUOTA_CHKD ; } do {
fs/xfs/xfs_qm_syscalls.c +14 -12
@@ -121,11 +121,11 @@ xfs_qm_scall_quotaoff( }if (flags &XFS_GQUOTA_ACCT ) { dqtype |=XFS_QMOPT_GQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_GQUOTA_CHKD |XFS_GQUOTA_ENFD ); inactivate_flags |=XFS_GQUOTA_ACTIVE ; }else if (flags &XFS_PQUOTA_ACCT ) { dqtype |=XFS_QMOPT_PQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_PQUOTA_CHKD |XFS_PQUOTA_ENFD ); inactivate_flags |=XFS_PQUOTA_ACTIVE ; }
@@ -349,9 +349,11 @@ xfs_qm_scall_quotaon( || ((flags & XFS_PQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && - (flags & XFS_GQUOTA_ACCT) == 0 && + (flags & XFS_PQUOTA_ENFD)) + || + ((flags & XFS_GQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && - (flags & XFS_OQUOTA_ENFD))) { + (flags & XFS_GQUOTA_ENFD))) {xfs_debug (mp,"%s: Can't enforce without acct, flags=%x sbflags=%x\n" , __func__, flags, mp->m_sb.sb_qflags);
@@ -801,8 +803,8 @@ xfs_qm_export_dquot(* so return zeroes in that case. */ if ((!XFS_IS_UQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_USER ) || - (!XFS_IS_OQUOTA_ENFORCED (mp) && - (src->d_flags & (XFS_DQ_PROJ |XFS_DQ_GROUP )))) { + (!XFS_IS_PQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_PROJ ) || + (!XFS_IS_GQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_GROUP )) { dst->d_btimer =0 ; dst->d_itimer =0 ; dst->d_rtbtimer =0 ;
@@ -810,8 +812,8 @@ xfs_qm_export_dquot(#ifdef DEBUG if (((XFS_IS_UQUOTA_ENFORCED (mp) && dst->d_flags ==FS_USER_QUOTA ) || - (XFS_IS_OQUOTA_ENFORCED (mp) && - (dst->d_flags & (FS_PROJ_QUOTA |FS_GROUP_QUOTA )))) && + (XFS_IS_PQUOTA_ENFORCED (mp) && dst->d_flags ==FS_PROJ_QUOTA ) || + (XFS_IS_GQUOTA_ENFORCED (mp) && dst->d_flags ==FS_GROUP_QUOTA )) && dst->d_id !=0 ) {if (((int ) dst->d_bcount >= (int ) dst->d_blk_softlimit) && (dst->d_blk_softlimit >0 )) {
@@ -860,10 +862,10 @@ xfs_qm_export_flags( uflags |=FS_QUOTA_GDQ_ACCT ;if (flags &XFS_UQUOTA_ENFD ) uflags |=FS_QUOTA_UDQ_ENFD ; -if (flags & (XFS_OQUOTA_ENFD )) { - uflags |= (flags &XFS_GQUOTA_ACCT ) ? -FS_QUOTA_GDQ_ENFD :FS_QUOTA_PDQ_ENFD ; - } +if (flags &XFS_PQUOTA_ENFD ) + uflags |=FS_QUOTA_PDQ_ENFD ; +if (flags &XFS_GQUOTA_ENFD ) + uflags |=FS_QUOTA_GDQ_ENFD ;return (uflags); }
fs/xfs/xfs_quotaops.c +4 -2
@@ -76,8 +76,10 @@ xfs_fs_set_xstate( flags |=XFS_GQUOTA_ACCT ;if (uflags &FS_QUOTA_UDQ_ENFD ) flags |=XFS_UQUOTA_ENFD ; -if (uflags & (FS_QUOTA_PDQ_ENFD |FS_QUOTA_GDQ_ENFD )) - flags |=XFS_OQUOTA_ENFD ; +if (uflags &FS_QUOTA_PDQ_ENFD ) + flags |=XFS_PQUOTA_ENFD ; +if (uflags &FS_QUOTA_GDQ_ENFD ) + flags |=XFS_GQUOTA_ENFD ;switch (op) {case Q_XQUOTAON :
fs/xfs/xfs_super.c +8 -8
@@ -339,17 +339,17 @@ xfs_parseargs( }else if (!strcmp (this_char,MNTOPT_PQUOTA ) || !strcmp (this_char,MNTOPT_PRJQUOTA )) { mp->m_qflags |= (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE | -XFS_OQUOTA_ENFD ); +XFS_PQUOTA_ENFD ); }else if (!strcmp (this_char,MNTOPT_PQUOTANOENF )) { mp->m_qflags |= (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE ); - mp->m_qflags &= ~XFS_OQUOTA_ENFD ; + mp->m_qflags &= ~XFS_PQUOTA_ENFD ; }else if (!strcmp (this_char,MNTOPT_GQUOTA ) || !strcmp (this_char,MNTOPT_GRPQUOTA )) { mp->m_qflags |= (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE | -XFS_OQUOTA_ENFD ); +XFS_GQUOTA_ENFD ); }else if (!strcmp (this_char,MNTOPT_GQUOTANOENF )) { mp->m_qflags |= (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE ); - mp->m_qflags &= ~XFS_OQUOTA_ENFD ; + mp->m_qflags &= ~XFS_GQUOTA_ENFD ; }else if (!strcmp (this_char,MNTOPT_DELAYLOG )) {xfs_warn (mp,"delaylog is the default now, option is deprecated." );
@@ -542,12 +542,12 @@ xfs_showargs(/* Either project or group quotas can be active, not both */ if (mp->m_qflags &XFS_PQUOTA_ACCT ) { -if (mp->m_qflags &XFS_OQUOTA_ENFD ) +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_OQUOTA_ENFD ) +if (mp->m_qflags &XFS_GQUOTA_ENFD )seq_puts (m,"," MNTOPT_GRPQUOTA );else seq_puts (m,"," MNTOPT_GQUOTANOENF );
@@ -1059,8 +1059,8 @@ xfs_fs_statfs(spin_unlock (&mp->m_sb_lock);if ((ip->i_d.di_flags &XFS_DIFLAG_PROJINHERIT ) || - ((mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_OQUOTA_ENFD ))) == - (XFS_PQUOTA_ACCT |XFS_OQUOTA_ENFD )) + ((mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ENFD ))) == + (XFS_PQUOTA_ACCT |XFS_PQUOTA_ENFD ))xfs_qm_statvfs (ip, statp);return 0 ; }
fs/xfs/xfs_trans_dquot.c +2 -2
@@ -640,8 +640,8 @@ xfs_trans_dqresv(if ((flags &XFS_QMOPT_FORCE_RES ) ==0 && dqp->q_core.d_id && ((XFS_IS_UQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISUDQ (dqp)) || - (XFS_IS_OQUOTA_ENFORCED (dqp->q_mount) && - (XFS_QM_ISPDQ (dqp) ||XFS_QM_ISGDQ (dqp))))) { + (XFS_IS_PQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISPDQ (dqp)) || + (XFS_IS_GQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISGDQ (dqp)))) {if (nblks >0 ) {/* * dquot is locked already. See if we'd go over the
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Re: [RFC v3 PATCH 1/4] xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
In reply to Chandra SeetharamanQuoted 147 lines · Chandra Seetharaman
Define new macros
XFS_GQUOTA_ENFD,XFS_GQUOTA_CHKD,XFS_PQUOTA_ENFD, andXFS_PQUOTA_CHKD.Remove incore use of
XFS_OQUOTA_ENFDandXFS_OQUOTA_CHKD. Instead, start using XFS_GQUOTA_.* XFS_PQUOTA_.* counterparts.No changes is made to the on-disk version of the superblock yet. On-disk copy still uses
XFS_OQUOTA_ENFDandXFS_OQUOTA_CHKD.Signed-off-by Chandra Seetharaman <[email protected]>--- fs/xfs/xfs_mount.c | 30 ++++++++++++++++++++++++++++++ fs/xfs/xfs_qm.c | 9 ++++++--- fs/xfs/xfs_qm_syscalls.c | 26 ++++++++++++++------------ fs/xfs/xfs_quota.h | 36 +++++++++++++++++++++++++----------- fs/xfs/xfs_quotaops.c | 6 ++++-- fs/xfs/xfs_super.c | 16 ++++++++-------- fs/xfs/xfs_trans_dquot.c | 4 ++-- 7 files changed, 89 insertions(+), 38 deletions(-)fs/xfs/xfs_quota.h +25
-11@@ -152,19 +152,34 @@ typedef struct xfs_qoff_logformat {#define XFS_GQUOTA_ACCT 0x0040/* group quota accounting ON */ /* +* Start differentiating group quota and project quota in-core +* using distinct flags, instead of using the combined OQUOTA flags. +* +* Conversion to and from the combined OQUOTA flag (if necessary) +* is done only in xfs_sb_{to,from}_disk() +*/ +#define XFS_GQUOTA_ENFD 0x0080/* group quota limits enforced */ +#define XFS_GQUOTA_CHKD 0x0100/* quotacheck run on group quotas */ +#define XFS_PQUOTA_ENFD 0x0200/* project quota limits enforced */ +#define XFS_PQUOTA_CHKD 0x0400/* quotacheck run on project quotas */ + +/* * Quota Accounting/Enforcement flags */ #define XFS_ALL_QUOTA_ACCT \ (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) -#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) -#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) +#define XFS_ALL_QUOTA_ENFD \ + (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) +#define XFS_ALL_QUOTA_CHKD \ + (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)#define XFS_IS_QUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)#define XFS_IS_UQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)#define XFS_IS_PQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)#define XFS_IS_GQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)#define XFS_IS_UQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) -#define XFS_IS_OQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD) +#define XFS_IS_PQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) +#define XFS_IS_GQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)/* * Incore only flags for quotaoff - these bits get cleared when quota(s) @@ -259,24 +274,23 @@ typedef struct xfs_qoff_logformat { ((XFS_IS_UQUOTA_ON (mp) && \ (mp->m_sb.sb_qflags &XFS_UQUOTA_CHKD ) ==0 ) || \ (XFS_IS_GQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags &XFS_PQUOTA_ACCT ))) || \ + (mp->m_sb.sb_qflags &XFS_GQUOTA_CHKD ) ==0 ) || \ (XFS_IS_PQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) + (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD)#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD)#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ - XFS_GQUOTA_ACCT) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD|\ + XFS_GQUOTA_ACCT|XFS_GQUOTA_ENFD|\ + XFS_GQUOTA_CHKD)/* fs/xfs/xfs_mount.c +29
-0@@ -593,6 +593,20 @@ xfs_sb_from_disk( to->sb_uquotino =be64_to_cpu (from->sb_uquotino); to->sb_gquotino =be64_to_cpu (from->sb_gquotino); to->sb_qflags =be16_to_cpu (from->sb_qflags); +if ((to->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && + (to->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. Fixing it.\n" ); + } +if (to->sb_qflags &XFS_OQUOTA_ENFD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ; +if (to->sb_qflags &XFS_OQUOTA_CHKD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; + to->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + to->sb_flags = from->sb_flags; to->sb_shared_vn = from->sb_shared_vn; to->sb_inoalignmt =be32_to_cpu (from->sb_inoalignmt);@@ -622,11 +636,26 @@ xfs_sb_to_disk(xfs_sb_field_t f;int first;int size; +__be16 saved_qflags;ASSERT (fields);if (!fields)return ; +/* +* in-core version of qflags do not have XFS_OQUOTA.*, whereas the +* on-disk version does. So, save the in-core sb_qflags and restore +* it after we modify and copy it to the buffer to be copied to +* disk. +*/ + saved_qflags = from->sb_qflags; + +if (from->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD )) + from->sb_qflags |=XFS_OQUOTA_ENFD ; +if (from->sb_qflags & (XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) + from->sb_qflags |=XFS_OQUOTA_CHKD ; + from->sb_qflags &= ~(XFS_PQUOTA_ENFD |XFS_PQUOTA_CHKD | +XFS_GQUOTA_ENFD |XFS_GQUOTA_CHKD );while (fields) { f = (xfs_sb_field_t )xfs_lowbit64 ((__uint64_t )fields); first = xfs_sb_info[f].offset;
fs/xfs/xfs_mount.c xfs_sb_to_disk( · line 689
Quoted 4 lines
fs/xfs/xfs_mount.c +1
-0@@ -657,6 +686,7 @@ xfs_sb_to_disk( fields &= ~(1LL << f); } + from->sb_qflags = saved_qflags;
I am disgusted that you should have to save the sb_qflags like this. After reading this 'fields' loop in xfs_sb_to_disk along with all the related crap I am actually feeling a little nauseous.
I don't know why in XFS we seem to feel the need to do everything in the most complicated way possible.
The rest of the patch looks good.
Quoted 190 lines
fs/xfs/xfs_mount.c +0
-0}/* fs/xfs/xfs_qm.c +6
-3@@ -313,8 +313,10 @@ xfs_qm_mount_quotas(*/ if (!XFS_IS_UQUOTA_ON (mp)) mp->m_qflags &= ~XFS_UQUOTA_CHKD ; -if (!(XFS_IS_GQUOTA_ON (mp) ||XFS_IS_PQUOTA_ON (mp))) - mp->m_qflags &= ~XFS_OQUOTA_CHKD ; +if (!XFS_IS_GQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_GQUOTA_CHKD ; +if (!XFS_IS_PQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_PQUOTA_CHKD ; write_changes:/* @@ -1449,7 +1451,8 @@ xfs_qm_quotacheck( XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);if (error) goto error_return; - flags |=XFS_OQUOTA_CHKD ; + flags |=XFS_IS_GQUOTA_ON (mp) ? +XFS_GQUOTA_CHKD :XFS_PQUOTA_CHKD ; } do {fs/xfs/xfs_qm_syscalls.c +14
-12@@ -121,11 +121,11 @@ xfs_qm_scall_quotaoff( }if (flags &XFS_GQUOTA_ACCT ) { dqtype |=XFS_QMOPT_GQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_GQUOTA_CHKD |XFS_GQUOTA_ENFD ); inactivate_flags |=XFS_GQUOTA_ACTIVE ; }else if (flags &XFS_PQUOTA_ACCT ) { dqtype |=XFS_QMOPT_PQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_PQUOTA_CHKD |XFS_PQUOTA_ENFD ); inactivate_flags |=XFS_PQUOTA_ACTIVE ; }@@ -349,9 +349,11 @@ xfs_qm_scall_quotaon( || ((flags & XFS_PQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && - (flags & XFS_GQUOTA_ACCT) == 0 && + (flags & XFS_PQUOTA_ENFD)) + || + ((flags & XFS_GQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && - (flags & XFS_OQUOTA_ENFD))) { + (flags & XFS_GQUOTA_ENFD))) {xfs_debug (mp,"%s: Can't enforce without acct, flags=%x sbflags=%x\n" , __func__, flags, mp->m_sb.sb_qflags);@@ -801,8 +803,8 @@ xfs_qm_export_dquot(* so return zeroes in that case. */ if ((!XFS_IS_UQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_USER ) || - (!XFS_IS_OQUOTA_ENFORCED (mp) && - (src->d_flags & (XFS_DQ_PROJ |XFS_DQ_GROUP )))) { + (!XFS_IS_PQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_PROJ ) || + (!XFS_IS_GQUOTA_ENFORCED (mp) && src->d_flags ==XFS_DQ_GROUP )) { dst->d_btimer =0 ; dst->d_itimer =0 ; dst->d_rtbtimer =0 ;@@ -810,8 +812,8 @@ xfs_qm_export_dquot(#ifdef DEBUG if (((XFS_IS_UQUOTA_ENFORCED (mp) && dst->d_flags ==FS_USER_QUOTA ) || - (XFS_IS_OQUOTA_ENFORCED (mp) && - (dst->d_flags & (FS_PROJ_QUOTA |FS_GROUP_QUOTA )))) && + (XFS_IS_PQUOTA_ENFORCED (mp) && dst->d_flags ==FS_PROJ_QUOTA ) || + (XFS_IS_GQUOTA_ENFORCED (mp) && dst->d_flags ==FS_GROUP_QUOTA )) && dst->d_id !=0 ) {if (((int ) dst->d_bcount >= (int ) dst->d_blk_softlimit) && (dst->d_blk_softlimit >0 )) {@@ -860,10 +862,10 @@ xfs_qm_export_flags( uflags |=FS_QUOTA_GDQ_ACCT ;if (flags &XFS_UQUOTA_ENFD ) uflags |=FS_QUOTA_UDQ_ENFD ; -if (flags & (XFS_OQUOTA_ENFD )) { - uflags |= (flags &XFS_GQUOTA_ACCT ) ? -FS_QUOTA_GDQ_ENFD :FS_QUOTA_PDQ_ENFD ; - } +if (flags &XFS_PQUOTA_ENFD ) + uflags |=FS_QUOTA_PDQ_ENFD ; +if (flags &XFS_GQUOTA_ENFD ) + uflags |=FS_QUOTA_GDQ_ENFD ;return (uflags); }fs/xfs/xfs_quotaops.c +4
-2@@ -76,8 +76,10 @@ xfs_fs_set_xstate( flags |=XFS_GQUOTA_ACCT ;if (uflags &FS_QUOTA_UDQ_ENFD ) flags |=XFS_UQUOTA_ENFD ; -if (uflags & (FS_QUOTA_PDQ_ENFD |FS_QUOTA_GDQ_ENFD )) - flags |=XFS_OQUOTA_ENFD ; +if (uflags &FS_QUOTA_PDQ_ENFD ) + flags |=XFS_PQUOTA_ENFD ; +if (uflags &FS_QUOTA_GDQ_ENFD ) + flags |=XFS_GQUOTA_ENFD ;switch (op) {case Q_XQUOTAON :fs/xfs/xfs_super.c +8
-8@@ -339,17 +339,17 @@ xfs_parseargs( }else if (!strcmp (this_char,MNTOPT_PQUOTA ) || !strcmp (this_char,MNTOPT_PRJQUOTA )) { mp->m_qflags |= (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE | -XFS_OQUOTA_ENFD ); +XFS_PQUOTA_ENFD ); }else if (!strcmp (this_char,MNTOPT_PQUOTANOENF )) { mp->m_qflags |= (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE ); - mp->m_qflags &= ~XFS_OQUOTA_ENFD ; + mp->m_qflags &= ~XFS_PQUOTA_ENFD ; }else if (!strcmp (this_char,MNTOPT_GQUOTA ) || !strcmp (this_char,MNTOPT_GRPQUOTA )) { mp->m_qflags |= (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE | -XFS_OQUOTA_ENFD ); +XFS_GQUOTA_ENFD ); }else if (!strcmp (this_char,MNTOPT_GQUOTANOENF )) { mp->m_qflags |= (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE ); - mp->m_qflags &= ~XFS_OQUOTA_ENFD ; + mp->m_qflags &= ~XFS_GQUOTA_ENFD ; }else if (!strcmp (this_char,MNTOPT_DELAYLOG )) {xfs_warn (mp,"delaylog is the default now, option is deprecated." );@@ -542,12 +542,12 @@ xfs_showargs(/* Either project or group quotas can be active, not both */ if (mp->m_qflags &XFS_PQUOTA_ACCT ) { -if (mp->m_qflags &XFS_OQUOTA_ENFD ) +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_OQUOTA_ENFD ) +if (mp->m_qflags &XFS_GQUOTA_ENFD )seq_puts (m,"," MNTOPT_GRPQUOTA );else seq_puts (m,"," MNTOPT_GQUOTANOENF );@@ -1059,8 +1059,8 @@ xfs_fs_statfs(spin_unlock (&mp->m_sb_lock);if ((ip->i_d.di_flags &XFS_DIFLAG_PROJINHERIT ) || - ((mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_OQUOTA_ENFD ))) == - (XFS_PQUOTA_ACCT |XFS_OQUOTA_ENFD )) + ((mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ENFD ))) == + (XFS_PQUOTA_ACCT |XFS_PQUOTA_ENFD ))xfs_qm_statvfs (ip, statp);return 0 ; }fs/xfs/xfs_trans_dquot.c +2
-2@@ -640,8 +640,8 @@ xfs_trans_dqresv(if ((flags &XFS_QMOPT_FORCE_RES ) ==0 && dqp->q_core.d_id && ((XFS_IS_UQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISUDQ (dqp)) || - (XFS_IS_OQUOTA_ENFORCED (dqp->q_mount) && - (XFS_QM_ISPDQ (dqp) ||XFS_QM_ISGDQ (dqp))))) { + (XFS_IS_PQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISPDQ (dqp)) || + (XFS_IS_GQUOTA_ENFORCED (dqp->q_mount) &&XFS_QM_ISGDQ (dqp)))) {if (nblks >0 ) {/* * dquot is locked already. See if we'd go over the Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [RFC v3 PATCH 1/4] xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
On Fri, 2012-02-10 at 18:41 -0600, Ben Myers wrote:
<snip>
Quoted 9 lines
fs/xfs/xfs_mount.c xfs_sb_to_disk( · line 689
Quoted 5 lines
fs/xfs/xfs_mount.c +1
-0@@ -657,6 +686,7 @@ xfs_sb_to_disk( fields &= ~(1LL << f); } + from->sb_qflags = saved_qflags;I am disgusted that you should have to save the
sb_qflagslike this. After reading this 'fields' loop inxfs_sb_to_diskalong with all the related crap I am actually feeling a little nauseous.
Let me know if you have any other solutions. I am open for it.
Quoted 7 lines
I don't know why in XFS we seem to feel the need to do everything in the most complicated way possible.
The rest of the patch looks good.
Reviewed-by Ben Myers <[email protected]>
Thanks.
<snip>
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [RFC v3 PATCH 1/4] xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
Hey Chandra,
Quoted 14 lines · Chandra Seetharaman
On Fri, 2012-02-10 at 18:41 -0600, Ben Myers wrote:
<snip>
Quoted 9 lines
fs/xfs/xfs_mount.c xfs_sb_to_disk( · line 689
Quoted 5 lines
fs/xfs/xfs_mount.c +1
-0@@ -657,6 +686,7 @@ xfs_sb_to_disk( fields &= ~(1LL << f); } + from->sb_qflags = saved_qflags;I am disgusted that you should have to save the
sb_qflagslike this. After reading this 'fields' loop inxfs_sb_to_diskalong with all the related crap I am actually feeling a little nauseous.
Quoted 1 line
Let me know if you have any other solutions. I am open for it.
How would you feel about something like this?
@@ -622,6 +636,7 @@ xfs_sb_to_disk(
xfs_sb_field_t f;
int first;
int size;
+ __uint16_t tmp16; ASSERT(fields);
if (!fields)@@ -636,6 +651,27 @@ xfs_sb_to_disk(
if (size == 1 || xfs_sb_info[f].type == 1) {
memcpy(to_ptr + first, from_ptr + first, size);
+ } else if (f == XFS_SBS_QFLAGS) {
+ /*
+ * The in-core version of sb_qflags do not have
+ * XFS_OQUOTA_* flags, whereas the on-disk version
+ * does. Save the in-core sb_qflags temporarily,
+ * removing the new XFS_{PG}QUOTA_* flags and re-apply
+ * the old on-disk flags. This is a temporary
+ * situation until the on-disk flags are updated.
+ */+ tmp16 = from->sb_qflags &
+ ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD |
+ XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD);
+
+ if (from->sb_qflags &
+ (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD))
+ tmp16 |= XFS_OQUOTA_ENFD;
+ if (from->sb_qflags &
+ (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD))
+ tmp16 |= XFS_OQUOTA_CHKD;
+
+ *(__be16 *)(to_ptr + first) = cpu_to_be16(tmp16);
} else {
switch (size) {
case 2:This way we needn't worry about any change (or locking) of the incore superblock sb_qflags.
Quoted 2 lines
Quoted 2 lines
I don't know why in XFS we seem to feel the need to do everything in the most complicated way possible.
I suppose they were trying to cut down on conditionals on fields... maybe something that could be done better at compile time... someday.
Regards,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [RFC v3 PATCH 1/4] xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
Fine by me. Will make these changes in my next version.
But, the situation may not be temporary as we have to support OQUOTA for backward compatibility reasons.
Chandra
Quoted 67 lines · Ben Myers
Hey Chandra,
Quoted 14 lines · Chandra Seetharaman
On Fri, 2012-02-10 at 18:41 -0600, Ben Myers wrote:
<snip>
Quoted 9 lines
fs/xfs/xfs_mount.c xfs_sb_to_disk( · line 689
Quoted 5 lines
fs/xfs/xfs_mount.c +1
-0@@ -657,6 +686,7 @@ xfs_sb_to_disk( fields &= ~(1LL << f); } + from->sb_qflags = saved_qflags;I am disgusted that you should have to save the
sb_qflagslike this. After reading this 'fields' loop inxfs_sb_to_diskalong with all the related crap I am actually feeling a little nauseous.Quoted 1 line
Let me know if you have any other solutions. I am open for it.
How would you feel about something like this?
fs/xfs/xfs_mount.c +22
-0@@ -622,6 +636,7 @@ xfs_sb_to_disk(xfs_sb_field_t f;int first;int size;GMCR + __uint16_t tmp16;ASSERT (fields);if (!fields)@@ -636,6 +651,27 @@ xfs_sb_to_disk(if (size ==1 || xfs_sb_info[f].type ==1 ) {memcpy (to_ptr + first, from_ptr + first, size); + }else if (f ==XFS_SBS_QFLAGS ) { +/* +* The in-core version of sb_qflags do not have +* XFS_OQUOTA_* flags, whereas the on-disk version +* does. Save the in-core sb_qflags temporarily, +* removing the new XFS_{PG}QUOTA_* flags and re-apply +* the old on-disk flags. This is a temporary +* situation until the on-disk flags are updated. +*/ + tmp16 = from->sb_qflags & + ~(XFS_PQUOTA_ENFD |XFS_PQUOTA_CHKD | +XFS_GQUOTA_ENFD |XFS_GQUOTA_CHKD ); + +if (from->sb_qflags & + (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD )) + tmp16 |=XFS_OQUOTA_ENFD ; +if (from->sb_qflags & + (XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) + tmp16 |=XFS_OQUOTA_CHKD ; + + *(__be16 *)(to_ptr + first) =cpu_to_be16 (tmp16); }else {switch (size) {case 2 :This way we needn't worry about any change (or locking) of the incore superblock
sb_qflags.Quoted 2 lines
Quoted 2 lines
I don't know why in XFS we seem to feel the need to do everything in the most complicated way possible.
I suppose they were trying to cut down on conditionals on fields... maybe something that could be done better at compile time... someday.
Quoted 8 lines
Regards,
Ben_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [RFC v3 PATCH 1/4] xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
In reply to Chandra SeetharamanHi Chandra,
Here are some cleanups caught by the script inscripts/checkpatch.pl
Quoted 99 lines · Chandra Seetharaman
Define new macros
XFS_GQUOTA_ENFD,XFS_GQUOTA_CHKD,XFS_PQUOTA_ENFD, andXFS_PQUOTA_CHKD.Remove incore use of
XFS_OQUOTA_ENFDandXFS_OQUOTA_CHKD. Instead, start using XFS_GQUOTA_.* XFS_PQUOTA_.* counterparts.No changes is made to the on-disk version of the superblock yet. On-disk copy still uses
XFS_OQUOTA_ENFDandXFS_OQUOTA_CHKD.Signed-off-by Chandra Seetharaman <[email protected]>--- fs/xfs/xfs_mount.c | 30 ++++++++++++++++++++++++++++++ fs/xfs/xfs_qm.c | 9 ++++++--- fs/xfs/xfs_qm_syscalls.c | 26 ++++++++++++++------------ fs/xfs/xfs_quota.h | 36 +++++++++++++++++++++++++----------- fs/xfs/xfs_quotaops.c | 6 ++++-- fs/xfs/xfs_super.c | 16 ++++++++-------- fs/xfs/xfs_trans_dquot.c | 4 ++-- 7 files changed, 89 insertions(+), 38 deletions(-)fs/xfs/xfs_quota.h +25
-11@@ -152,19 +152,34 @@ typedef struct xfs_qoff_logformat {#define XFS_GQUOTA_ACCT 0x0040/* group quota accounting ON */ /* +* Start differentiating group quota and project quota in-core +* using distinct flags, instead of using the combined OQUOTA flags. +* +* Conversion to and from the combined OQUOTA flag (if necessary) +* is done only in xfs_sb_{to,from}_disk() +*/ +#define XFS_GQUOTA_ENFD 0x0080/* group quota limits enforced */ +#define XFS_GQUOTA_CHKD 0x0100/* quotacheck run on group quotas */ +#define XFS_PQUOTA_ENFD 0x0200/* project quota limits enforced */ +#define XFS_PQUOTA_CHKD 0x0400/* quotacheck run on project quotas */ + +/* * Quota Accounting/Enforcement flags */ #define XFS_ALL_QUOTA_ACCT \ (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) -#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) -#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) +#define XFS_ALL_QUOTA_ENFD \ + (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) +#define XFS_ALL_QUOTA_CHKD \ + (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)#define XFS_IS_QUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)#define XFS_IS_UQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)#define XFS_IS_PQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)#define XFS_IS_GQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)#define XFS_IS_UQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) -#define XFS_IS_OQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD) +#define XFS_IS_PQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) +#define XFS_IS_GQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)/* * Incore only flags for quotaoff - these bits get cleared when quota(s) @@ -259,24 +274,23 @@ typedef struct xfs_qoff_logformat { ((XFS_IS_UQUOTA_ON (mp) && \ (mp->m_sb.sb_qflags &XFS_UQUOTA_CHKD ) ==0 ) || \ (XFS_IS_GQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags &XFS_PQUOTA_ACCT ))) || \ + (mp->m_sb.sb_qflags &XFS_GQUOTA_CHKD ) ==0 ) || \ (XFS_IS_PQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) + (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD)#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD)#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ - XFS_GQUOTA_ACCT) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD|\ + XFS_GQUOTA_ACCT|XFS_GQUOTA_ENFD|\ + XFS_GQUOTA_CHKD)/* fs/xfs/xfs_mount.c +0
-0
fs/xfs/xfs_mount.c xfs_sb_from_disk( · line 597
Quoted 5 lines
fs/xfs/xfs_mount.c +2
-0@@ -593,6 +593,20 @@ xfs_sb_from_disk( to->sb_uquotino =be64_to_cpu (from->sb_uquotino); to->sb_gquotino =be64_to_cpu (from->sb_gquotino); to->sb_qflags =be16_to_cpu (from->sb_qflags); + if ((to->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) && + (to->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD |
ERROR: need consistent spacing around '|' (ctx:WxV) #115: FILE: fs/xfs/xfs_mount.c:597:
+ (to->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD |
^
fs/xfs/xfs_mount.c xfs_sb_from_disk( · line 598
Quoted 1 line
fs/xfs/xfs_mount.c +1
-0+ XFS_PQUOTA_CHKD| XFS_GQUOTA_CHKD))) {
ERROR: need consistent spacing around '|' (ctx:VxW) #116: FILE: fs/xfs/xfs_mount.c:598:
+ XFS_PQUOTA_CHKD| XFS_GQUOTA_CHKD))) {
^Quoted 17 lines
fs/xfs/xfs_mount.c +11
-0+xfs_notice (mp,"Super block has XFS_OQUOTA bits along with " +"XFS_PQUOTA and/or XFS_GQUOTA bits. Fixing it.\n" ); + } +if (to->sb_qflags &XFS_OQUOTA_ENFD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ; +if (to->sb_qflags &XFS_OQUOTA_CHKD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; + to->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + to->sb_flags = from->sb_flags; to->sb_shared_vn = from->sb_shared_vn; to->sb_inoalignmt =be32_to_cpu (from->sb_inoalignmt);@@ -622,11 +636,26 @@ xfs_sb_to_disk(xfs_sb_field_t f;int first;
fs/xfs/xfs_mount.c xfs_sb_to_disk( · line 647
Quoted 10 lines
fs/xfs/xfs_mount.c +4
-0int size; +__be16 saved_qflags;ASSERT (fields);if (!fields)return ; +/* +* in-core version of qflags do not have XFS_OQUOTA.*, whereas the +* on-disk version does. So, save the in-core sb_qflags and restore
ERROR: code indent should use tabs where possible
#143: FILE: fs/xfs/xfs_mount.c:647:
+ ^I * on-disk version does. So, save the in-core sb_qflags and restore$
WARNING: please, no space before tabs
#143: FILE: fs/xfs/xfs_mount.c:647:
+ ^I * on-disk version does. So, save the in-core sb_qflags and restore$
Quoted 82 lines
fs/xfs/xfs_mount.c +12
-0+* it after we modify and copy it to the buffer to be copied to +* disk. +*/ + saved_qflags = from->sb_qflags; + +if (from->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD )) + from->sb_qflags |=XFS_OQUOTA_ENFD ; +if (from->sb_qflags & (XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) + from->sb_qflags |=XFS_OQUOTA_CHKD ; + from->sb_qflags &= ~(XFS_PQUOTA_ENFD |XFS_PQUOTA_CHKD | +XFS_GQUOTA_ENFD |XFS_GQUOTA_CHKD );while (fields) { f = (xfs_sb_field_t )xfs_lowbit64 ((__uint64_t )fields); first = xfs_sb_info[f].offset;@@ -657,6 +686,7 @@ xfs_sb_to_disk( fields &= ~(1LL << f); } + from->sb_qflags = saved_qflags; }/* fs/xfs/xfs_qm.c +6
-3@@ -313,8 +313,10 @@ xfs_qm_mount_quotas(*/ if (!XFS_IS_UQUOTA_ON (mp)) mp->m_qflags &= ~XFS_UQUOTA_CHKD ; -if (!(XFS_IS_GQUOTA_ON (mp) ||XFS_IS_PQUOTA_ON (mp))) - mp->m_qflags &= ~XFS_OQUOTA_CHKD ; +if (!XFS_IS_GQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_GQUOTA_CHKD ; +if (!XFS_IS_PQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_PQUOTA_CHKD ; write_changes:/* @@ -1449,7 +1451,8 @@ xfs_qm_quotacheck( XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);if (error) goto error_return; - flags |=XFS_OQUOTA_CHKD ; + flags |=XFS_IS_GQUOTA_ON (mp) ? +XFS_GQUOTA_CHKD :XFS_PQUOTA_CHKD ; } do {fs/xfs/xfs_qm_syscalls.c +6
-4@@ -121,11 +121,11 @@ xfs_qm_scall_quotaoff( }if (flags &XFS_GQUOTA_ACCT ) { dqtype |=XFS_QMOPT_GQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_GQUOTA_CHKD |XFS_GQUOTA_ENFD ); inactivate_flags |=XFS_GQUOTA_ACTIVE ; }else if (flags &XFS_PQUOTA_ACCT ) { dqtype |=XFS_QMOPT_PQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_PQUOTA_CHKD |XFS_PQUOTA_ENFD ); inactivate_flags |=XFS_PQUOTA_ACTIVE ; }@@ -349,9 +349,11 @@ xfs_qm_scall_quotaon( || ((flags & XFS_PQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && - (flags & XFS_GQUOTA_ACCT) == 0 && + (flags & XFS_PQUOTA_ENFD)) + || + ((flags & XFS_GQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && - (flags & XFS_OQUOTA_ENFD))) { + (flags & XFS_GQUOTA_ENFD))) {xfs_debug (mp,"%s: Can't enforce without acct, flags=%x sbflags=%x\n" , __func__, flags, mp->m_sb.sb_qflags);
fs/xfs/xfs_qm_syscalls.c xfs_qm_export_dquot( · line 806
Quoted 6 lines
fs/xfs/xfs_qm_syscalls.c +1
-2@@ -801,8 +803,8 @@ xfs_qm_export_dquot(* so return zeroes in that case. */ if ((!XFS_IS_UQUOTA_ENFORCED(mp) && src->d_flags == XFS_DQ_USER) || - (!XFS_IS_OQUOTA_ENFORCED (mp) && - (src->d_flags & (XFS_DQ_PROJ |XFS_DQ_GROUP )))) { + (!XFS_IS_PQUOTA_ENFORCED(mp) && src->d_flags == XFS_DQ_PROJ) ||
ERROR: trailing whitespace
#231: FILE: fs/xfs/xfs_qm_syscalls.c:806:
+^I (!XFS_IS_PQUOTA_ENFORCED(mp) && src->d_flags == XFS_DQ_PROJ) || $
I suggest you run the script on your other patches as well...
Regards,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [RFC v3 PATCH 1/4] xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
oops. will clean up and resend.
sorry.
Quoted 255 lines · Ben Myers
Hi Chandra,
Here are some cleanups caught by the script in
scripts/checkpatch.plQuoted 99 lines · Chandra Seetharaman
Define new macros
XFS_GQUOTA_ENFD,XFS_GQUOTA_CHKD,XFS_PQUOTA_ENFD, andXFS_PQUOTA_CHKD.Remove incore use of
XFS_OQUOTA_ENFDandXFS_OQUOTA_CHKD. Instead, start using XFS_GQUOTA_.* XFS_PQUOTA_.* counterparts.No changes is made to the on-disk version of the superblock yet. On-disk copy still uses
XFS_OQUOTA_ENFDandXFS_OQUOTA_CHKD.Signed-off-by Chandra Seetharaman <[email protected]>--- fs/xfs/xfs_mount.c | 30 ++++++++++++++++++++++++++++++ fs/xfs/xfs_qm.c | 9 ++++++--- fs/xfs/xfs_qm_syscalls.c | 26 ++++++++++++++------------ fs/xfs/xfs_quota.h | 36 +++++++++++++++++++++++++----------- fs/xfs/xfs_quotaops.c | 6 ++++-- fs/xfs/xfs_super.c | 16 ++++++++-------- fs/xfs/xfs_trans_dquot.c | 4 ++-- 7 files changed, 89 insertions(+), 38 deletions(-)fs/xfs/xfs_quota.h +25
-11@@ -152,19 +152,34 @@ typedef struct xfs_qoff_logformat {#define XFS_GQUOTA_ACCT 0x0040/* group quota accounting ON */ /* +* Start differentiating group quota and project quota in-core +* using distinct flags, instead of using the combined OQUOTA flags. +* +* Conversion to and from the combined OQUOTA flag (if necessary) +* is done only in xfs_sb_{to,from}_disk() +*/ +#define XFS_GQUOTA_ENFD 0x0080/* group quota limits enforced */ +#define XFS_GQUOTA_CHKD 0x0100/* quotacheck run on group quotas */ +#define XFS_PQUOTA_ENFD 0x0200/* project quota limits enforced */ +#define XFS_PQUOTA_CHKD 0x0400/* quotacheck run on project quotas */ + +/* * Quota Accounting/Enforcement flags */ #define XFS_ALL_QUOTA_ACCT \ (XFS_UQUOTA_ACCT | XFS_GQUOTA_ACCT | XFS_PQUOTA_ACCT) -#define XFS_ALL_QUOTA_ENFD (XFS_UQUOTA_ENFD | XFS_OQUOTA_ENFD) -#define XFS_ALL_QUOTA_CHKD (XFS_UQUOTA_CHKD | XFS_OQUOTA_CHKD) +#define XFS_ALL_QUOTA_ENFD \ + (XFS_UQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_ENFD) +#define XFS_ALL_QUOTA_CHKD \ + (XFS_UQUOTA_CHKD | XFS_GQUOTA_CHKD | XFS_PQUOTA_CHKD)#define XFS_IS_QUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_ALL_QUOTA_ACCT)#define XFS_IS_UQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_UQUOTA_ACCT)#define XFS_IS_PQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_PQUOTA_ACCT)#define XFS_IS_GQUOTA_RUNNING (mp) ((mp)->m_qflags & XFS_GQUOTA_ACCT)#define XFS_IS_UQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_UQUOTA_ENFD) -#define XFS_IS_OQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_OQUOTA_ENFD) +#define XFS_IS_PQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_PQUOTA_ENFD) +#define XFS_IS_GQUOTA_ENFORCED (mp) ((mp)->m_qflags & XFS_GQUOTA_ENFD)/* * Incore only flags for quotaoff - these bits get cleared when quota(s) @@ -259,24 +274,23 @@ typedef struct xfs_qoff_logformat { ((XFS_IS_UQUOTA_ON (mp) && \ (mp->m_sb.sb_qflags &XFS_UQUOTA_CHKD ) ==0 ) || \ (XFS_IS_GQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags &XFS_PQUOTA_ACCT ))) || \ + (mp->m_sb.sb_qflags &XFS_GQUOTA_CHKD ) ==0 ) || \ (XFS_IS_PQUOTA_ON (mp) && \ - ((mp->m_sb.sb_qflags &XFS_OQUOTA_CHKD ) ==0 || \ - (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT)))) + (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0))#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD)#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD) + XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD)#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_OQUOTA_ENFD|XFS_OQUOTA_CHKD|\ - XFS_GQUOTA_ACCT) + XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD|\ + XFS_GQUOTA_ACCT|XFS_GQUOTA_ENFD|\ + XFS_GQUOTA_CHKD)/* fs/xfs/xfs_mount.c +0
-0fs/xfs/xfs_mount.c xfs_sb_from_disk( · line 597
Quoted 5 lines
fs/xfs/xfs_mount.c +2
-0@@ -593,6 +593,20 @@ xfs_sb_from_disk( to->sb_uquotino =be64_to_cpu (from->sb_uquotino); to->sb_gquotino =be64_to_cpu (from->sb_gquotino); to->sb_qflags =be16_to_cpu (from->sb_qflags); + if ((to->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) && + (to->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD |ERROR: need consistent spacing around '|' (ctx:WxV) #115: FILE:
fs/xfs/xfs_mount.c:597:
+ (to->sb_qflags& (XFS_PQUOTA_ENFD|XFS_GQUOTA_ENFD |^fs/xfs/xfs_mount.c xfs_sb_from_disk( · line 598
Quoted 1 line
fs/xfs/xfs_mount.c +1
-0+ XFS_PQUOTA_CHKD| XFS_GQUOTA_CHKD))) {ERROR: need consistent spacing around '|' (ctx:VxW) #116: FILE:
fs/xfs/xfs_mount.c:598:+ XFS_PQUOTA_CHKD| XFS_GQUOTA_CHKD))) { ^Quoted 17 lines
fs/xfs/xfs_mount.c +11
-0+xfs_notice (mp,"Super block has XFS_OQUOTA bits along with " +"XFS_PQUOTA and/or XFS_GQUOTA bits. Fixing it.\n" ); + } +if (to->sb_qflags &XFS_OQUOTA_ENFD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ; +if (to->sb_qflags &XFS_OQUOTA_CHKD ) + to->sb_qflags |= (to->sb_qflags &XFS_PQUOTA_ACCT ) ? +XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; + to->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + to->sb_flags = from->sb_flags; to->sb_shared_vn = from->sb_shared_vn; to->sb_inoalignmt =be32_to_cpu (from->sb_inoalignmt);@@ -622,11 +636,26 @@ xfs_sb_to_disk(xfs_sb_field_t f;int first;fs/xfs/xfs_mount.c xfs_sb_to_disk( · line 647
Quoted 10 lines
fs/xfs/xfs_mount.c +4
-0int size; +__be16 saved_qflags;ASSERT (fields);if (!fields)return ; +/* +* in-core version of qflags do not have XFS_OQUOTA.*, whereas the +* on-disk version does. So, save the in-core sb_qflags and restore ERROR: code indent should use tabs where possible
#143: FILE:fs/xfs/xfs_mount.c:647:
+ ^I * on-disk version does. So, save the in-coresb_qflagsand restore$WARNING: please, no space before tabs
#143: FILE:fs/xfs/xfs_mount.c:647:
+ ^I * on-disk version does. So, save the in-coresb_qflagsand restore$Quoted 82 lines
fs/xfs/xfs_mount.c +12
-0+* it after we modify and copy it to the buffer to be copied to +* disk. +*/ + saved_qflags = from->sb_qflags; + +if (from->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD )) + from->sb_qflags |=XFS_OQUOTA_ENFD ; +if (from->sb_qflags & (XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) + from->sb_qflags |=XFS_OQUOTA_CHKD ; + from->sb_qflags &= ~(XFS_PQUOTA_ENFD |XFS_PQUOTA_CHKD | +XFS_GQUOTA_ENFD |XFS_GQUOTA_CHKD );while (fields) { f = (xfs_sb_field_t )xfs_lowbit64 ((__uint64_t )fields); first = xfs_sb_info[f].offset;@@ -657,6 +686,7 @@ xfs_sb_to_disk( fields &= ~(1LL << f); } + from->sb_qflags = saved_qflags; }/* fs/xfs/xfs_qm.c +6
-3@@ -313,8 +313,10 @@ xfs_qm_mount_quotas(*/ if (!XFS_IS_UQUOTA_ON (mp)) mp->m_qflags &= ~XFS_UQUOTA_CHKD ; -if (!(XFS_IS_GQUOTA_ON (mp) ||XFS_IS_PQUOTA_ON (mp))) - mp->m_qflags &= ~XFS_OQUOTA_CHKD ; +if (!XFS_IS_GQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_GQUOTA_CHKD ; +if (!XFS_IS_PQUOTA_ON (mp)) + mp->m_qflags &= ~XFS_PQUOTA_CHKD ; write_changes:/* @@ -1449,7 +1451,8 @@ xfs_qm_quotacheck( XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);if (error) goto error_return; - flags |=XFS_OQUOTA_CHKD ; + flags |=XFS_IS_GQUOTA_ON (mp) ? +XFS_GQUOTA_CHKD :XFS_PQUOTA_CHKD ; } do {fs/xfs/xfs_qm_syscalls.c +6
-4@@ -121,11 +121,11 @@ xfs_qm_scall_quotaoff( }if (flags &XFS_GQUOTA_ACCT ) { dqtype |=XFS_QMOPT_GQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_GQUOTA_CHKD |XFS_GQUOTA_ENFD ); inactivate_flags |=XFS_GQUOTA_ACTIVE ; }else if (flags &XFS_PQUOTA_ACCT ) { dqtype |=XFS_QMOPT_PQUOTA ; - flags |= (XFS_OQUOTA_CHKD |XFS_OQUOTA_ENFD ); + flags |= (XFS_PQUOTA_CHKD |XFS_PQUOTA_ENFD ); inactivate_flags |=XFS_PQUOTA_ACTIVE ; }@@ -349,9 +349,11 @@ xfs_qm_scall_quotaon( || ((flags & XFS_PQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_PQUOTA_ACCT) == 0 && - (flags & XFS_GQUOTA_ACCT) == 0 && + (flags & XFS_PQUOTA_ENFD)) + || + ((flags & XFS_GQUOTA_ACCT) == 0 && (mp->m_sb.sb_qflags & XFS_GQUOTA_ACCT) == 0 && - (flags & XFS_OQUOTA_ENFD))) { + (flags & XFS_GQUOTA_ENFD))) {xfs_debug (mp,"%s: Can't enforce without acct, flags=%x sbflags=%x\n" , __func__, flags, mp->m_sb.sb_qflags);fs/xfs/xfs_qm_syscalls.c xfs_qm_export_dquot( · line 806
Quoted 6 lines
fs/xfs/xfs_qm_syscalls.c +1
-2@@ -801,8 +803,8 @@ xfs_qm_export_dquot(* so return zeroes in that case. */ if ((!XFS_IS_UQUOTA_ENFORCED(mp) && src->d_flags == XFS_DQ_USER) || - (!XFS_IS_OQUOTA_ENFORCED (mp) && - (src->d_flags & (XFS_DQ_PROJ |XFS_DQ_GROUP )))) { + (!XFS_IS_PQUOTA_ENFORCED(mp) && src->d_flags == XFS_DQ_PROJ) ||ERROR: trailing whitespace
#231: FILE:fs/xfs/xfs_qm_syscalls.c:806:
+^I (!XFS_IS_PQUOTA_ENFORCED(mp) &&src->d_flags==XFS_DQ_PROJ) || $
Quoted 5 lines
I suggest you run the script on your other patches as well...
Regards,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Re: [RFC v3 PATCH 1/4] xfs: Remove incore use of XFS_OQUOTA_ENFD and XFS_OQUOTA_CHKD
Quoted 3 lines · Chandra Seetharaman
oops. will clean up and resend.
sorry.
Don't be. This is good work.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
RFC PATCH v3 2/4 xfs: Add pquota fields where gquota is used.
In reply to Chandra SeetharamanAdd project quota changes to all the places where group quota field is used.
No externally visible changed and no superblock changes, yet.
--- fs/xfs/xfs_dquot.c | 17 +++- fs/xfs/xfs_dquot.h | 9 ++- fs/xfs/xfs_iget.c | 2 +- fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_ioctl.c | 12 +- fs/xfs/xfs_iops.c | 4 +- fs/xfs/xfs_qm.c | 259 ++++++++++++++++++++++++++++++++-------------- fs/xfs/xfs_qm.h | 7 +- fs/xfs/xfs_qm_bhv.c | 2 +- fs/xfs/xfs_qm_syscalls.c | 19 +++- fs/xfs/xfs_quota.h | 38 ++++--- fs/xfs/xfs_quota_priv.h | 6 +- fs/xfs/xfs_sb.h | 1 + fs/xfs/xfs_super.c | 5 +- fs/xfs/xfs_trans_dquot.c | 71 ++++++++++--- fs/xfs/xfs_vnodeops.c | 23 +++-- 16 files changed, 330 insertions(+), 146 deletions(-)
fs/xfs/xfs_quota.h +21 -17
@@ -186,9 +186,9 @@ typedef struct xfs_qoff_logformat {* are in the process of getting turned off. These flags are in m_qflags but * never in sb_qflags. */ -#define XFS_UQUOTA_ACTIVE 0x0100/* uquotas are being turned off */ -#define XFS_PQUOTA_ACTIVE 0x0200/* pquotas are being turned off */ -#define XFS_GQUOTA_ACTIVE 0x0400/* gquotas are being turned off */ +#define XFS_UQUOTA_ACTIVE 0x1000/* uquotas are being turned off */ +#define XFS_PQUOTA_ACTIVE 0x2000/* pquotas are being turned off */ +#define XFS_GQUOTA_ACTIVE 0x4000/* gquotas are being turned off */ #define XFS_ALL_QUOTA_ACTIVE \ (XFS_UQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE)
@@ -199,8 +199,6 @@ typedef struct xfs_qoff_logformat {#define XFS_IS_QUOTA_ON (mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \ XFS_GQUOTA_ACTIVE | \ XFS_PQUOTA_ACTIVE)) -#define XFS_IS_OQUOTA_ON (mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \ - XFS_PQUOTA_ACTIVE))#define XFS_IS_UQUOTA_ON (mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE)#define XFS_IS_GQUOTA_ON (mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE)#define XFS_IS_PQUOTA_ON (mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE)
@@ -267,8 +265,10 @@ typedef struct xfs_qoff_logformat {*/ #define XFS_NOT_DQATTACHED (mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\ (ip)->i_udquot == NULL) || \ - (XFS_IS_OQUOTA_ON(mp) && \ - (ip)->i_gdquot == 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) && \
@@ -323,17 +323,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 *);
@@ -347,10 +348,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, +xfs_dquot **pdqp) { *udqp =NULL ; *gdqp =NULL ; + *pdqp =NULL ;return 0 ; }#define xfs_trans_dup_dqinfo (tp, tp2)
@@ -365,14 +368,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)
@@ -386,8 +390,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_quota_priv.h +1 -5
@@ -30,11 +30,7 @@#define XFS_DQ_HASHVAL (mp, id) (((__psunsigned_t)(mp) + \ (__psunsigned_t)(id)) & \ (xfs_Gqm->qm_dqhashmask - 1)) -#define XFS_DQ_HASH (mp, id, type) (type == XFS_DQ_USER ? \ - (xfs_Gqm->qm_usr_dqhtable + \ - XFS_DQ_HASHVAL(mp, id)) : \ - (xfs_Gqm->qm_grp_dqhtable + \ - XFS_DQ_HASHVAL(mp, id))) +#define XFS_IS_DQUOT_UNINITIALIZED (dqp) ( \ !dqp->q_core.d_blk_hardlimit && \ !dqp->q_core.d_blk_softlimit && \
fs/xfs/xfs_sb.h +1 -0
@@ -140,6 +140,7 @@ typedef struct xfs_sb {*/ xfs_ino_t sb_uquotino;/* user quota inode */ xfs_ino_t sb_gquotino;/* group quota inode */ +#define sb_pquotino sb_gquotino__uint16_t sb_qflags;/* quota flags */ __uint8_t sb_flags;/* misc. flags */ __uint8_t sb_shared_vn;/* shared version number */
fs/xfs/xfs_qm.h +4 -3
@@ -68,6 +68,7 @@ typedef xfs_dqhash_t xfs_dqlist_t; typedef struct xfs_qm { xfs_dqlist_t *qm_usr_dqhtable;/* udquot hash table */ xfs_dqlist_t *qm_grp_dqhtable;/* gdquot hash table */ + xfs_dqlist_t *qm_prj_dqhtable;/* project hash table */ uint qm_dqhashmask; /* # buckets in dq hashtab - 1 */ struct list_head qm_dqfrlist; /* freelist of dquots */ struct mutex qm_dqfrlist_lock;
@@ -86,6 +87,7 @@ typedef struct xfs_qm { typedef struct xfs_quotainfo { xfs_inode_t *qi_uquotaip; /* user quota inode */ xfs_inode_t *qi_gquotaip; /* group quota inode */ + xfs_inode_t *qi_pquotaip; /* project quota inode */ struct list_head qi_dqlist; /* all dquots in filesys */ struct mutex qi_dqlist_lock; int qi_dquots;
@@ -110,13 +112,11 @@ typedef struct xfs_quotainfo {extern void xfs_trans_mod_dquot (xfs_trans_t *,xfs_dquot_t *,uint ,long ); -extern int xfs_trans_reserve_quota_bydquots (xfs_trans_t *,xfs_mount_t *, -xfs_dquot_t *,xfs_dquot_t *,long ,long ,uint );extern void xfs_trans_dqjoin (xfs_trans_t *,xfs_dquot_t *);extern void xfs_trans_log_dquot (xfs_trans_t *,xfs_dquot_t *);/* -* We keep the usr and grp dquots separately so that locking will be easier +* 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. */
@@ -124,6 +124,7 @@ extern void xfs_trans_log_dquot(xfs_trans_t *, xfs_dquot_t *);typedef struct xfs_dquot_acct {xfs_dqtrx_t dqa_usrdquots[XFS_QM_TRANS_MAXDQS ];xfs_dqtrx_t dqa_grpdquots[XFS_QM_TRANS_MAXDQS ]; +xfs_dqtrx_t dqa_prjdquots[XFS_QM_TRANS_MAXDQS ]; }xfs_dquot_acct_t ;/*
fs/xfs/xfs_inode.h +1 -0
@@ -224,6 +224,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_dquot.h +7 -2
@@ -59,6 +59,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 */
@@ -122,8 +123,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 ; }
@@ -136,6 +138,7 @@ 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_PROJ : +return ip->i_pdquot;case XFS_DQ_GROUP :return ip->i_gdquot;default :
@@ -151,7 +154,9 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)#define XFS_DQ_TO_QINF (dqp) ((dqp)->q_mount->m_quotainfo)#define XFS_DQ_TO_QIP (dqp) (XFS_QM_ISUDQ(dqp) ? \ XFS_DQ_TO_QINF(dqp)->qi_uquotaip : \ - XFS_DQ_TO_QINF(dqp)->qi_gquotaip) + (XFS_QM_ISGDQ(dqp) ? \ + XFS_DQ_TO_QINF(dqp)->qi_gquotaip : \ + XFS_DQ_TO_QINF(dqp)->qi_pquotaip))extern int xfs_qm_dqread (struct xfs_mount *,xfs_dqid_t ,uint ,uint ,struct xfs_dquot **);
fs/xfs/xfs_dquot.c +16 -1
@@ -706,6 +706,21 @@ xfs_qm_dqlookup(return 1 ; } +static struct xfs_dqhash *xfs_dq_hash (struct xfs_mount *mp, +xfs_dqid_t id,uint type) +{ +switch (type) { +case XFS_DQ_USER : +return (xfs_Gqm->qm_usr_dqhtable +XFS_DQ_HASHVAL (mp, id)); +case XFS_DQ_GROUP : +return (xfs_Gqm->qm_grp_dqhtable +XFS_DQ_HASHVAL (mp, id)); +case XFS_DQ_PROJ : +return (xfs_Gqm->qm_prj_dqhtable +XFS_DQ_HASHVAL (mp, id)); +default : +return NULL ; + } +} +/* * Given the file system, inode OR id, and type (UDQUOT/GDQUOT), return a * a locked dquot, doing an allocation (if requested) as needed.
@@ -734,7 +749,7 @@ xfs_qm_dqget( (! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) {return (ESRCH ); } - h =XFS_DQ_HASH (mp, id, type); + h =xfs_dq_hash (mp, id, type);#ifdef DEBUG if (xfs_do_dqerror) {
fs/xfs/xfs_iget.c +1 -1
@@ -362,7 +362,7 @@ xfs_iget_cache_miss( }/* These values _must_ be set before releasing the radix tree lock! */ - ip->i_udquot = ip->i_gdquot =NULL ; + ip->i_udquot = ip->i_gdquot = ip->i_pdquot =NULL ;xfs_iflags_set (ip,XFS_INEW );spin_unlock (&pag->pag_ici_lock);
fs/xfs/xfs_ioctl.c +6 -6
@@ -907,7 +907,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;
@@ -936,7 +936,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; }
@@ -973,7 +973,7 @@ 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, + code =xfs_qm_vop_chown_reserve (tp, ip, udqp,NULL , pdqp,capable (CAP_FOWNER ) ?XFS_QMOPT_FORCE_RES :0 );if (code)/* out of quota */
@@ -1092,7 +1092,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);
@@ -1139,13 +1139,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
@@ -569,7 +569,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; }
@@ -604,7 +604,7 @@ xfs_setattr_nonsize( ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {ASSERT (tp); - error =xfs_qm_vop_chown_reserve (tp, ip, udqp, gdqp, + error =xfs_qm_vop_chown_reserve (tp, ip, udqp, gdqp,NULL ,capable (CAP_FOWNER ) ?XFS_QMOPT_FORCE_RES :0 );if (error)/* out of quota */
fs/xfs/xfs_qm.c +181 -78
547 lines not on this page · raw message
fs/xfs/xfs_qm_bhv.c +1 -1
@@ -117,7 +117,7 @@ xfs_qm_newmount( (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))) && xfs_dev_is_read_only(mp, "changing quota state")) { xfs_warn(mp, "please mount with%s%s%s%s.", (!quotaondisk ? "out quota" : ""),
fs/xfs/xfs_qm_syscalls.c +15 -4
@@ -123,7 +123,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 ;
@@ -223,10 +224,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);
@@ -878,9 +883,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 ; }
@@ -889,10 +896,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_super.c +2 -3
@@ -539,14 +539,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
fs/xfs/xfs_trans_dquot.c +56 -15
152 lines not on this page · raw message
fs/xfs/xfs_vnodeops.c +15 -8
@@ -851,6 +851,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;
@@ -869,7 +870,7 @@ 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;
@@ -929,7 +930,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;
@@ -993,7 +995,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)
@@ -1005,6 +1007,7 @@ xfs_create(xfs_qm_dqrele (udqp);xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp); *ipp = ip;return 0 ;
@@ -1026,6 +1029,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 );
@@ -1516,7 +1520,7 @@ xfs_symlink(int n;xfs_buf_t *bp;prid_t prid; -struct xfs_dquot *udqp, *gdqp; +struct xfs_dquot *udqp, *gdqp, *pdqp;uint resblks; *ipp =NULL ;
@@ -1546,7 +1550,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;
@@ -1587,7 +1591,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;
@@ -1625,7 +1630,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);
@@ -1709,6 +1714,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 ;
@@ -1722,6 +1728,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 );
@@ -2188,7 +2195,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
RFC PATCH v3 2/4 xfs: Add pquota fields where gquota is used.
#pwhite: Most of the changes fall into two categories.
# 1) Changing the check for OQUOTA to mean either GQUOTA or PQUOTA to an
# inclusive or.
# 2) Substituting OQUOTA for PQUOTA and GQUOTA in function arguments,
# initializations, etc.
Add project quota changes to all the places where group quota field is used.
No externally visible changed and no superblock changes, yet.
--- fs/xfs/xfs_dquot.c | 17 +++- fs/xfs/xfs_dquot.h | 9 ++- fs/xfs/xfs_iget.c | 2 +- fs/xfs/xfs_inode.h | 1 + fs/xfs/xfs_ioctl.c | 12 +- fs/xfs/xfs_iops.c | 4 +- fs/xfs/xfs_qm.c | 259 ++++++++++++++++++++++++++++++++-------------- fs/xfs/xfs_qm.h | 7 +- fs/xfs/xfs_qm_bhv.c | 2 +- fs/xfs/xfs_qm_syscalls.c | 19 +++- fs/xfs/xfs_quota.h | 38 ++++--- fs/xfs/xfs_quota_priv.h | 6 +- fs/xfs/xfs_sb.h | 1 + fs/xfs/xfs_super.c | 5 +- fs/xfs/xfs_trans_dquot.c | 71 ++++++++++--- fs/xfs/xfs_vnodeops.c | 23 +++-- 16 files changed, 330 insertions(+), 146 deletions(-)
fs/xfs/xfs_quota.h +3 -3
@@ -186,9 +186,9 @@ typedef struct xfs_qoff_logformat {* are in the process of getting turned off. These flags are in m_qflags but * never in sb_qflags. */ -#define XFS_UQUOTA_ACTIVE 0x0100/* uquotas are being turned off */ -#define XFS_PQUOTA_ACTIVE 0x0200/* pquotas are being turned off */ -#define XFS_GQUOTA_ACTIVE 0x0400/* gquotas are being turned off */ +#define XFS_UQUOTA_ACTIVE 0x1000/* uquotas are being turned off */ +#define XFS_PQUOTA_ACTIVE 0x2000/* pquotas are being turned off */ +#define XFS_GQUOTA_ACTIVE 0x4000/* gquotas are being turned off */ #define XFS_ALL_QUOTA_ACTIVE \ (XFS_UQUOTA_ACTIVE | XFS_PQUOTA_ACTIVE | XFS_GQUOTA_ACTIVE)
#pwhite: These have to get moved up because of the definitions for #XFS_[GP]QUOTA_*
@@ -199,8 +199,6 @@ typedef struct xfs_qoff_logformat {
#define XFS_IS_QUOTA_ON(mp) ((mp)->m_qflags & (XFS_UQUOTA_ACTIVE | \
XFS_GQUOTA_ACTIVE | \
XFS_PQUOTA_ACTIVE))
-#define XFS_IS_OQUOTA_ON(mp) ((mp)->m_qflags & (XFS_GQUOTA_ACTIVE | \
- XFS_PQUOTA_ACTIVE))
#define XFS_IS_UQUOTA_ON(mp) ((mp)->m_qflags & XFS_UQUOTA_ACTIVE)
#define XFS_IS_GQUOTA_ON(mp) ((mp)->m_qflags & XFS_GQUOTA_ACTIVE)
#define XFS_IS_PQUOTA_ON(mp) ((mp)->m_qflags & XFS_PQUOTA_ACTIVE)
@@ -267,8 +265,10 @@ typedef struct xfs_qoff_logformat {
*/
#define XFS_NOT_DQATTACHED(mp, ip) ((XFS_IS_UQUOTA_ON(mp) &&\
(ip)->i_udquot == NULL) || \
- (XFS_IS_OQUOTA_ON(mp) && \
- (ip)->i_gdquot == 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) && \
@@ -323,17 +323,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);
#pwhite: This -- and the series of redefinitions following are to change out #passing one oquota structure for two structures -- one for pquota, one for #gquota.
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 *);
@@ -347,10 +348,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,
+ xfs_dquot **pdqp)
{
*udqp = NULL;
*gdqp = NULL;
+ *pdqp = NULL;
return 0;
}
#define xfs_trans_dup_dqinfo(tp, tp2)
@@ -365,14 +368,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)
@@ -386,8 +390,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_quota_priv.h +1 -5
@@ -30,11 +30,7 @@#define XFS_DQ_HASHVAL (mp, id) (((__psunsigned_t)(mp) + \ (__psunsigned_t)(id)) & \ (xfs_Gqm->qm_dqhashmask - 1)) -#define XFS_DQ_HASH (mp, id, type) (type == XFS_DQ_USER ? \ - (xfs_Gqm->qm_usr_dqhtable + \ - XFS_DQ_HASHVAL(mp, id)) : \ - (xfs_Gqm->qm_grp_dqhtable + \ - XFS_DQ_HASHVAL(mp, id))) +
#pwhite: Ok -- this is a little worrying. I'm not sure why we're removing #XFS_DQ_HASH.
#define XFS_IS_DQUOT_UNINITIALIZED(dqp) ( \
!dqp->q_core.d_blk_hardlimit && \
!dqp->q_core.d_blk_softlimit && \
fs/xfs/xfs_sb.h +1 -0
@@ -140,6 +140,7 @@ typedef struct xfs_sb {*/ xfs_ino_t sb_uquotino;/* user quota inode */ xfs_ino_t sb_gquotino;/* group quota inode */ +#define sb_pquotino sb_gquotino__uint16_t sb_qflags;/* quota flags */ __uint8_t sb_flags;/* misc. flags */ __uint8_t sb_shared_vn;/* shared version number */
fs/xfs/xfs_qm.h +2 -0
@@ -68,6 +68,7 @@ typedef xfs_dqhash_t xfs_dqlist_t; typedef struct xfs_qm { xfs_dqlist_t *qm_usr_dqhtable;/* udquot hash table */ xfs_dqlist_t *qm_grp_dqhtable;/* gdquot hash table */ + xfs_dqlist_t *qm_prj_dqhtable;/* project hash table */ uint qm_dqhashmask; /* # buckets in dq hashtab - 1 */ struct list_head qm_dqfrlist; /* freelist of dquots */ struct mutex qm_dqfrlist_lock;
@@ -86,6 +87,7 @@ typedef struct xfs_qm { typedef struct xfs_quotainfo { xfs_inode_t *qi_uquotaip; /* user quota inode */ xfs_inode_t *qi_gquotaip; /* group quota inode */ + xfs_inode_t *qi_pquotaip; /* project quota inode */ struct list_head qi_dqlist; /* all dquots in filesys */ struct mutex qi_dqlist_lock; int qi_dquots;
#pwhite: Why are the group & project quota inodes different here, but not in #xfs_sb? This anticipates a change in the 3rd patch.
@@ -110,13 +112,11 @@ typedef struct xfs_quotainfo {
extern void xfs_trans_mod_dquot(xfs_trans_t *, xfs_dquot_t *, uint, long);
-extern int xfs_trans_reserve_quota_bydquots(xfs_trans_t *, xfs_mount_t *,
- xfs_dquot_t *, xfs_dquot_t *, long, long, uint);
extern void xfs_trans_dqjoin(xfs_trans_t *, xfs_dquot_t *);
extern void xfs_trans_log_dquot(xfs_trans_t *, xfs_dquot_t *);
/*
- * We keep the usr and grp dquots separately so that locking will be easier
+ * 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. */
@@ -124,6 +124,7 @@ extern void xfs_trans_log_dquot(xfs_trans_t *, xfs_dquot_t *);
typedef struct xfs_dquot_acct {
xfs_dqtrx_t dqa_usrdquots[XFS_QM_TRANS_MAXDQS];
xfs_dqtrx_t dqa_grpdquots[XFS_QM_TRANS_MAXDQS];
+ xfs_dqtrx_t dqa_prjdquots[XFS_QM_TRANS_MAXDQS];
} xfs_dquot_acct_t;
/*
fs/xfs/xfs_inode.h +1 -0
@@ -224,6 +224,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_dquot.h +7 -2
@@ -59,6 +59,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 */
@@ -122,8 +123,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 ; }
@@ -136,6 +138,7 @@ 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_PROJ : +return ip->i_pdquot;case XFS_DQ_GROUP :return ip->i_gdquot;default :
@@ -151,7 +154,9 @@ static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)#define XFS_DQ_TO_QINF (dqp) ((dqp)->q_mount->m_quotainfo)#define XFS_DQ_TO_QIP (dqp) (XFS_QM_ISUDQ(dqp) ? \ XFS_DQ_TO_QINF(dqp)->qi_uquotaip : \ - XFS_DQ_TO_QINF(dqp)->qi_gquotaip) + (XFS_QM_ISGDQ(dqp) ? \ + XFS_DQ_TO_QINF(dqp)->qi_gquotaip : \ + XFS_DQ_TO_QINF(dqp)->qi_pquotaip))extern int xfs_qm_dqread (struct xfs_mount *,xfs_dqid_t ,uint ,uint ,struct xfs_dquot **);
fs/xfs/xfs_dquot.c +15 -0
@@ -706,6 +706,21 @@ xfs_qm_dqlookup(return 1 ; } +static struct xfs_dqhash *xfs_dq_hash (struct xfs_mount *mp, +xfs_dqid_t id,uint type) +{ +switch (type) { +case XFS_DQ_USER : +return (xfs_Gqm->qm_usr_dqhtable +XFS_DQ_HASHVAL (mp, id)); +case XFS_DQ_GROUP : +return (xfs_Gqm->qm_grp_dqhtable +XFS_DQ_HASHVAL (mp, id)); +case XFS_DQ_PROJ : +return (xfs_Gqm->qm_prj_dqhtable +XFS_DQ_HASHVAL (mp, id)); +default : +return NULL ; + } +} +
#pwhite: OK. This replaces XFS_DQ_HASH(). Fair enough.
/*
* Given the file system, inode OR id, and type (UDQUOT/GDQUOT), return a
* a locked dquot, doing an allocation (if requested) as needed.
@@ -734,7 +749,7 @@ xfs_qm_dqget(
(! XFS_IS_GQUOTA_ON(mp) && type == XFS_DQ_GROUP)) {
return (ESRCH);
}
- h = XFS_DQ_HASH(mp, id, type);
+ h = xfs_dq_hash(mp, id, type);
#ifdef DEBUG
if (xfs_do_dqerror) {
fs/xfs/xfs_iget.c +1 -1
@@ -362,7 +362,7 @@ xfs_iget_cache_miss( }/* These values _must_ be set before releasing the radix tree lock! */ - ip->i_udquot = ip->i_gdquot =NULL ; + ip->i_udquot = ip->i_gdquot = ip->i_pdquot =NULL ;xfs_iflags_set (ip,XFS_INEW );spin_unlock (&pag->pag_ici_lock);
fs/xfs/xfs_ioctl.c +1 -1
@@ -907,7 +907,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 ;
#pwhite: Why does this remove *gdqp? Are we never going to use group quotas #through this ioctl() ?
struct xfs_dquot *olddquot = NULL;
int code;
@@ -936,7 +936,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;
}
@@ -973,7 +973,7 @@ 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,
+ code = xfs_qm_vop_chown_reserve(tp, ip, udqp, NULL, pdqp,
capable(CAP_FOWNER) ? XFS_QMOPT_FORCE_RES : 0);
if (code) /* out of quota */
@@ -1092,7 +1092,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);
@@ -1139,13 +1139,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
@@ -569,7 +569,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; }
@@ -604,7 +604,7 @@ xfs_setattr_nonsize( ((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || (XFS_IS_GQUOTA_ON(mp) && igid != gid))) {ASSERT (tp); - error =xfs_qm_vop_chown_reserve (tp, ip, udqp, gdqp, + error =xfs_qm_vop_chown_reserve (tp, ip, udqp, gdqp,NULL ,capable (CAP_FOWNER ) ?XFS_QMOPT_FORCE_RES :0 );if (error)/* out of quota */
fs/xfs/xfs_qm.c +41 -20
152 lines not on this page · raw message
#pwhite: Shouldn't this code check for PQUOTA_ON and do the appropriate attach?
/*
@@ -715,14 +736,28 @@ xfs_qm_dqattach_locked(
nquotas++;
}
+ ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
+ if (XFS_IS_PQUOTA_ON(mp)) {
+ error = xfs_qm_dqattach_one(ip, xfs_get_projid(ip), XFS_DQ_PROJ,
+ flags & XFS_QMOPT_DQALLOC,
+ ip->i_udquot, &ip->i_pdquot);
+ /*
+ * Don't worry about the udquot that we may have
+ * attached above. It'll get detached, if not already.
+ */
+ if (error)
+ goto done;
+ nquotas++;
+ }
+
#pwhite: Oh, there it is. That'll teach me to hold my horses.
/*
- * Attach this group quota to the user quota as a hint.
+ * Attach this group/project quota to the user quota as a hint.
* This WON'T, in general, result in a thrash. */
- if (nquotas == 2) {
+ if (nquotas > 1 && ip->i_udquot) {
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
- ASSERT(ip->i_udquot);
- ASSERT(ip->i_gdquot);
+ ASSERT(ip->i_gdquot || !XFS_IS_GQUOTA_ON(mp)); + ASSERT(ip->i_pdquot || !XFS_IS_PQUOTA_ON(mp));
/*
* We do not have i_udquot locked at this point, but this check
@@ -730,8 +765,13 @@ xfs_qm_dqattach_locked(
* 100% all the time. It is just a hint, and this will
* succeed in general.
*/
- if (ip->i_udquot->q_gdquot != ip->i_gdquot)
- xfs_qm_dqattach_grouphint(ip->i_udquot, ip->i_gdquot);
+ if (XFS_IS_GQUOTA_ON(mp) &&
+ ip->i_udquot->q_gdquot != ip->i_gdquot)
+ xfs_qm_dqattach_grouphint(ip, XFS_DQ_GROUP);
+
+ if (XFS_IS_PQUOTA_ON(mp) &&
+ ip->i_udquot->q_pdquot != ip->i_pdquot)
+ xfs_qm_dqattach_grouphint(ip, XFS_DQ_PROJ);
}
done:
@@ -739,8 +779,10 @@ xfs_qm_dqattach_locked(
if (!error) {
if (XFS_IS_UQUOTA_ON(mp))
ASSERT(ip->i_udquot);
- if (XFS_IS_OQUOTA_ON(mp))
+ if (XFS_IS_GQUOTA_ON(mp))
ASSERT(ip->i_gdquot);
+ if (XFS_IS_PQUOTA_ON(mp))
+ ASSERT(ip->i_pdquot);
}
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
#endif
@@ -770,7 +812,7 @@ void
xfs_qm_dqdetach(
xfs_inode_t *ip)
{
- if (!(ip->i_udquot || ip->i_gdquot)) + if (!(ip->i_udquot || ip->i_gdquot || ip->i_pdquot))
return;
trace_xfs_dquot_dqdetach(ip);
@@ -785,6 +827,10 @@ xfs_qm_dqdetach(
xfs_qm_dqrele(ip->i_gdquot);
ip->i_gdquot = NULL;
}
+ if (ip->i_pdquot) {
+ xfs_qm_dqrele(ip->i_pdquot);
+ ip->i_pdquot = NULL;
+ }
}
/*
@@ -936,6 +982,10 @@ xfs_qm_destroy_quotainfo(
IRELE(qi->qi_gquotaip);
qi->qi_gquotaip = NULL;
}
+ if (qi->qi_pquotaip) {
+ IRELE(qi->qi_pquotaip);
+ qi->qi_pquotaip = NULL;
+ }
mutex_destroy(&qi->qi_quotaofflock);
kmem_free(qi);
mp->m_quotainfo = NULL;
@@ -1413,7 +1463,7 @@ xfs_qm_quotacheck(
int done, count, error;
xfs_ino_t lastino;
size_t structsz;
- xfs_inode_t *uip, *gip;
+ xfs_inode_t *uip, *gip, *pip;
uint flags;
count = INT_MAX;
@@ -1421,7 +1471,8 @@ xfs_qm_quotacheck(
lastino = 0;
flags = 0;
- ASSERT(mp->m_quotainfo->qi_uquotaip || mp->m_quotainfo->qi_gquotaip); + ASSERT(mp->m_quotainfo->qi_uquotaip || mp->m_quotainfo->qi_gquotaip
+ || mp->m_quotainfo->qi_pquotaip);
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
/*
@@ -1447,12 +1498,18 @@ xfs_qm_quotacheck(
gip = mp->m_quotainfo->qi_gquotaip;
if (gip) {
- error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ?
- XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);
+ error = xfs_qm_dqiterate(mp, gip, XFS_QMOPT_GQUOTA);
if (error)
goto error_return;
- flags |= XFS_IS_GQUOTA_ON(mp) ?
- XFS_GQUOTA_CHKD : XFS_PQUOTA_CHKD;
+ flags |= XFS_GQUOTA_CHKD;
+ }
+
+ pip = mp->m_quotainfo->qi_pquotaip;
+ if (pip) {
+ error = xfs_qm_dqiterate(mp, pip, XFS_QMOPT_PQUOTA);
+ if (error)
+ goto error_return;
+ flags |= XFS_PQUOTA_CHKD;
}
do {
@@ -1533,13 +1590,13 @@ STATIC int
xfs_qm_init_quotainos(
xfs_mount_t *mp)
{
- xfs_inode_t *uip, *gip;
+ xfs_inode_t *uip, *gip, *pip;
int error;
__int64_t sbflags;
uint flags;
ASSERT(mp->m_quotainfo);
- uip = gip = NULL;
+ uip = gip = pip = NULL;
sbflags = 0;
flags = 0;
@@ -1554,7 +1611,7 @@ xfs_qm_init_quotainos(
0, 0, &uip)))
return XFS_ERROR(error);
}
- if (XFS_IS_OQUOTA_ON(mp) &&
+ if (XFS_IS_GQUOTA_ON(mp) &&
mp->m_sb.sb_gquotino != NULLFSINO) {
ASSERT(mp->m_sb.sb_gquotino > 0);
if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_gquotino,
@@ -1564,6 +1621,18 @@ xfs_qm_init_quotainos(
return XFS_ERROR(error);
}
}
+ if (XFS_IS_PQUOTA_ON(mp) &&
+ mp->m_sb.sb_pquotino != NULLFSINO) {
+ ASSERT(mp->m_sb.sb_pquotino > 0);
+ if ((error = xfs_iget(mp, NULL, mp->m_sb.sb_pquotino,
+ 0, 0, &pip))) {
+ if (uip)
+ IRELE(uip);
+ if (gip)
+ IRELE(gip);
+ return XFS_ERROR(error);
+ }
+ }
} else {
flags |= XFS_QMOPT_SBVERSION;
sbflags |= (XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO |
@@ -1571,7 +1640,7 @@ xfs_qm_init_quotainos(
}
/*
- * Create the two inodes, if they don't exist already. The changes
+ * Create the three inodes, if they don't exist already. The changes
* made above will get added to a transaction and logged in one of
* the qino_alloc calls below. If the device is readonly,
* temporarily switch to read-write to do this.
@@ -1584,11 +1653,10 @@ xfs_qm_init_quotainos(
flags &= ~XFS_QMOPT_SBVERSION;
}
- if (XFS_IS_OQUOTA_ON(mp) && gip == NULL) {
- flags |= (XFS_IS_GQUOTA_ON(mp) ?
- XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);
+ if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) {
error = xfs_qm_qino_alloc(mp, &gip,
- sbflags | XFS_SB_GQUOTINO, flags);
+ sbflags | XFS_SB_GQUOTINO,
+ flags | XFS_QMOPT_GQUOTA);
if (error) {
if (uip)
IRELE(uip);
@@ -1596,9 +1664,23 @@ xfs_qm_init_quotainos(
return XFS_ERROR(error);
}
}
+ if (XFS_IS_PQUOTA_ON(mp) && pip == NULL) {
+ error = xfs_qm_qino_alloc(mp, &pip,
+ sbflags | XFS_SB_GQUOTINO,
+ flags | XFS_QMOPT_PQUOTA);
+ if (error) {
+ if (uip)
+ IRELE(uip);
+ if (gip)
+ IRELE(gip);
+
+ return XFS_ERROR(error);
+ }
+ }
mp->m_quotainfo->qi_uquotaip = uip;
mp->m_quotainfo->qi_gquotaip = gip;
+ mp->m_quotainfo->qi_pquotaip = pip;
return 0;
}
@@ -1862,10 +1944,11 @@ xfs_qm_vop_dqalloc(
prid_t prid,
uint flags,
struct xfs_dquot **O_udqpp,
- struct xfs_dquot **O_gdqpp)
+ struct xfs_dquot **O_gdqpp,
+ struct xfs_dquot **O_pdqpp)
{
struct xfs_mount *mp = ip->i_mount;
- struct xfs_dquot *uq, *gq;
+ struct xfs_dquot *uq, *gq, *pq;
int error;
uint lockflags;
@@ -1890,7 +1973,7 @@ xfs_qm_vop_dqalloc(
}
}
- uq = gq = NULL;
+ uq = gq = pq = NULL;
if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) {
if (ip->i_d.di_uid != uid) {
/*
@@ -1946,25 +2029,28 @@ xfs_qm_vop_dqalloc(
ASSERT(ip->i_gdquot);
gq = xfs_qm_dqhold(ip->i_gdquot);
}
- } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
+ }
+ if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
if (xfs_get_projid(ip) != prid) {
xfs_iunlock(ip, lockflags);
if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)prid,
XFS_DQ_PROJ, XFS_QMOPT_DQALLOC | XFS_QMOPT_DOWARN,
- &gq))) {
+ &pq))) {
if (uq)
xfs_qm_dqrele(uq);
+ if (gq)
+ xfs_qm_dqrele(gq);
ASSERT(error != ENOENT);
return (error);
}
- xfs_dqunlock(gq);
+ xfs_dqunlock(pq);
lockflags = XFS_ILOCK_SHARED; xfs_ilock(ip, lockflags);
} else {
- ASSERT(ip->i_gdquot);
- gq = xfs_qm_dqhold(ip->i_gdquot);
+ ASSERT(ip->i_pdquot);
+ pq = xfs_qm_dqhold(ip->i_pdquot);
}
}
if (uq)
@@ -1979,6 +2065,10 @@ xfs_qm_vop_dqalloc(
*O_gdqpp = gq;
else if (gq)
xfs_qm_dqrele(gq);
+ if (O_pdqpp)
+ *O_pdqpp = pq;
+ else if (pq)
+ xfs_qm_dqrele(pq);
return 0;
}
@@ -2031,11 +2121,13 @@ xfs_qm_vop_chown_reserve(
xfs_inode_t *ip,
xfs_dquot_t *udqp,
xfs_dquot_t *gdqp,
+ xfs_dquot_t *pdqp,
uint flags)
{
xfs_mount_t *mp = ip->i_mount;
uint delblks, blkflags, prjflags = 0;
- xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq;
+ xfs_dquot_t *unresudq, *unresgdq, *unrespdq;
+ xfs_dquot_t *delblksudq, *delblksgdq, *delblkspdq;
int error;
@@ -2043,7 +2135,8 @@ xfs_qm_vop_chown_reserve(
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
delblks = ip->i_delayed_blks;
- delblksudq = delblksgdq = unresudq = unresgdq = NULL;
+ delblksudq = delblksgdq = delblkspdq = NULL;
+ unresudq = unresgdq = unrespdq = NULL;
blkflags = XFS_IS_REALTIME_INODE(ip) ?
XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
@@ -2060,25 +2153,28 @@ xfs_qm_vop_chown_reserve(
unresudq = ip->i_udquot;
}
}
- if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) {
- if (XFS_IS_PQUOTA_ON(ip->i_mount) &&
- xfs_get_projid(ip) != be32_to_cpu(gdqp->q_core.d_id))
- prjflags = XFS_QMOPT_ENOSPC;
-
- if (prjflags ||
- (XFS_IS_GQUOTA_ON(ip->i_mount) &&
- ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id))) {
- delblksgdq = gdqp;
- if (delblks) {
- ASSERT(ip->i_gdquot);
- unresgdq = ip->i_gdquot;
- }
+ if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp &&
+ ip->i_d.di_gid != be32_to_cpu(gdqp->q_core.d_id)) {
+ delblksgdq = gdqp;
+ if (delblks) {
+ ASSERT(ip->i_gdquot);
+ unresgdq = ip->i_gdquot;
+ }
+ }
+
+ if (XFS_IS_PQUOTA_ON(ip->i_mount) && pdqp &&
+ xfs_get_projid(ip) != be32_to_cpu(pdqp->q_core.d_id)) {
+ prjflags = XFS_QMOPT_ENOSPC;
+ delblkspdq = pdqp;
+ if (delblks) {
+ ASSERT(ip->i_pdquot);
+ unrespdq = ip->i_pdquot;
}
}
if ((error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
- delblksudq, delblksgdq, ip->i_d.di_nblocks, 1,
- flags | blkflags | prjflags)))
+ delblksudq, delblksgdq, delblkspdq, ip->i_d.di_nblocks,
+ 1, flags | blkflags | prjflags)))
return (error);
/*
@@ -2091,15 +2187,16 @@ xfs_qm_vop_chown_reserve(
/*
* Do the reservations first. Unreservation can't fail. */
- ASSERT(delblksudq || delblksgdq);
- ASSERT(unresudq || unresgdq);
+ ASSERT(delblksudq || delblksgdq || delblkspdq);
+ ASSERT(unresudq || unresgdq || unrespdq);
if ((error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
- delblksudq, delblksgdq, (xfs_qcnt_t)delblks, 0,
+ delblksudq, delblksgdq, delblkspdq,
+ (xfs_qcnt_t)delblks, 0,
flags | blkflags | prjflags)))
return (error);
xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
- unresudq, unresgdq, -((xfs_qcnt_t)delblks), 0,
- blkflags);
+ unresudq, unresgdq, unrespdq,
+ -((xfs_qcnt_t)delblks), 0, blkflags);
}
return (0);
@@ -2138,7 +2235,8 @@ xfs_qm_vop_create_dqattach(
struct xfs_trans *tp,
struct xfs_inode *ip,
struct xfs_dquot *udqp,
- struct xfs_dquot *gdqp)
+ struct xfs_dquot *gdqp,
+ struct xfs_dquot *pdqp)
{
struct xfs_mount *mp = tp->t_mountp;
@@ -2158,13 +2256,18 @@ xfs_qm_vop_create_dqattach(
}
if (gdqp) {
ASSERT(ip->i_gdquot == NULL);
- ASSERT(XFS_IS_OQUOTA_ON(mp));
- ASSERT((XFS_IS_GQUOTA_ON(mp) ?
- ip->i_d.di_gid : xfs_get_projid(ip)) ==
- be32_to_cpu(gdqp->q_core.d_id));
-
+ ASSERT(XFS_ISGOQUOTA_ON(mp));
+ ASSERT(ip->i_d.di_gid == be32_to_cpu(gdqp->q_core.d_id));
ip->i_gdquot = xfs_qm_dqhold(gdqp); xfs_trans_mod_dquot(tp, gdqp, XFS_TRANS_DQ_ICOUNT, 1);
}
+ if (pdqp) {
+ ASSERT(ip->i_pdquot == NULL);
+ ASSERT(XFS_IS_PQUOTA_ON(mp));
+ ASSERT(xfs_get_projid(ip) == be32_to_cpu(pdqp->q_core.d_id));
+
+ ip->i_pdquot = xfs_qm_dqhold(pdqp);
+ xfs_trans_mod_dquot(tp, pdqp, XFS_TRANS_DQ_ICOUNT, 1);
+ }
}
fs/xfs/xfs_qm_bhv.c +1 -1
@@ -117,7 +117,7 @@ xfs_qm_newmount( (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))) && xfs_dev_is_read_only(mp, "changing quota state")) { xfs_warn(mp, "please mount with%s%s%s%s.", (!quotaondisk ? "out quota" : ""),
fs/xfs/xfs_qm_syscalls.c +15 -4
@@ -123,7 +123,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 ;
@@ -223,10 +224,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);
@@ -878,9 +883,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 ; }
@@ -889,10 +896,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_super.c +2 -3
@@ -539,14 +539,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
fs/xfs/xfs_trans_dquot.c +56 -15
152 lines not on this page · raw message
fs/xfs/xfs_vnodeops.c +15 -8
@@ -851,6 +851,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;
@@ -869,7 +870,7 @@ 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;
@@ -929,7 +930,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;
@@ -993,7 +995,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)
@@ -1005,6 +1007,7 @@ xfs_create(xfs_qm_dqrele (udqp);xfs_qm_dqrele (gdqp); +xfs_qm_dqrele (pdqp); *ipp = ip;return 0 ;
@@ -1026,6 +1029,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 );
@@ -1516,7 +1520,7 @@ xfs_symlink(int n;xfs_buf_t *bp;prid_t prid; -struct xfs_dquot *udqp, *gdqp; +struct xfs_dquot *udqp, *gdqp, *pdqp;uint resblks; *ipp =NULL ;
@@ -1546,7 +1550,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;
@@ -1587,7 +1591,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;
@@ -1625,7 +1630,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);
@@ -1709,6 +1714,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 ;
@@ -1722,6 +1728,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 );
@@ -2188,7 +2195,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
RFC PATCH v3 3/4 xfs: Add pquotaino to on-disk super block
In reply to Chandra SeetharamanAdd a new field to the superblock to add support for seperate pquota with a specific version.
No change made yet to gather both project and group quota with quotactl.
--- fs/xfs/xfs_itable.c | 3 +- fs/xfs/xfs_mount.c | 101 ++++++++++++++++++++++++++++++++------------ fs/xfs/xfs_qm.c | 18 +++++--- fs/xfs/xfs_qm_syscalls.c | 30 ++++++++++--- fs/xfs/xfs_quota.h | 8 ---- fs/xfs/xfs_sb.h | 20 +++++++-- fs/xfs/xfs_super.c | 15 ++++--- fs/xfs/xfs_trans_dquot.c | 4 +- include/linux/dqblk_xfs.h | 1 + 9 files changed, 139 insertions(+), 61 deletions(-)
include/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 */
fs/xfs/xfs_quota.h +0 -8
@@ -278,14 +278,6 @@ typedef struct xfs_qoff_logformat { (XFS_IS_PQUOTA_ON(mp) && \ (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0)) -#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ - XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD) - -#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ - XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD) -#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD|\
fs/xfs/xfs_sb.h +16 -4
@@ -81,11 +81,15 @@ struct xfs_mount;#define XFS_SB_VERSION2_ATTR2BIT 0x00000008/* Inline attr rework */ #define XFS_SB_VERSION2_PARENTBIT 0x00000010/* parent pointers */ #define XFS_SB_VERSION2_PROJID32BIT 0x00000080/* 32 bit project id */ +#define XFS_SB_VERSION2_NO_OQUOTA 0x00000100/* No OQUOTA and * +* separate project * +* quota field */ #define XFS_SB_VERSION2_OKREALFBITS \ (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ XFS_SB_VERSION2_ATTR2BIT | \ - XFS_SB_VERSION2_PROJID32BIT) + XFS_SB_VERSION2_PROJID32BIT | \ + XFS_SB_VERSION2_NO_OQUOTA)#define XFS_SB_VERSION2_OKSASHFBITS \ (0)#define XFS_SB_VERSION2_OKREALBITS \
@@ -140,7 +144,6 @@ typedef struct xfs_sb {*/ xfs_ino_t sb_uquotino;/* user quota inode */ xfs_ino_t sb_gquotino;/* group quota inode */ -#define sb_pquotino sb_gquotino__uint16_t sb_qflags;/* quota flags */ __uint8_t sb_flags;/* misc. flags */ __uint8_t sb_shared_vn;/* shared version number */
@@ -160,6 +163,7 @@ typedef struct xfs_sb {* it for anything else. */ __uint32_t sb_bad_features2; +xfs_ino_t sb_pquotino;/* project quota inode */ /* must be padded to 64 bit alignment */ } xfs_sb_t;
@@ -230,6 +234,7 @@ typedef struct xfs_dsb {* it for anything else. */ __be32 sb_bad_features2; +__be64 sb_pquotino;/* project quota inode */ /* must be padded to 64 bit alignment */ } xfs_dsb_t;
@@ -250,7 +255,7 @@ typedef enum {XFS_SBS_GQUOTINO ,XFS_SBS_QFLAGS ,XFS_SBS_FLAGS ,XFS_SBS_SHARED_VN ,XFS_SBS_INOALIGNMT ,XFS_SBS_UNIT ,XFS_SBS_WIDTH ,XFS_SBS_DIRBLKLOG ,XFS_SBS_LOGSECTLOG ,XFS_SBS_LOGSECTSIZE ,XFS_SBS_LOGSUNIT , -XFS_SBS_FEATURES2 ,XFS_SBS_BAD_FEATURES2 , +XFS_SBS_FEATURES2 ,XFS_SBS_BAD_FEATURES2 ,XFS_SBS_PQUOTINO , XFS_SBS_FIELDCOUNT } xfs_sb_field_t;
@@ -276,6 +281,7 @@ typedef enum {#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) +#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO)#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)#define XFS_SB_MOD_BITS \
@@ -283,7 +289,7 @@ typedef enum {XFS_SB_VERSIONNUM |XFS_SB_UQUOTINO |XFS_SB_GQUOTINO | \XFS_SB_QFLAGS |XFS_SB_SHARED_VN |XFS_SB_UNIT |XFS_SB_WIDTH | \XFS_SB_ICOUNT |XFS_SB_IFREE |XFS_SB_FDBLOCKS |XFS_SB_FEATURES2 | \ - XFS_SB_BAD_FEATURES2) + XFS_SB_BAD_FEATURES2 | XFS_SB_PQUOTINO)/*
@@ -504,6 +510,12 @@ static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp) (sbp->sb_features2 &XFS_SB_VERSION2_PROJID32BIT ); } +static inline int xfs_sb_version_has_no_oquota (xfs_sb_t *sbp) +{ +return xfs_sb_version_hasmorebits (sbp) && + (sbp->sb_features2 &XFS_SB_VERSION2_NO_OQUOTA ); +} +/* * end of superblock version macros */
fs/xfs/xfs_itable.c +2 -1
@@ -43,7 +43,8 @@ xfs_internal_inum( {return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || (xfs_sb_version_hasquota (&mp->m_sb) && - (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino))); + (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino || + ino == mp->m_sb.sb_pquotino))); }/*
fs/xfs/xfs_mount.c +73 -28
150 lines not on this page · raw message
fs/xfs/xfs_qm.c +12 -6
@@ -708,7 +708,8 @@ xfs_qm_dqattach_locked( !XFS_IS_QUOTA_ON (mp) || !XFS_NOT_DQATTACHED (mp, ip) || ip->i_ino == mp->m_sb.sb_uquotino || - ip->i_ino == mp->m_sb.sb_gquotino) + ip->i_ino == mp->m_sb.sb_gquotino || + ip->i_ino == mp->m_sb.sb_pquotino) return 0;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));
@@ -819,6 +820,7 @@ xfs_qm_dqdetach(ASSERT (ip->i_ino != ip->i_mount->m_sb.sb_uquotino);ASSERT (ip->i_ino != ip->i_mount->m_sb.sb_gquotino); +ASSERT (ip->i_ino != ip->i_mount->m_sb.sb_pquotino);if (ip->i_udquot) {xfs_qm_dqrele (ip->i_udquot); ip->i_udquot =NULL ;
@@ -1058,19 +1060,22 @@ xfs_qm_qino_alloc(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_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 ; }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);
@@ -1377,7 +1382,8 @@ xfs_qm_dqusage_adjust(* rootino must have its resources accounted for, not so with the quota * inodes. */ -if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino) { +if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino || + ino == mp->m_sb.sb_pquotino) { *res =BULKSTAT_RV_NOTHING ;return XFS_ERROR (EINVAL ); }
@@ -1636,7 +1642,7 @@ 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 ); }/*
@@ -1666,7 +1672,7 @@ xfs_qm_init_quotainos( }if (XFS_IS_PQUOTA_ON (mp) && pip ==NULL ) { error =xfs_qm_qino_alloc (mp, &pip, - sbflags |XFS_SB_GQUOTINO , + sbflags |XFS_SB_PQUOTINO , flags |XFS_QMOPT_PQUOTA );if (error) {if (uip)
fs/xfs/xfs_qm_syscalls.c +23 -7
@@ -210,8 +210,7 @@ xfs_qm_scall_quotaoff(/* * If quotas is completely disabled, close shop. */ -if (((flags &XFS_MOUNT_QUOTA_ALL ) ==XFS_MOUNT_QUOTA_SET1 ) || - ((flags &XFS_MOUNT_QUOTA_ALL ) ==XFS_MOUNT_QUOTA_SET2 )) { +if ((flags &XFS_MOUNT_QUOTA_ALL ) ==XFS_MOUNT_QUOTA_ALL ) {mutex_unlock (&q->qi_quotaofflock);xfs_qm_destroy_quotainfo (mp);return (0 );
@@ -306,8 +305,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; }
@@ -423,17 +424,18 @@ xfs_qm_scall_getqstat( struct fs_quota_stat *out) {struct xfs_quotainfo *q = mp->m_quotainfo; -struct xfs_inode *uip, *gip; -boolean_t tempuqip, tempgqip; +struct xfs_inode *uip, *gip, *pip; +boolean_t tempuqip, tempgqip, temppqip; - uip = gip =NULL ; - tempuqip = tempgqip =B_FALSE ; + uip = gip = pip =NULL ; + tempuqip = tempgqip = temppqip =B_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 ; + out->qs_pquota.qfs_ino =NULLFSINO ;return (0 ); } out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags &
@@ -442,10 +444,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,
@@ -457,6 +462,11 @@ xfs_qm_scall_getqstat( 0, 0, &gip) == 0) tempgqip =B_TRUE ; } +if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { +if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, +0 ,0 , &pip) ==0 ) + temppqip =B_TRUE ; + }if (uip) { out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; out->qs_uquota.qfs_nextents = uip->i_d.di_nextents;
@@ -469,6 +479,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_super.c +9 -6
@@ -400,12 +400,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 ;
@@ -1315,6 +1309,15 @@ xfs_fs_fill_super(if (error) goto out_destroy_counters; +if ((mp->m_qflags & (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE )) && + (mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE )) && + !xfs_sb_version_has_no_oquota (&mp->m_sb)) { +xfs_warn (mp,"Super block does not support " +"project and group quota together" ); + error =EINVAL ; + goto out_free_sb; + } + error =xfs_finish_flags (mp);if (error) goto out_free_sb;
fs/xfs/xfs_trans_dquot.c +3 -1
@@ -165,7 +165,8 @@ xfs_trans_mod_dquot_byino(if (!XFS_IS_QUOTA_RUNNING (mp) || !XFS_IS_QUOTA_ON (mp) || ip->i_ino == mp->m_sb.sb_uquotino || - ip->i_ino == mp->m_sb.sb_gquotino) + ip->i_ino == mp->m_sb.sb_gquotino || + ip->i_ino == mp->m_sb.sb_pquotino)return ;if (tp->t_dqinfo ==NULL )
@@ -859,6 +860,7 @@ xfs_trans_reserve_quota_nblks(ASSERT (ip->i_ino != mp->m_sb.sb_uquotino);ASSERT (ip->i_ino != mp->m_sb.sb_gquotino); +ASSERT (ip->i_ino != mp->m_sb.sb_pquotino);ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
RFC PATCH v3 3/4 xfs: Add pquotaino to on-disk super block
#pwhite: This starts to remove the OQUOTA setting from the old superblock, so #that we can support group & project quotas simultaneously.
Add a new field to the superblock to add support for separate pquota with a specific version.
No change made yet to gather both project and group quota with quotactl.
--- fs/xfs/xfs_itable.c | 3 +- fs/xfs/xfs_mount.c | 101 ++++++++++++++++++++++++++++++++------------ fs/xfs/xfs_qm.c | 18 +++++--- fs/xfs/xfs_qm_syscalls.c | 30 ++++++++++--- fs/xfs/xfs_quota.h | 8 ---- fs/xfs/xfs_sb.h | 20 +++++++-- fs/xfs/xfs_super.c | 15 ++++--- fs/xfs/xfs_trans_dquot.c | 4 +- include/linux/dqblk_xfs.h | 1 + 9 files changed, 139 insertions(+), 61 deletions(-)
include/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 */
fs/xfs/xfs_quota.h +0 -8
@@ -278,14 +278,6 @@ typedef struct xfs_qoff_logformat { (XFS_IS_PQUOTA_ON(mp) && \ (mp->m_sb.sb_qflags & XFS_PQUOTA_CHKD) == 0)) -#define XFS_MOUNT_QUOTA_SET1 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ - XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ - XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD) - -#define XFS_MOUNT_QUOTA_SET2 (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ - XFS_UQUOTA_CHKD|XFS_GQUOTA_ACCT|\ - XFS_GQUOTA_ENFD|XFS_GQUOTA_CHKD) -#define XFS_MOUNT_QUOTA_ALL (XFS_UQUOTA_ACCT|XFS_UQUOTA_ENFD|\ XFS_UQUOTA_CHKD|XFS_PQUOTA_ACCT|\ XFS_PQUOTA_ENFD|XFS_PQUOTA_CHKD|\
fs/xfs/xfs_sb.h +6 -2
@@ -81,11 +81,15 @@ struct xfs_mount;#define XFS_SB_VERSION2_ATTR2BIT 0x00000008/* Inline attr rework */ #define XFS_SB_VERSION2_PARENTBIT 0x00000010/* parent pointers */ #define XFS_SB_VERSION2_PROJID32BIT 0x00000080/* 32 bit project id */ +#define XFS_SB_VERSION2_NO_OQUOTA 0x00000100/* No OQUOTA and * +* separate project * +* quota field */ #define XFS_SB_VERSION2_OKREALFBITS \ (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ XFS_SB_VERSION2_ATTR2BIT | \ - XFS_SB_VERSION2_PROJID32BIT) + XFS_SB_VERSION2_PROJID32BIT | \ + XFS_SB_VERSION2_NO_OQUOTA)#define XFS_SB_VERSION2_OKSASHFBITS \ (0)#define XFS_SB_VERSION2_OKREALBITS \
@@ -140,7 +144,6 @@ typedef struct xfs_sb {*/ xfs_ino_t sb_uquotino;/* user quota inode */ xfs_ino_t sb_gquotino;/* group quota inode */ -#define sb_pquotino sb_gquotino__uint16_t sb_qflags;/* quota flags */ __uint8_t sb_flags;/* misc. flags */ __uint8_t sb_shared_vn;/* shared version number */
@@ -160,6 +163,7 @@ typedef struct xfs_sb {* it for anything else. */ __uint32_t sb_bad_features2; +xfs_ino_t sb_pquotino;/* project quota inode */
#pwhite: Ok, now we're splitting the two gquota & pquota inodes up. We saw some #of this in patch 2 of this series.
/* must be padded to 64 bit alignment */
} xfs_sb_t;
@@ -230,6 +234,7 @@ typedef struct xfs_dsb {
* it for anything else.
*/
__be32 sb_bad_features2;
+ __be64 sb_pquotino; /* project quota inode */
/* must be padded to 64 bit alignment */
} xfs_dsb_t;
@@ -250,7 +255,7 @@ typedef enum {
XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT,
- XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2,
+ XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_PQUOTINO,
XFS_SBS_FIELDCOUNT
} xfs_sb_field_t;
@@ -276,6 +281,7 @@ typedef enum {
#define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS)
#define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2)
#define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2)
+#define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO)
#define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT)
#define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1)
#define XFS_SB_MOD_BITS \
@@ -283,7 +289,7 @@ typedef enum {
XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \
XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \
- XFS_SB_BAD_FEATURES2)
+ XFS_SB_BAD_FEATURES2 | XFS_SB_PQUOTINO)
/*
@@ -504,6 +510,12 @@ static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp)
(sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT);
}
+static inline int xfs_sb_version_has_no_oquota(xfs_sb_t *sbp) +{
+ return xfs_sb_version_hasmorebits(sbp) &&
+ (sbp->sb_features2 & XFS_SB_VERSION2_NO_OQUOTA);
+}
+
/*
* end of superblock version macros
*/
fs/xfs/xfs_itable.c +2 -1
@@ -43,7 +43,8 @@ xfs_internal_inum( {return (ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino || (xfs_sb_version_hasquota (&mp->m_sb) && - (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino))); + (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino || + ino == mp->m_sb.sb_pquotino))); }/*
fs/xfs/xfs_mount.c +1 -0
@@ -108,6 +108,7 @@ static const struct { { offsetof(xfs_sb_t, sb_logsunit), 0 }, { offsetof(xfs_sb_t, sb_features2), 0 }, { offsetof(xfs_sb_t, sb_bad_features2), 0 }, + { offsetof(xfs_sb_t, sb_pquotino), 0 }, { sizeof(xfs_sb_t), 0 } };
#pwhite: xfs_sb_(from|to)_disk() contain the new superblock format in which #we do away with OQUOTA flags to represent [PG]QUOTA.
@@ -593,20 +594,6 @@ xfs_sb_from_disk(
to->sb_uquotino = be64_to_cpu(from->sb_uquotino); to->sb_gquotino = be64_to_cpu(from->sb_gquotino); to->sb_qflags = be16_to_cpu(from->sb_qflags);
- if ((to->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) &&
- (to->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. Fixing it.\n");
- }
- if (to->sb_qflags & XFS_OQUOTA_ENFD)
- to->sb_qflags |= (to->sb_qflags & XFS_PQUOTA_ACCT) ?
- XFS_PQUOTA_ENFD : XFS_GQUOTA_ENFD;
- if (to->sb_qflags & XFS_OQUOTA_CHKD)
- to->sb_qflags |= (to->sb_qflags & XFS_PQUOTA_ACCT) ?
- XFS_PQUOTA_CHKD : XFS_GQUOTA_CHKD;
- to->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD);
-
to->sb_flags = from->sb_flags;
to->sb_shared_vn = from->sb_shared_vn; to->sb_inoalignmt = be32_to_cpu(from->sb_inoalignmt);
@@ -618,6 +605,33 @@ xfs_sb_from_disk(
to->sb_logsunit = be32_to_cpu(from->sb_logsunit); to->sb_features2 = be32_to_cpu(from->sb_features2); to->sb_bad_features2 = be32_to_cpu(from->sb_bad_features2);
+
+ if (xfs_sb_version_has_no_oquota(to)) {
+ if (to->sb_qflags & (XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD)) {
+ xfs_notice(mp, "Super block has XFS_OQUOTA bits with "
+ "version NO_OQUOTA. Fixing it.\n");
+ to->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD);
+ }
+ to->sb_pquotino = be64_to_cpu(from->sb_pquotino);
+ } else {
+ if (to->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD |
+ XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) {
+ xfs_notice(mp, "Super block has XFS_[G|P]UOTA bits in "
+ "older version. Fixing it.\n");
+ to->sb_qflags &= ~(XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD |
+ XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD);
+ }
+ if (to->sb_qflags & XFS_OQUOTA_ENFD)
+ to->sb_qflags |= (to->sb_qflags & XFS_PQUOTA_ACCT) ?
+ XFS_PQUOTA_ENFD : XFS_GQUOTA_ENFD;
+ if (to->sb_qflags & XFS_OQUOTA_CHKD)
+ to->sb_qflags |= (to->sb_qflags & XFS_PQUOTA_ACCT) ?
+ XFS_PQUOTA_CHKD : XFS_GQUOTA_CHKD;
+ to->sb_qflags &= ~(XFS_OQUOTA_ENFD | XFS_OQUOTA_CHKD);
+
+ if (to->sb_qflags & XFS_PQUOTA_ACCT)
+ to->sb_pquotino = to->sb_gquotino;
+ }
}
/*
@@ -636,26 +650,37 @@ xfs_sb_to_disk(
xfs_sb_field_t f;
int first;
int size;
- __be16 saved_qflags;
+ __be16 saved_qflags = 0;
ASSERT(fields);
if (!fields)
return;
- /*
- * in-core version of qflags do not have XFS_OQUOTA.*, whereas the
- * on-disk version does. So, save the in-core sb_qflags and restore
- * it after we modify and copy it to the buffer to be copied to
- * disk.
- */
- saved_qflags = from->sb_qflags;
- if (from->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD))
- from->sb_qflags |= XFS_OQUOTA_ENFD;
- if (from->sb_qflags & (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD))
- from->sb_qflags |= XFS_OQUOTA_CHKD;
- from->sb_qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD |
+ if (!xfs_sb_version_has_no_oquota(from) &&
+ (from->sb_qflags & (XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD |
+ XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD))) {
+
+ if (from->sb_qflags & (XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD)) {
+ from->sb_gquotino = from->sb_pquotino;
+ from->sb_pquotino = 0;
+ }
+ /*
+ * in-core version of qflags do not have XFS_OQUOTA.*, whereas
+ * the on-disk version does. So, save the in-core sb_qflags
+ * and restore it after we modify and copy it to the buffer
+ * to be copied to disk.
+ */
+ saved_qflags = from->sb_qflags;
+
+ if (from->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD))
+ from->sb_qflags |= XFS_OQUOTA_ENFD;
+ if (from->sb_qflags & (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD))
+ from->sb_qflags |= XFS_OQUOTA_CHKD;
+ from->sb_qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD |
XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD);
+ }
+
while (fields) {
f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); first = xfs_sb_info[f].offset;
@@ -686,7 +711,15 @@ xfs_sb_to_disk(
fields &= ~(1LL << f);
}
- from->sb_qflags = saved_qflags;
+
+ /* Revert to the old saved values */
+ if (saved_qflags) {
+ from->sb_qflags = saved_qflags;
+ if (from->sb_qflags & (XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD)) {
+ from->sb_pquotino = from->sb_gquotino;
+ from->sb_gquotino = NULLFSINO;
+ }
+ }
#pwhite: We'll need a bunch of checks like this in order to ensure that the #disk's super block isn't half converted from using OQUOTA to using [PG]QUOTA.
}
/*
@@ -754,6 +787,12 @@ reread:
goto reread;
}
+ if (!xfs_sb_version_has_no_oquota(&mp->m_sb) &&
+ XFS_IS_PQUOTA_ON(mp)) {
+ mp->m_sb.sb_pquotino = mp->m_sb.sb_gquotino;
+ mp->m_sb.sb_gquotino = NULLFSINO;
+ }
+
/* Initialize per-cpu counters */
xfs_icsb_reinit_counters(mp);
@@ -1672,6 +1711,12 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields)
first = sizeof(xfs_sb_t);
last = 0;
+ if (!xfs_sb_version_has_no_oquota(&mp->m_sb) &&
+ XFS_IS_PQUOTA_ON(mp)) {
+ fields &= (__int64_t)~XFS_SB_PQUOTINO;
+ fields |= (__int64_t)XFS_SB_GQUOTINO;
+ }
+
/* translate/copy */
xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb, fields);
fs/xfs/xfs_qm.c +12 -6
@@ -708,7 +708,8 @@ xfs_qm_dqattach_locked( !XFS_IS_QUOTA_ON (mp) || !XFS_NOT_DQATTACHED (mp, ip) || ip->i_ino == mp->m_sb.sb_uquotino || - ip->i_ino == mp->m_sb.sb_gquotino) + ip->i_ino == mp->m_sb.sb_gquotino || + ip->i_ino == mp->m_sb.sb_pquotino) return 0;ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));
@@ -819,6 +820,7 @@ xfs_qm_dqdetach(ASSERT (ip->i_ino != ip->i_mount->m_sb.sb_uquotino);ASSERT (ip->i_ino != ip->i_mount->m_sb.sb_gquotino); +ASSERT (ip->i_ino != ip->i_mount->m_sb.sb_pquotino);if (ip->i_udquot) {xfs_qm_dqrele (ip->i_udquot); ip->i_udquot =NULL ;
@@ -1058,19 +1060,22 @@ xfs_qm_qino_alloc(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_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 ; }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);
@@ -1377,7 +1382,8 @@ xfs_qm_dqusage_adjust(* rootino must have its resources accounted for, not so with the quota * inodes. */ -if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino) { +if (ino == mp->m_sb.sb_uquotino || ino == mp->m_sb.sb_gquotino || + ino == mp->m_sb.sb_pquotino) { *res =BULKSTAT_RV_NOTHING ;return XFS_ERROR (EINVAL ); }
@@ -1636,7 +1642,7 @@ 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 ); }/*
@@ -1666,7 +1672,7 @@ xfs_qm_init_quotainos( }if (XFS_IS_PQUOTA_ON (mp) && pip ==NULL ) { error =xfs_qm_qino_alloc (mp, &pip, - sbflags |XFS_SB_GQUOTINO , + sbflags |XFS_SB_PQUOTINO , flags |XFS_QMOPT_PQUOTA );if (error) {if (uip)
fs/xfs/xfs_qm_syscalls.c +23 -7
@@ -210,8 +210,7 @@ xfs_qm_scall_quotaoff(/* * If quotas is completely disabled, close shop. */ -if (((flags &XFS_MOUNT_QUOTA_ALL ) ==XFS_MOUNT_QUOTA_SET1 ) || - ((flags &XFS_MOUNT_QUOTA_ALL ) ==XFS_MOUNT_QUOTA_SET2 )) { +if ((flags &XFS_MOUNT_QUOTA_ALL ) ==XFS_MOUNT_QUOTA_ALL ) {mutex_unlock (&q->qi_quotaofflock);xfs_qm_destroy_quotainfo (mp);return (0 );
@@ -306,8 +305,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; }
@@ -423,17 +424,18 @@ xfs_qm_scall_getqstat( struct fs_quota_stat *out) {struct xfs_quotainfo *q = mp->m_quotainfo; -struct xfs_inode *uip, *gip; -boolean_t tempuqip, tempgqip; +struct xfs_inode *uip, *gip, *pip; +boolean_t tempuqip, tempgqip, temppqip; - uip = gip =NULL ; - tempuqip = tempgqip =B_FALSE ; + uip = gip = pip =NULL ; + tempuqip = tempgqip = temppqip =B_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 ; + out->qs_pquota.qfs_ino =NULLFSINO ;return (0 ); } out->qs_flags = (__uint16_t) xfs_qm_export_flags(mp->m_qflags &
@@ -442,10 +444,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,
@@ -457,6 +462,11 @@ xfs_qm_scall_getqstat( 0, 0, &gip) == 0) tempgqip =B_TRUE ; } +if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { +if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, +0 ,0 , &pip) ==0 ) + temppqip =B_TRUE ; + }if (uip) { out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; out->qs_uquota.qfs_nextents = uip->i_d.di_nextents;
@@ -469,6 +479,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_super.c +9 -6
@@ -400,12 +400,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 ;
@@ -1315,6 +1309,15 @@ xfs_fs_fill_super(if (error) goto out_destroy_counters; +if ((mp->m_qflags & (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE )) && + (mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE )) && + !xfs_sb_version_has_no_oquota (&mp->m_sb)) { +xfs_warn (mp,"Super block does not support " +"project and group quota together" ); + error =EINVAL ; + goto out_free_sb; + } +
#pwhite: This is a check for the old format superblock which could not do both #project & group quotas.
error = xfs_finish_flags(mp);
if (error)
goto out_free_sb;
fs/xfs/xfs_trans_dquot.c +3 -1
@@ -165,7 +165,8 @@ xfs_trans_mod_dquot_byino(if (!XFS_IS_QUOTA_RUNNING (mp) || !XFS_IS_QUOTA_ON (mp) || ip->i_ino == mp->m_sb.sb_uquotino || - ip->i_ino == mp->m_sb.sb_gquotino) + ip->i_ino == mp->m_sb.sb_gquotino || + ip->i_ino == mp->m_sb.sb_pquotino)return ;if (tp->t_dqinfo ==NULL )
@@ -859,6 +860,7 @@ xfs_trans_reserve_quota_nblks(ASSERT (ip->i_ino != mp->m_sb.sb_uquotino);ASSERT (ip->i_ino != mp->m_sb.sb_gquotino); +ASSERT (ip->i_ino != mp->m_sb.sb_pquotino);ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL )); ASSERT((flags & ~(XFS_QMOPT_FORCE_RES | XFS_QMOPT_ENOSPC)) ==
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
RFC PATCH v3 4/4 xfs: Add a new field to fs_quota_stat to get pquota information
In reply to Chandra SeetharamanAdd a new field to fs_quota_stat and define a new version for the bigger size.
--- fs/quota/quota.c | 6 +++++- fs/xfs/xfs_qm_syscalls.c | 26 +++++++++++++------------- include/linux/dqblk_xfs.h | 28 +++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 15 deletions(-)
include/linux/dqblk_xfs.h +27 -1
@@ -18,6 +18,7 @@#define _LINUX_DQBLK_XFS_H#include <linux/types.h> +#include <linux/stddef.h> /* * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM).
@@ -139,6 +140,7 @@ typedef struct fs_disk_quota {* incore. */ #define FS_QSTAT_VERSION 1/* fs_quota_stat.qs_version */ +#define FS_QSTAT_VERSION_2 2/* new field qs_pquota */ /* * Some basic information about 'quota files'.
@@ -155,13 +157,37 @@ 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 */ __s32 qs_rtbtimelimit;/* limit for rt blks timer */ __u16 qs_bwarnlimit;/* limit for num warnings */ __u16 qs_iwarnlimit;/* limit for num warnings */ + fs_qfilestat_t qs_pquota; /* project quota storage information */ } fs_quota_stat_t; +#define FS_QSTAT_V1_SIZE (offsetof(fs_quota_stat_t, qs_pquota)) +#define FS_QSTAT_V2_SIZE (FS_QSTAT_V1_SIZE + sizeof (fs_qfilestat_t)) + +static inline int valid_qstat_version (int version) +{ +switch (version) { +case FS_QSTAT_VERSION : +case FS_QSTAT_VERSION_2 : +return 1 ; +default : +return 0 ; + } +} +static inline int qstatsize (int version) +{ +switch (version) { +case FS_QSTAT_VERSION_2 : +return FS_QSTAT_V2_SIZE ; +case FS_QSTAT_VERSION : +default : +return FS_QSTAT_V1_SIZE ; + } +} +#endif /* _LINUX_DQBLK_XFS_H */
fs/quota/quota.c +5 -1
@@ -203,8 +203,12 @@ static int quota_getxstate(struct super_block *sb, void __user *addr)if (!sb->s_qcop->get_xstate)return -ENOSYS ; +if (copy_from_user (&fqs, addr,1 ))/* just get the version */ +return -EFAULT ; +if (!valid_qstat_version (fqs.qs_version)) + fqs.qs_version =FS_QSTAT_VERSION ; ret = sb->s_qcop->get_xstate (sb, &fqs); -if (!ret &©_to_user (addr, &fqs,sizeof (fqs))) +if (!ret &©_to_user (addr, &fqs,qstatsize (fqs.qs_version)))return -EFAULT ;return ret; }
fs/xfs/xfs_qm_syscalls.c +13 -13
@@ -431,7 +431,6 @@ xfs_qm_scall_getqstat( tempuqip = tempgqip = temppqip =B_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 ;
@@ -444,8 +443,6 @@ 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;
@@ -462,11 +459,6 @@ xfs_qm_scall_getqstat( 0, 0, &gip) == 0) tempgqip =B_TRUE ; } -if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { -if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, -0 ,0 , &pip) ==0 ) - temppqip =B_TRUE ; - }if (uip) { out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; out->qs_uquota.qfs_nextents = uip->i_d.di_nextents;
@@ -479,11 +471,19 @@ 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 (out->qs_version >=FS_QSTAT_VERSION_2 ) { + out->qs_pquota.qfs_ino = mp->m_sb.sb_pquotino; +if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { +if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, +0 ,0 , &pip) ==0 ) + temppqip =B_TRUE ; + } +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;
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
RFC PATCH v3 4/4 xfs: Add a new field to fs_quota_stat to get pquota information
#pwhite: This essentially just adds the detection for the new quota sizes. #The only quibble I have is on qstatsize(), but that might be because I don't #understand the basic assumption of the quota versioning not equalling V1 or V2.
Add a new field to fs_quota_stat and define a new version for the bigger size.
--- fs/quota/quota.c | 6 +++++- fs/xfs/xfs_qm_syscalls.c | 26 +++++++++++++------------- include/linux/dqblk_xfs.h | 28 +++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 15 deletions(-)
include/linux/dqblk_xfs.h +27 -1
@@ -18,6 +18,7 @@#define _LINUX_DQBLK_XFS_H#include <linux/types.h> +#include <linux/stddef.h> /* * Disk quota - quotactl(2) commands for the XFS Quota Manager (XQM).
@@ -139,6 +140,7 @@ typedef struct fs_disk_quota {* incore. */ #define FS_QSTAT_VERSION 1/* fs_quota_stat.qs_version */ +#define FS_QSTAT_VERSION_2 2/* new field qs_pquota */ /* * Some basic information about 'quota files'.
@@ -155,13 +157,37 @@ 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 */ __s32 qs_rtbtimelimit;/* limit for rt blks timer */ __u16 qs_bwarnlimit;/* limit for num warnings */ __u16 qs_iwarnlimit;/* limit for num warnings */ +fs_qfilestat_t qs_pquota;/* project quota storage information */ } fs_quota_stat_t; +#define FS_QSTAT_V1_SIZE (offsetof(fs_quota_stat_t, qs_pquota)) +#define FS_QSTAT_V2_SIZE (FS_QSTAT_V1_SIZE + sizeof (fs_qfilestat_t)) + +static inline int valid_qstat_version (int version) +{ +switch (version) { +case FS_QSTAT_VERSION : +case FS_QSTAT_VERSION_2 : +return 1 ; +default : +return 0 ; + } +} +static inline int qstatsize (int version) +{ +switch (version) { +case FS_QSTAT_VERSION_2 : +return FS_QSTAT_V2_SIZE ; +case FS_QSTAT_VERSION : +default : +return FS_QSTAT_V1_SIZE ; + } +} +
#pwhite: It seems like in the event of an invalid version, then we should #either return 0 or FS_QSTAT_V2_SIZE to ensure that we don't have something #trying to use the old version.
#endif /* _LINUX_DQBLK_XFS_H */
fs/quota/quota.c +5 -1
@@ -203,8 +203,12 @@ static int quota_getxstate(struct super_block *sb, void __user *addr)if (!sb->s_qcop->get_xstate)return -ENOSYS ; +if (copy_from_user (&fqs, addr,1 ))/* just get the version */ +return -EFAULT ; +if (!valid_qstat_version (fqs.qs_version)) + fqs.qs_version =FS_QSTAT_VERSION ; ret = sb->s_qcop->get_xstate (sb, &fqs); -if (!ret &©_to_user (addr, &fqs,sizeof (fqs))) +if (!ret &©_to_user (addr, &fqs,qstatsize (fqs.qs_version)))return -EFAULT ;return ret; }
fs/xfs/xfs_qm_syscalls.c +13 -13
@@ -431,7 +431,6 @@ xfs_qm_scall_getqstat( tempuqip = tempgqip = temppqip =B_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 ;
@@ -444,8 +443,6 @@ 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;
@@ -462,11 +459,6 @@ xfs_qm_scall_getqstat( 0, 0, &gip) == 0) tempgqip =B_TRUE ; } -if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { -if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, -0 ,0 , &pip) ==0 ) - temppqip =B_TRUE ; - }if (uip) { out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; out->qs_uquota.qfs_nextents = uip->i_d.di_nextents;
@@ -479,11 +471,19 @@ 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 (out->qs_version >=FS_QSTAT_VERSION_2 ) { + out->qs_pquota.qfs_ino = mp->m_sb.sb_pquotino; +if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { +if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, +0 ,0 , &pip) ==0 ) + temppqip =B_TRUE ; + } +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;
Signature · 6 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs