xfs: Start using pquotaino from the superblock.
PATCH 1/1 xfs: Start using pquotaino from the superblock.
Change from the previous version:
Addressed Ben's comments
- removed unnecessary sb_gquotino == NULLFSINO check in xfs_sb_quota_to_disk()
- Changed the fs_quota_stat logic to not fail with EINVAL if both gquota and pquota are available. Instead, fill fs_quota_stat only with gquota information.
----
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
--- fs/xfs/xfs_mount.c | 62 ++++++++++++++++++++++++++++++++++----- fs/xfs/xfs_qm.c | 72 ++++++++++++++++++++++++++++++++++----------- fs/xfs/xfs_qm_syscalls.c | 35 +++++++++++++++++++--- fs/xfs/xfs_sb.h | 13 ++++++-- fs/xfs/xfs_super.c | 19 ++++++------ 6 files changed, 159 insertions(+), 44 deletions(-)
fs/xfs/xfs_mount.c +54 -8
@@ -336,14 +336,6 @@ xfs_mount_validate_sb(return XFS_ERROR (EWRONGFS ); } -if ((sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) && - (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | -XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD ))) { -xfs_notice (mp, -"Super block has XFS_OQUOTA bits along with XFS_PQUOTA and/or XFS_GQUOTA bits.\n" ); -return XFS_ERROR (EFSCORRUPTED ); - } -/* * Version 5 superblock feature mask validation. Reject combinations the * kernel cannot support up front before checking anything else. For
@@ -387,6 +379,19 @@ xfs_mount_validate_sb( } } +if (xfs_sb_version_has_pquotino (sbp)) { +if (sbp->sb_qflags & (XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD )) { +xfs_notice (mp, +"Version 5 of Super block has XFS_OQUOTA bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + } + }else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD |XFS_GQUOTA_ENFD | +XFS_PQUOTA_CHKD |XFS_GQUOTA_CHKD )) { +xfs_notice (mp, +"Superblock earlier than Version 5 has XFS_[PQ]UOTA_{ENFD|CHKD} bits.\n" ); +return XFS_ERROR (EFSCORRUPTED ); + } +if (unlikely ( sbp->sb_logstart ==0 && mp->m_logdev_targp == mp->m_ddev_targp)) { xfs_warn(mp,
@@ -590,6 +595,13 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp)if (sbp->sb_pquotino ==0 ) sbp->sb_pquotino =NULLFSINO ; +/* +* We need to do these manipilations only if we are working +* with an older version of on-disk superblock. +*/ +if (xfs_sb_version_has_pquotino (sbp)) +return ; +if (sbp->sb_qflags &XFS_OQUOTA_ENFD ) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_ENFD :XFS_GQUOTA_ENFD ;
@@ -597,6 +609,18 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp) sbp->sb_qflags |= (sbp->sb_qflags &XFS_PQUOTA_ACCT ) ?XFS_PQUOTA_CHKD :XFS_GQUOTA_CHKD ; sbp->sb_qflags &= ~(XFS_OQUOTA_ENFD |XFS_OQUOTA_CHKD ); + +if (sbp->sb_qflags &XFS_PQUOTA_ACCT ) { +/* +* In older version of superblock, on-disk superblock only +* has sb_gquotino, and in-core superblock has both sb_gquotino +* and sb_pquotino. But, only one of them is supported at any +* point of time. So, if PQUOTA is set in disk superblock, +* copy over sb_gquotino to sb_pquotino. +*/ + sbp->sb_pquotino = sbp->sb_gquotino; + sbp->sb_gquotino =NULLFSINO ; + } }void
@@ -668,6 +692,13 @@ xfs_sb_quota_to_disk( {__uint16_t qflags = from->sb_qflags; +/* +* We need to do these manipilations only if we are working +* with an older version of on-disk superblock. +*/ +if (xfs_sb_version_has_pquotino (from)) +return ; +if (*fields &XFS_SB_QFLAGS ) {/* * The in-core version of sb_qflags do not have
@@ -687,6 +718,21 @@ xfs_sb_quota_to_disk( to->sb_qflags =cpu_to_be16 (qflags); *fields &= ~XFS_SB_QFLAGS ; } + +/* +* GQUOTINO and PQUOTINO cannot be used together in versions +* of superblock that do not have pquotino. from->sb_flags +* tells us which quota is active and should be copied to +* disk. +*/ +if ((*fields &XFS_SB_GQUOTINO ) && + (from->sb_qflags &XFS_GQUOTA_ACCT )) + to->sb_gquotino =cpu_to_be64 (from->sb_gquotino); +else if ((*fields &XFS_SB_PQUOTINO ) && + (from->sb_qflags &XFS_PQUOTA_ACCT )) + to->sb_gquotino =cpu_to_be64 (from->sb_pquotino); + + *fields &= ~(XFS_SB_PQUOTINO |XFS_SB_GQUOTINO ); }/*
fs/xfs/xfs_qm.c +54 -18
119 lines not on this page · raw message
fs/xfs/xfs_qm_syscalls.c +30 -5
@@ -296,8 +296,10 @@ xfs_qm_scall_trunc_qfiles(if (flags &XFS_DQ_USER ) error =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_uquotino); -if (flags & (XFS_DQ_GROUP |XFS_DQ_PROJ )) +if (flags &XFS_DQ_GROUP ) error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_gquotino); +if (flags &XFS_DQ_PROJ ) + error2 =xfs_qm_scall_trunc_qfile (mp, mp->m_sb.sb_pquotino);return error ? error : error2; }
@@ -413,8 +415,10 @@ xfs_qm_scall_getqstat(struct xfs_quotainfo *q = mp->m_quotainfo;struct xfs_inode *uip =NULL ;struct xfs_inode *gip =NULL ; +struct xfs_inode *pip =NULL ;bool tempuqip = false;bool tempgqip = false; +bool temppqip = false;memset (out,0 ,sizeof (fs_quota_stat_t));
@@ -424,16 +428,14 @@ xfs_qm_scall_getqstat( out->qs_gquota.qfs_ino =NULLFSINO ;return (0 ); } + out->qs_flags = (__uint16_t )xfs_qm_export_flags (mp->m_qflags & (XFS_ALL_QUOTA_ACCT |XFS_ALL_QUOTA_ENFD )); - out->qs_pad =0 ; - out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; - out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; -if (q) { uip = q->qi_uquotaip; gip = q->qi_gquotaip; + pip = q->qi_pquotaip; }if (!uip && mp->m_sb.sb_uquotino !=NULLFSINO ) { if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
@@ -445,18 +447,41 @@ xfs_qm_scall_getqstat( 0, 0, &gip) == 0) tempgqip = true; } +/* +* Q_XGETQSTAT doesn't have room for both group and project quotas. +* So, allow the project quota values to be copied out only if +* there is no group quota information available. +*/ +if (!gip) { +if (!pip && mp->m_sb.sb_pquotino !=NULLFSINO ) { +if (xfs_iget (mp,NULL , mp->m_sb.sb_pquotino, +0 ,0 , &pip) ==0 ) + temppqip = true; + } + }else + pip =NULL ;if (uip) { + out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; out->qs_uquota.qfs_nblks = uip->i_d.di_nblocks; out->qs_uquota.qfs_nextents = uip->i_d.di_nextents;if (tempuqip)IRELE (uip); } +if (gip) { + out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; out->qs_gquota.qfs_nblks = gip->i_d.di_nblocks; out->qs_gquota.qfs_nextents = gip->i_d.di_nextents;if (tempgqip)IRELE (gip); } +if (pip) { + out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; + out->qs_gquota.qfs_nblks = pip->i_d.di_nblocks; + out->qs_gquota.qfs_nextents = pip->i_d.di_nextents; +if (temppqip) +IRELE (pip); + }if (q) { out->qs_incoredqs = q->qi_dquots; out->qs_btimelimit = q->qi_btimelimit;
fs/xfs/xfs_sb.h +10 -3
@@ -618,16 +618,23 @@ xfs_sb_has_incompat_log_feature(return (sbp->sb_features_log_incompat & feature) !=0 ; } -static inline bool -xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) +static inline int xfs_sb_version_has_pquotino (xfs_sb_t *sbp) { -return (ino == sbp->sb_uquotino || ino == sbp->sb_gquotino); +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; }/* * end of superblock version macros */ +static inline bool +xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) +{ +return (ino == sbp->sb_uquotino || + ino == sbp->sb_gquotino || + ino == sbp->sb_pquotino); +} +#define XFS_SB_DADDR ((xfs_daddr_t)0)/* daddr in filesystem/ag */ #define XFS_SB_BLOCK (mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR)#define XFS_BUF_TO_SBP (bp) ((xfs_dsb_t *)((bp)->b_addr))
fs/xfs/xfs_super.c +10 -9
@@ -421,12 +421,6 @@ xfs_parseargs( }#endif -if ((mp->m_qflags & (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE )) && - (mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE ))) { -xfs_warn (mp,"cannot mount with both project and group quota" ); -return EINVAL ; - } -if ((dsunit && !dswidth) || (!dsunit && dswidth)) {xfs_warn (mp,"sunit and swidth must be specified together" );return EINVAL ;
@@ -556,14 +550,13 @@ xfs_showargs(else if (mp->m_qflags &XFS_UQUOTA_ACCT )seq_puts (m,"," MNTOPT_UQUOTANOENF ); -/* Either project or group quotas can be active, not both */ -if (mp->m_qflags &XFS_PQUOTA_ACCT ) {if (mp->m_qflags &XFS_PQUOTA_ENFD )seq_puts (m,"," MNTOPT_PRJQUOTA );else seq_puts (m,"," MNTOPT_PQUOTANOENF ); - }else if (mp->m_qflags &XFS_GQUOTA_ACCT ) { + } +if (mp->m_qflags &XFS_GQUOTA_ACCT ) {if (mp->m_qflags &XFS_GQUOTA_ENFD )seq_puts (m,"," MNTOPT_GRPQUOTA );else
@@ -1396,6 +1389,14 @@ xfs_finish_flags(return XFS_ERROR (EROFS ); } +if ((mp->m_qflags & (XFS_GQUOTA_ACCT |XFS_GQUOTA_ACTIVE )) && + (mp->m_qflags & (XFS_PQUOTA_ACCT |XFS_PQUOTA_ACTIVE )) && + !xfs_sb_version_has_pquotino (&mp->m_sb)) { +xfs_warn (mp, +"Super block does not support project and group quota together" ); +return XFS_ERROR (EINVAL ); + } +return 0 ; }
Signature · 8 lines
1.7.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 9 lines · Chandra Seetharaman
Change from the previous version:
Addressed Ben's comments
- removed unnecessarysb_gquotino== NULLFSINO check inxfs_sb_quota_to_disk()
- Changed thefs_quota_statlogic to not fail with EINVAL if both gquota and pquota are available. Instead, fillfs_quota_statonly with gquota information.
----
Quoted 7 lines
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
Signed-off-by Chandra Seetharaman <[email protected]>
Looks good!
Applied. As much as I'd like to send this in a pull request for -rc3, IMO this is the sort of material that is most appropriate for a merge window. I think we'd better wait for 3.12-rc1 merge window to open. Sorry about that.
Thanks,
Ben
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 9 lines · Chandra Seetharaman
Change from the previous version:
Addressed Ben's comments
- removed unnecessarysb_gquotino== NULLFSINO check inxfs_sb_quota_to_disk()
- Changed thefs_quota_statlogic to not fail with EINVAL if both gquota and pquota are available. Instead, fillfs_quota_statonly with gquota information.
----
Quoted 7 lines
Start using pquotino and define a macro to check if the superblock has pquotino.
Keep backward compatibilty by alowing mount of older superblock with no separate pquota inode.
Signed-off-by Chandra Seetharaman <[email protected]>
Chandra, now that this has been comitted, can you make sure that the userspace tools handle the separate pquota inode correctly (i.e. reapir, db, etc). You'll probably be best to work from the crc-dev branch of the xfsprogs tree...
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs