|
@@ -81,12 +81,18 @@ struct xfs_qm *xfs_Gqm;
|
|
|
|
|
|
kmem_zone_t *qm_dqzone;
|
|
|
kmem_zone_t *qm_dqtrxzone;
|
|
|
-kmem_shaker_t xfs_qm_shaker;
|
|
|
+STATIC kmem_shaker_t xfs_qm_shaker;
|
|
|
|
|
|
STATIC void xfs_qm_list_init(xfs_dqlist_t *, char *, int);
|
|
|
STATIC void xfs_qm_list_destroy(xfs_dqlist_t *);
|
|
|
|
|
|
+STATIC void xfs_qm_freelist_init(xfs_frlist_t *);
|
|
|
+STATIC void xfs_qm_freelist_destroy(xfs_frlist_t *);
|
|
|
+STATIC int xfs_qm_mplist_nowait(xfs_mount_t *);
|
|
|
+STATIC int xfs_qm_dqhashlock_nowait(xfs_dquot_t *);
|
|
|
+
|
|
|
STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
|
|
|
+STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
|
|
|
STATIC int xfs_qm_shake(int, unsigned int);
|
|
|
|
|
|
#ifdef DEBUG
|
|
@@ -184,7 +190,7 @@ xfs_Gqm_init(void)
|
|
|
/*
|
|
|
* Destroy the global quota manager when its reference count goes to zero.
|
|
|
*/
|
|
|
-void
|
|
|
+STATIC void
|
|
|
xfs_qm_destroy(
|
|
|
struct xfs_qm *xqm)
|
|
|
{
|
|
@@ -304,9 +310,9 @@ xfs_qm_mount_quotainit(
|
|
|
uint flags)
|
|
|
{
|
|
|
/*
|
|
|
- * User or group quotas has to be on.
|
|
|
+ * User, projects or group quotas has to be on.
|
|
|
*/
|
|
|
- ASSERT(flags & (XFSMNT_UQUOTA | XFSMNT_GQUOTA));
|
|
|
+ ASSERT(flags & (XFSMNT_UQUOTA | XFSMNT_PQUOTA | XFSMNT_GQUOTA));
|
|
|
|
|
|
/*
|
|
|
* Initialize the flags in the mount structure. From this point
|
|
@@ -324,7 +330,11 @@ xfs_qm_mount_quotainit(
|
|
|
if (flags & XFSMNT_GQUOTA) {
|
|
|
mp->m_qflags |= (XFS_GQUOTA_ACCT | XFS_GQUOTA_ACTIVE);
|
|
|
if (flags & XFSMNT_GQUOTAENF)
|
|
|
- mp->m_qflags |= XFS_GQUOTA_ENFD;
|
|
|
+ mp->m_qflags |= XFS_OQUOTA_ENFD;
|
|
|
+ } else if (flags & XFSMNT_PQUOTA) {
|
|
|
+ mp->m_qflags |= (XFS_PQUOTA_ACCT | XFS_PQUOTA_ACTIVE);
|
|
|
+ if (flags & XFSMNT_PQUOTAENF)
|
|
|
+ mp->m_qflags |= XFS_OQUOTA_ENFD;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -357,11 +367,11 @@ xfs_qm_mount_quotas(
|
|
|
|
|
|
/*
|
|
|
* If a file system had quotas running earlier, but decided to
|
|
|
- * mount without -o quota/uquota/gquota options, revoke the
|
|
|
+ * mount without -o uquota/pquota/gquota options, revoke the
|
|
|
* quotachecked license, and bail out.
|
|
|
*/
|
|
|
if (! XFS_IS_QUOTA_ON(mp) &&
|
|
|
- (mp->m_sb.sb_qflags & (XFS_UQUOTA_ACCT|XFS_GQUOTA_ACCT))) {
|
|
|
+ (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_ACCT)) {
|
|
|
mp->m_qflags = 0;
|
|
|
goto write_changes;
|
|
|
}
|
|
@@ -509,7 +519,7 @@ out:
|
|
|
* Flush all dquots of the given file system to disk. The dquots are
|
|
|
* _not_ purged from memory here, just their data written to disk.
|
|
|
*/
|
|
|
-int
|
|
|
+STATIC int
|
|
|
xfs_qm_dqflush_all(
|
|
|
xfs_mount_t *mp,
|
|
|
int flags)
|
|
@@ -613,7 +623,7 @@ xfs_qm_detach_gdquots(
|
|
|
STATIC int
|
|
|
xfs_qm_dqpurge_int(
|
|
|
xfs_mount_t *mp,
|
|
|
- uint flags) /* QUOTAOFF/UMOUNTING/UQUOTA/GQUOTA */
|
|
|
+ uint flags) /* QUOTAOFF/UMOUNTING/UQUOTA/PQUOTA/GQUOTA */
|
|
|
{
|
|
|
xfs_dquot_t *dqp;
|
|
|
uint dqtype;
|
|
@@ -625,6 +635,7 @@ xfs_qm_dqpurge_int(
|
|
|
return (0);
|
|
|
|
|
|
dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0;
|
|
|
+ dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0;
|
|
|
dqtype |= (flags & XFS_QMOPT_GQUOTA) ? XFS_DQ_GROUP : 0;
|
|
|
|
|
|
xfs_qm_mplist_lock(mp);
|
|
@@ -734,11 +745,11 @@ xfs_qm_dqattach_one(
|
|
|
|
|
|
/*
|
|
|
* udqhint is the i_udquot field in inode, and is non-NULL only
|
|
|
- * when the type arg is XFS_DQ_GROUP. Its purpose is to save a
|
|
|
+ * when the type arg is group/project. Its purpose is to save a
|
|
|
* lookup by dqid (xfs_qm_dqget) by caching a group dquot inside
|
|
|
* the user dquot.
|
|
|
*/
|
|
|
- ASSERT(!udqhint || type == XFS_DQ_GROUP);
|
|
|
+ ASSERT(!udqhint || type == XFS_DQ_GROUP || type == XFS_DQ_PROJ);
|
|
|
if (udqhint && !dolock)
|
|
|
xfs_dqlock(udqhint);
|
|
|
|
|
@@ -897,8 +908,8 @@ xfs_qm_dqattach_grouphint(
|
|
|
|
|
|
|
|
|
/*
|
|
|
- * Given a locked inode, attach dquot(s) to it, taking UQUOTAON / GQUOTAON
|
|
|
- * in to account.
|
|
|
+ * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON
|
|
|
+ * into account.
|
|
|
* If XFS_QMOPT_DQALLOC, the dquot(s) will be allocated if needed.
|
|
|
* If XFS_QMOPT_DQLOCK, the dquot(s) will be returned locked. This option pretty
|
|
|
* much made this code a complete mess, but it has been pretty useful.
|
|
@@ -937,8 +948,13 @@ xfs_qm_dqattach(
|
|
|
nquotas++;
|
|
|
}
|
|
|
ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
|
|
|
- if (XFS_IS_GQUOTA_ON(mp)) {
|
|
|
- error = xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP,
|
|
|
+ if (XFS_IS_OQUOTA_ON(mp)) {
|
|
|
+ error = XFS_IS_GQUOTA_ON(mp) ?
|
|
|
+ xfs_qm_dqattach_one(ip, ip->i_d.di_gid, XFS_DQ_GROUP,
|
|
|
+ flags & XFS_QMOPT_DQALLOC,
|
|
|
+ flags & XFS_QMOPT_DQLOCK,
|
|
|
+ ip->i_udquot, &ip->i_gdquot) :
|
|
|
+ xfs_qm_dqattach_one(ip, ip->i_d.di_projid, XFS_DQ_PROJ,
|
|
|
flags & XFS_QMOPT_DQALLOC,
|
|
|
flags & XFS_QMOPT_DQLOCK,
|
|
|
ip->i_udquot, &ip->i_gdquot);
|
|
@@ -989,7 +1005,7 @@ xfs_qm_dqattach(
|
|
|
}
|
|
|
if (XFS_IS_UQUOTA_ON(mp))
|
|
|
ASSERT(ip->i_udquot);
|
|
|
- if (XFS_IS_GQUOTA_ON(mp))
|
|
|
+ if (XFS_IS_OQUOTA_ON(mp))
|
|
|
ASSERT(ip->i_gdquot);
|
|
|
}
|
|
|
#endif
|
|
@@ -1018,13 +1034,13 @@ 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);
|
|
|
- if (ip->i_udquot)
|
|
|
- xfs_dqtrace_entry_ino(ip->i_udquot, "DQDETTACH", ip);
|
|
|
if (ip->i_udquot) {
|
|
|
+ xfs_dqtrace_entry_ino(ip->i_udquot, "DQDETTACH", ip);
|
|
|
xfs_qm_dqrele(ip->i_udquot);
|
|
|
ip->i_udquot = NULL;
|
|
|
}
|
|
|
if (ip->i_gdquot) {
|
|
|
+ xfs_dqtrace_entry_ino(ip->i_gdquot, "DQDETTACH", ip);
|
|
|
xfs_qm_dqrele(ip->i_gdquot);
|
|
|
ip->i_gdquot = NULL;
|
|
|
}
|
|
@@ -1149,7 +1165,7 @@ xfs_qm_sync(
|
|
|
* This initializes all the quota information that's kept in the
|
|
|
* mount structure
|
|
|
*/
|
|
|
-int
|
|
|
+STATIC int
|
|
|
xfs_qm_init_quotainfo(
|
|
|
xfs_mount_t *mp)
|
|
|
{
|
|
@@ -1202,8 +1218,9 @@ xfs_qm_init_quotainfo(
|
|
|
* and group quotas, at least not at this point.
|
|
|
*/
|
|
|
error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)0,
|
|
|
- (XFS_IS_UQUOTA_RUNNING(mp)) ?
|
|
|
- XFS_DQ_USER : XFS_DQ_GROUP,
|
|
|
+ XFS_IS_UQUOTA_RUNNING(mp) ? XFS_DQ_USER :
|
|
|
+ (XFS_IS_GQUOTA_RUNNING(mp) ? XFS_DQ_GROUP :
|
|
|
+ XFS_DQ_PROJ),
|
|
|
XFS_QMOPT_DQSUSER|XFS_QMOPT_DOWARN,
|
|
|
&dqp);
|
|
|
if (! error) {
|
|
@@ -1234,6 +1251,10 @@ xfs_qm_init_quotainfo(
|
|
|
INT_GET(ddqp->d_iwarns, ARCH_CONVERT) ?
|
|
|
INT_GET(ddqp->d_iwarns, ARCH_CONVERT) :
|
|
|
XFS_QM_IWARNLIMIT;
|
|
|
+ qinf->qi_rtbwarnlimit =
|
|
|
+ INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) ?
|
|
|
+ INT_GET(ddqp->d_rtbwarns, ARCH_CONVERT) :
|
|
|
+ XFS_QM_RTBWARNLIMIT;
|
|
|
qinf->qi_bhardlimit =
|
|
|
INT_GET(ddqp->d_blk_hardlimit, ARCH_CONVERT);
|
|
|
qinf->qi_bsoftlimit =
|
|
@@ -1259,6 +1280,7 @@ xfs_qm_init_quotainfo(
|
|
|
qinf->qi_rtbtimelimit = XFS_QM_RTBTIMELIMIT;
|
|
|
qinf->qi_bwarnlimit = XFS_QM_BWARNLIMIT;
|
|
|
qinf->qi_iwarnlimit = XFS_QM_IWARNLIMIT;
|
|
|
+ qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
|
|
|
}
|
|
|
|
|
|
return (0);
|
|
@@ -1366,13 +1388,20 @@ xfs_qm_dqget_noattach(
|
|
|
ASSERT(udqp);
|
|
|
}
|
|
|
|
|
|
- if (XFS_IS_GQUOTA_ON(mp)) {
|
|
|
+ if (XFS_IS_OQUOTA_ON(mp)) {
|
|
|
ASSERT(ip->i_gdquot == NULL);
|
|
|
if (udqp)
|
|
|
xfs_dqunlock(udqp);
|
|
|
- if ((error = xfs_qm_dqget(mp, ip, ip->i_d.di_gid, XFS_DQ_GROUP,
|
|
|
- XFS_QMOPT_DQALLOC|XFS_QMOPT_DOWARN,
|
|
|
- &gdqp))) {
|
|
|
+ error = XFS_IS_GQUOTA_ON(mp) ?
|
|
|
+ xfs_qm_dqget(mp, ip,
|
|
|
+ ip->i_d.di_gid, XFS_DQ_GROUP,
|
|
|
+ XFS_QMOPT_DQALLOC|XFS_QMOPT_DOWARN,
|
|
|
+ &gdqp) :
|
|
|
+ xfs_qm_dqget(mp, ip,
|
|
|
+ ip->i_d.di_projid, XFS_DQ_PROJ,
|
|
|
+ XFS_QMOPT_DQALLOC|XFS_QMOPT_DOWARN,
|
|
|
+ &gdqp);
|
|
|
+ if (error) {
|
|
|
if (udqp)
|
|
|
xfs_qm_dqrele(udqp);
|
|
|
ASSERT(error != ESRCH);
|
|
@@ -1521,8 +1550,10 @@ xfs_qm_reset_dqcounts(
|
|
|
INT_SET(ddq->d_rtbcount, ARCH_CONVERT, 0ULL);
|
|
|
INT_SET(ddq->d_btimer, ARCH_CONVERT, (time_t)0);
|
|
|
INT_SET(ddq->d_itimer, ARCH_CONVERT, (time_t)0);
|
|
|
+ INT_SET(ddq->d_rtbtimer, ARCH_CONVERT, (time_t)0);
|
|
|
INT_SET(ddq->d_bwarns, ARCH_CONVERT, 0UL);
|
|
|
INT_SET(ddq->d_iwarns, ARCH_CONVERT, 0UL);
|
|
|
+ INT_SET(ddq->d_rtbwarns, ARCH_CONVERT, 0UL);
|
|
|
ddq = (xfs_disk_dquot_t *) ((xfs_dqblk_t *)ddq + 1);
|
|
|
}
|
|
|
|
|
@@ -1541,11 +1572,14 @@ xfs_qm_dqiter_bufs(
|
|
|
int error;
|
|
|
int notcommitted;
|
|
|
int incr;
|
|
|
+ int type;
|
|
|
|
|
|
ASSERT(blkcnt > 0);
|
|
|
notcommitted = 0;
|
|
|
incr = (blkcnt > XFS_QM_MAX_DQCLUSTER_LOGSZ) ?
|
|
|
XFS_QM_MAX_DQCLUSTER_LOGSZ : blkcnt;
|
|
|
+ type = flags & XFS_QMOPT_UQUOTA ? XFS_DQ_USER :
|
|
|
+ (flags & XFS_QMOPT_PQUOTA ? XFS_DQ_PROJ : XFS_DQ_GROUP);
|
|
|
error = 0;
|
|
|
|
|
|
/*
|
|
@@ -1564,9 +1598,7 @@ xfs_qm_dqiter_bufs(
|
|
|
if (error)
|
|
|
break;
|
|
|
|
|
|
- (void) xfs_qm_reset_dqcounts(mp, bp, firstid,
|
|
|
- flags & XFS_QMOPT_UQUOTA ?
|
|
|
- XFS_DQ_USER : XFS_DQ_GROUP);
|
|
|
+ (void) xfs_qm_reset_dqcounts(mp, bp, firstid, type);
|
|
|
xfs_bdwrite(mp, bp);
|
|
|
/*
|
|
|
* goto the next block.
|
|
@@ -1578,7 +1610,7 @@ xfs_qm_dqiter_bufs(
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * Iterate over all allocated USR/GRP dquots in the system, calling a
|
|
|
+ * Iterate over all allocated USR/GRP/PRJ dquots in the system, calling a
|
|
|
* caller supplied function for every chunk of dquots that we find.
|
|
|
*/
|
|
|
STATIC int
|
|
@@ -1849,7 +1881,7 @@ xfs_qm_dqusage_adjust(
|
|
|
xfs_qm_quotacheck_dqadjust(udqp, nblks, rtblks);
|
|
|
xfs_qm_dqput(udqp);
|
|
|
}
|
|
|
- if (XFS_IS_GQUOTA_ON(mp)) {
|
|
|
+ if (XFS_IS_OQUOTA_ON(mp)) {
|
|
|
ASSERT(gdqp);
|
|
|
xfs_qm_quotacheck_dqadjust(gdqp, nblks, rtblks);
|
|
|
xfs_qm_dqput(gdqp);
|
|
@@ -1898,7 +1930,7 @@ xfs_qm_quotacheck(
|
|
|
cmn_err(CE_NOTE, "XFS quotacheck %s: Please wait.", mp->m_fsname);
|
|
|
|
|
|
/*
|
|
|
- * First we go thru all the dquots on disk, USR and GRP, and reset
|
|
|
+ * First we go thru all the dquots on disk, USR and GRP/PRJ, and reset
|
|
|
* their counters to zero. We need a clean slate.
|
|
|
* We don't log our changes till later.
|
|
|
*/
|
|
@@ -1909,9 +1941,10 @@ xfs_qm_quotacheck(
|
|
|
}
|
|
|
|
|
|
if ((gip = XFS_QI_GQIP(mp))) {
|
|
|
- if ((error = xfs_qm_dqiterate(mp, gip, XFS_QMOPT_GQUOTA)))
|
|
|
+ if ((error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ?
|
|
|
+ XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA)))
|
|
|
goto error_return;
|
|
|
- flags |= XFS_GQUOTA_CHKD;
|
|
|
+ flags |= XFS_OQUOTA_CHKD;
|
|
|
}
|
|
|
|
|
|
do {
|
|
@@ -1938,7 +1971,7 @@ xfs_qm_quotacheck(
|
|
|
if (error) {
|
|
|
xfs_qm_dqpurge_all(mp,
|
|
|
XFS_QMOPT_UQUOTA|XFS_QMOPT_GQUOTA|
|
|
|
- XFS_QMOPT_QUOTAOFF);
|
|
|
+ XFS_QMOPT_PQUOTA|XFS_QMOPT_QUOTAOFF);
|
|
|
goto error_return;
|
|
|
}
|
|
|
/*
|
|
@@ -1961,7 +1994,7 @@ xfs_qm_quotacheck(
|
|
|
* quotachecked status, since we won't be doing accounting for
|
|
|
* that type anymore.
|
|
|
*/
|
|
|
- mp->m_qflags &= ~(XFS_GQUOTA_CHKD | XFS_UQUOTA_CHKD);
|
|
|
+ mp->m_qflags &= ~(XFS_OQUOTA_CHKD | XFS_UQUOTA_CHKD);
|
|
|
mp->m_qflags |= flags;
|
|
|
|
|
|
XQM_LIST_PRINT(&(XFS_QI_MPL_LIST(mp)), MPL_NEXT, "++++ Mp list +++");
|
|
@@ -2013,7 +2046,7 @@ xfs_qm_init_quotainos(
|
|
|
0, 0, &uip, 0)))
|
|
|
return XFS_ERROR(error);
|
|
|
}
|
|
|
- if (XFS_IS_GQUOTA_ON(mp) &&
|
|
|
+ if (XFS_IS_OQUOTA_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,
|
|
@@ -2043,10 +2076,12 @@ xfs_qm_init_quotainos(
|
|
|
|
|
|
flags &= ~XFS_QMOPT_SBVERSION;
|
|
|
}
|
|
|
- if (XFS_IS_GQUOTA_ON(mp) && gip == NULL) {
|
|
|
- if ((error = xfs_qm_qino_alloc(mp, &gip,
|
|
|
- sbflags | XFS_SB_GQUOTINO,
|
|
|
- flags | XFS_QMOPT_GQUOTA))) {
|
|
|
+ if (XFS_IS_OQUOTA_ON(mp) && gip == NULL) {
|
|
|
+ flags |= (XFS_IS_GQUOTA_ON(mp) ?
|
|
|
+ XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);
|
|
|
+ error = xfs_qm_qino_alloc(mp, &gip,
|
|
|
+ sbflags | XFS_SB_GQUOTINO, flags);
|
|
|
+ if (error) {
|
|
|
if (uip)
|
|
|
VN_RELE(XFS_ITOV(uip));
|
|
|
|
|
@@ -2452,6 +2487,7 @@ xfs_qm_vop_dqalloc(
|
|
|
xfs_inode_t *ip,
|
|
|
uid_t uid,
|
|
|
gid_t gid,
|
|
|
+ prid_t prid,
|
|
|
uint flags,
|
|
|
xfs_dquot_t **O_udqpp,
|
|
|
xfs_dquot_t **O_gdqpp)
|
|
@@ -2483,8 +2519,7 @@ xfs_qm_vop_dqalloc(
|
|
|
}
|
|
|
|
|
|
uq = gq = NULL;
|
|
|
- if ((flags & XFS_QMOPT_UQUOTA) &&
|
|
|
- XFS_IS_UQUOTA_ON(mp)) {
|
|
|
+ if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) {
|
|
|
if (ip->i_d.di_uid != uid) {
|
|
|
/*
|
|
|
* What we need is the dquot that has this uid, and
|
|
@@ -2522,8 +2557,7 @@ xfs_qm_vop_dqalloc(
|
|
|
xfs_dqunlock(uq);
|
|
|
}
|
|
|
}
|
|
|
- if ((flags & XFS_QMOPT_GQUOTA) &&
|
|
|
- XFS_IS_GQUOTA_ON(mp)) {
|
|
|
+ if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) {
|
|
|
if (ip->i_d.di_gid != gid) {
|
|
|
xfs_iunlock(ip, lockflags);
|
|
|
if ((error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid,
|
|
@@ -2546,6 +2580,29 @@ xfs_qm_vop_dqalloc(
|
|
|
XFS_DQHOLD(gq);
|
|
|
xfs_dqunlock(gq);
|
|
|
}
|
|
|
+ } else if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) {
|
|
|
+ if (ip->i_d.di_projid != 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))) {
|
|
|
+ if (uq)
|
|
|
+ xfs_qm_dqrele(uq);
|
|
|
+ ASSERT(error != ENOENT);
|
|
|
+ return (error);
|
|
|
+ }
|
|
|
+ xfs_dqunlock(gq);
|
|
|
+ lockflags = XFS_ILOCK_SHARED;
|
|
|
+ xfs_ilock(ip, lockflags);
|
|
|
+ } else {
|
|
|
+ ASSERT(ip->i_gdquot);
|
|
|
+ gq = ip->i_gdquot;
|
|
|
+ xfs_dqlock(gq);
|
|
|
+ XFS_DQHOLD(gq);
|
|
|
+ xfs_dqunlock(gq);
|
|
|
+ }
|
|
|
}
|
|
|
if (uq)
|
|
|
xfs_dqtrace_entry_ino(uq, "DQALLOC", ip);
|
|
@@ -2574,6 +2631,9 @@ xfs_qm_vop_chown(
|
|
|
xfs_dquot_t *newdq)
|
|
|
{
|
|
|
xfs_dquot_t *prevdq;
|
|
|
+ uint bfield = XFS_IS_REALTIME_INODE(ip) ?
|
|
|
+ XFS_TRANS_DQ_RTBCOUNT : XFS_TRANS_DQ_BCOUNT;
|
|
|
+
|
|
|
ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
|
|
|
ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount));
|
|
|
|
|
@@ -2582,20 +2642,12 @@ xfs_qm_vop_chown(
|
|
|
ASSERT(prevdq);
|
|
|
ASSERT(prevdq != newdq);
|
|
|
|
|
|
- xfs_trans_mod_dquot(tp, prevdq,
|
|
|
- XFS_TRANS_DQ_BCOUNT,
|
|
|
- -(ip->i_d.di_nblocks));
|
|
|
- xfs_trans_mod_dquot(tp, prevdq,
|
|
|
- XFS_TRANS_DQ_ICOUNT,
|
|
|
- -1);
|
|
|
+ xfs_trans_mod_dquot(tp, prevdq, bfield, -(ip->i_d.di_nblocks));
|
|
|
+ xfs_trans_mod_dquot(tp, prevdq, XFS_TRANS_DQ_ICOUNT, -1);
|
|
|
|
|
|
/* the sparkling new dquot */
|
|
|
- xfs_trans_mod_dquot(tp, newdq,
|
|
|
- XFS_TRANS_DQ_BCOUNT,
|
|
|
- ip->i_d.di_nblocks);
|
|
|
- xfs_trans_mod_dquot(tp, newdq,
|
|
|
- XFS_TRANS_DQ_ICOUNT,
|
|
|
- 1);
|
|
|
+ xfs_trans_mod_dquot(tp, newdq, bfield, ip->i_d.di_nblocks);
|
|
|
+ xfs_trans_mod_dquot(tp, newdq, XFS_TRANS_DQ_ICOUNT, 1);
|
|
|
|
|
|
/*
|
|
|
* Take an extra reference, because the inode
|
|
@@ -2611,7 +2663,7 @@ xfs_qm_vop_chown(
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * Quota reservations for setattr(AT_UID|AT_GID).
|
|
|
+ * Quota reservations for setattr(AT_UID|AT_GID|AT_PROJID).
|
|
|
*/
|
|
|
int
|
|
|
xfs_qm_vop_chown_reserve(
|
|
@@ -2623,7 +2675,7 @@ xfs_qm_vop_chown_reserve(
|
|
|
{
|
|
|
int error;
|
|
|
xfs_mount_t *mp;
|
|
|
- uint delblks;
|
|
|
+ uint delblks, blkflags;
|
|
|
xfs_dquot_t *unresudq, *unresgdq, *delblksudq, *delblksgdq;
|
|
|
|
|
|
ASSERT(XFS_ISLOCKED_INODE(ip));
|
|
@@ -2632,6 +2684,8 @@ xfs_qm_vop_chown_reserve(
|
|
|
|
|
|
delblks = ip->i_delayed_blks;
|
|
|
delblksudq = delblksgdq = unresudq = unresgdq = NULL;
|
|
|
+ blkflags = XFS_IS_REALTIME_INODE(ip) ?
|
|
|
+ XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
|
|
|
|
|
|
if (XFS_IS_UQUOTA_ON(mp) && udqp &&
|
|
|
ip->i_d.di_uid != (uid_t)INT_GET(udqp->q_core.d_id, ARCH_CONVERT)) {
|
|
@@ -2646,18 +2700,22 @@ xfs_qm_vop_chown_reserve(
|
|
|
unresudq = ip->i_udquot;
|
|
|
}
|
|
|
}
|
|
|
- if (XFS_IS_GQUOTA_ON(ip->i_mount) && gdqp &&
|
|
|
- ip->i_d.di_gid != INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)) {
|
|
|
- delblksgdq = gdqp;
|
|
|
- if (delblks) {
|
|
|
- ASSERT(ip->i_gdquot);
|
|
|
- unresgdq = ip->i_gdquot;
|
|
|
+ if (XFS_IS_OQUOTA_ON(ip->i_mount) && gdqp) {
|
|
|
+ if ((XFS_IS_GQUOTA_ON(ip->i_mount) && ip->i_d.di_gid !=
|
|
|
+ INT_GET(gdqp->q_core.d_id, ARCH_CONVERT)) ||
|
|
|
+ (XFS_IS_PQUOTA_ON(ip->i_mount) && ip->i_d.di_projid !=
|
|
|
+ INT_GET(gdqp->q_core.d_id, ARCH_CONVERT))) {
|
|
|
+ delblksgdq = gdqp;
|
|
|
+ if (delblks) {
|
|
|
+ ASSERT(ip->i_gdquot);
|
|
|
+ unresgdq = ip->i_gdquot;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ((error = xfs_trans_reserve_quota_bydquots(tp, ip->i_mount,
|
|
|
delblksudq, delblksgdq, ip->i_d.di_nblocks, 1,
|
|
|
- flags | XFS_QMOPT_RES_REGBLKS)))
|
|
|
+ flags | blkflags)))
|
|
|
return (error);
|
|
|
|
|
|
/*
|
|
@@ -2674,11 +2732,11 @@ xfs_qm_vop_chown_reserve(
|
|
|
ASSERT(unresudq || unresgdq);
|
|
|
if ((error = xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
|
|
|
delblksudq, delblksgdq, (xfs_qcnt_t)delblks, 0,
|
|
|
- flags | XFS_QMOPT_RES_REGBLKS)))
|
|
|
+ flags | blkflags)))
|
|
|
return (error);
|
|
|
xfs_trans_reserve_quota_bydquots(NULL, ip->i_mount,
|
|
|
unresudq, unresgdq, -((xfs_qcnt_t)delblks), 0,
|
|
|
- XFS_QMOPT_RES_REGBLKS);
|
|
|
+ blkflags);
|
|
|
}
|
|
|
|
|
|
return (0);
|
|
@@ -2751,7 +2809,7 @@ xfs_qm_vop_dqattach_and_dqmod_newinode(
|
|
|
}
|
|
|
|
|
|
/* ------------- list stuff -----------------*/
|
|
|
-void
|
|
|
+STATIC void
|
|
|
xfs_qm_freelist_init(xfs_frlist_t *ql)
|
|
|
{
|
|
|
ql->qh_next = ql->qh_prev = (xfs_dquot_t *) ql;
|
|
@@ -2760,7 +2818,7 @@ xfs_qm_freelist_init(xfs_frlist_t *ql)
|
|
|
ql->qh_nelems = 0;
|
|
|
}
|
|
|
|
|
|
-void
|
|
|
+STATIC void
|
|
|
xfs_qm_freelist_destroy(xfs_frlist_t *ql)
|
|
|
{
|
|
|
xfs_dquot_t *dqp, *nextdqp;
|
|
@@ -2786,7 +2844,7 @@ xfs_qm_freelist_destroy(xfs_frlist_t *ql)
|
|
|
ASSERT(ql->qh_nelems == 0);
|
|
|
}
|
|
|
|
|
|
-void
|
|
|
+STATIC void
|
|
|
xfs_qm_freelist_insert(xfs_frlist_t *ql, xfs_dquot_t *dq)
|
|
|
{
|
|
|
dq->dq_flnext = ql->qh_next;
|
|
@@ -2816,7 +2874,7 @@ xfs_qm_freelist_append(xfs_frlist_t *ql, xfs_dquot_t *dq)
|
|
|
xfs_qm_freelist_insert((xfs_frlist_t *)ql->qh_prev, dq);
|
|
|
}
|
|
|
|
|
|
-int
|
|
|
+STATIC int
|
|
|
xfs_qm_dqhashlock_nowait(
|
|
|
xfs_dquot_t *dqp)
|
|
|
{
|
|
@@ -2836,7 +2894,7 @@ xfs_qm_freelist_lock_nowait(
|
|
|
return (locked);
|
|
|
}
|
|
|
|
|
|
-int
|
|
|
+STATIC int
|
|
|
xfs_qm_mplist_nowait(
|
|
|
xfs_mount_t *mp)
|
|
|
{
|