xfs: stop using q_core warning counters in the quota code
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 14 Jul 2020 17:37:31 +0000 (10:37 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 29 Jul 2020 03:24:14 +0000 (20:24 -0700)
Add warning counter fields to the incore dquot, and use that instead of
the ones in qcore.  This eliminates a bunch of endian conversions and
will eventually allow us to remove qcore entirely.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
fs/xfs/xfs_dquot.c
fs/xfs/xfs_dquot.h
fs/xfs/xfs_qm.c
fs/xfs/xfs_qm_syscalls.c
fs/xfs/xfs_trans_dquot.c

index dc3bfce7f28b3c182f485821f44c141aebbec9f6..9ba21523a481720869400a78d91951cbcf23483c 100644 (file)
@@ -140,7 +140,7 @@ xfs_qm_adjust_dqtimers(
                        d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
                                        defq->btimelimit);
                } else {
-                       d->d_bwarns = 0;
+                       dq->q_blk.warnings = 0;
                }
        } else {
                if ((!dq->q_blk.softlimit ||
@@ -159,7 +159,7 @@ xfs_qm_adjust_dqtimers(
                        d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
                                        defq->itimelimit);
                } else {
-                       d->d_iwarns = 0;
+                       dq->q_ino.warnings = 0;
                }
        } else {
                if ((!dq->q_ino.softlimit ||
@@ -178,7 +178,7 @@ xfs_qm_adjust_dqtimers(
                        d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
                                        defq->rtbtimelimit);
                } else {
-                       d->d_rtbwarns = 0;
+                       dq->q_rtb.warnings = 0;
                }
        } else {
                if ((!dq->q_rtb.softlimit ||
@@ -542,6 +542,10 @@ xfs_dquot_from_disk(
        dqp->q_ino.count = be64_to_cpu(ddqp->d_icount);
        dqp->q_rtb.count = be64_to_cpu(ddqp->d_rtbcount);
 
+       dqp->q_blk.warnings = be16_to_cpu(ddqp->d_bwarns);
+       dqp->q_ino.warnings = be16_to_cpu(ddqp->d_iwarns);
+       dqp->q_rtb.warnings = be16_to_cpu(ddqp->d_rtbwarns);
+
        /*
         * Reservation counters are defined as reservation plus current usage
         * to avoid having to add every time.
@@ -572,6 +576,10 @@ xfs_dquot_to_disk(
        ddqp->d_bcount = cpu_to_be64(dqp->q_blk.count);
        ddqp->d_icount = cpu_to_be64(dqp->q_ino.count);
        ddqp->d_rtbcount = cpu_to_be64(dqp->q_rtb.count);
+
+       ddqp->d_bwarns = cpu_to_be16(dqp->q_blk.warnings);
+       ddqp->d_iwarns = cpu_to_be16(dqp->q_ino.warnings);
+       ddqp->d_rtbwarns = cpu_to_be16(dqp->q_rtb.warnings);
 }
 
 /* Allocate and initialize the dquot buffer for this in-core dquot. */
index f5f0a15c0f7bf86f5dcb2eb32bd01fdf4fd723d9..afac622c0fde8ba3bd9246670078919827df9c7c 100644 (file)
@@ -37,6 +37,14 @@ struct xfs_dquot_res {
        /* Absolute and preferred limits. */
        xfs_qcnt_t              hardlimit;
        xfs_qcnt_t              softlimit;
+
+       /*
+        * For root dquots, this is the maximum number of warnings that will
+        * be issued for this quota type.  Otherwise, this is the number of
+        * warnings issued against this quota.  Note that none of this is
+        * implemented.
+        */
+       xfs_qwarncnt_t          warnings;
 };
 
 /*
index d6df2a4ca4cac610695a44125f36adef44828a6d..4dc989551710eeaf330ced0f28e6bbeb1542ad76 100644 (file)
@@ -616,12 +616,12 @@ xfs_qm_init_timelimits(
                defq->itimelimit = be32_to_cpu(ddqp->d_itimer);
        if (ddqp->d_rtbtimer)
                defq->rtbtimelimit = be32_to_cpu(ddqp->d_rtbtimer);
-       if (ddqp->d_bwarns)
-               defq->bwarnlimit = be16_to_cpu(ddqp->d_bwarns);
-       if (ddqp->d_iwarns)
-               defq->iwarnlimit = be16_to_cpu(ddqp->d_iwarns);
-       if (ddqp->d_rtbwarns)
-               defq->rtbwarnlimit = be16_to_cpu(ddqp->d_rtbwarns);
+       if (dqp->q_blk.warnings)
+               defq->bwarnlimit = dqp->q_blk.warnings;
+       if (dqp->q_ino.warnings)
+               defq->iwarnlimit = dqp->q_ino.warnings;
+       if (dqp->q_rtb.warnings)
+               defq->rtbwarnlimit = dqp->q_rtb.warnings;
 
        xfs_qm_dqdestroy(dqp);
 }
index 7aab60ea67e2a5bc24a40b7a63ac90fcec41dd62..acea375c0d178445da2c6e208f161e259c93ea64 100644 (file)
@@ -548,11 +548,11 @@ xfs_qm_scall_setqlim(
         * Update warnings counter(s) if requested
         */
        if (newlim->d_fieldmask & QC_SPC_WARNS)
-               ddq->d_bwarns = cpu_to_be16(newlim->d_spc_warns);
+               dqp->q_blk.warnings = newlim->d_spc_warns;
        if (newlim->d_fieldmask & QC_INO_WARNS)
-               ddq->d_iwarns = cpu_to_be16(newlim->d_ino_warns);
+               dqp->q_ino.warnings = newlim->d_ino_warns;
        if (newlim->d_fieldmask & QC_RT_SPC_WARNS)
-               ddq->d_rtbwarns = cpu_to_be16(newlim->d_rt_spc_warns);
+               dqp->q_rtb.warnings = newlim->d_rt_spc_warns;
 
        if (id == 0) {
                if (newlim->d_fieldmask & QC_SPC_WARNS)
@@ -627,13 +627,13 @@ xfs_qm_scall_getquota_fill_qc(
        dst->d_ino_count = dqp->q_ino.reserved;
        dst->d_spc_timer = be32_to_cpu(dqp->q_core.d_btimer);
        dst->d_ino_timer = be32_to_cpu(dqp->q_core.d_itimer);
-       dst->d_ino_warns = be16_to_cpu(dqp->q_core.d_iwarns);
-       dst->d_spc_warns = be16_to_cpu(dqp->q_core.d_bwarns);
+       dst->d_ino_warns = dqp->q_ino.warnings;
+       dst->d_spc_warns = dqp->q_blk.warnings;
        dst->d_rt_spc_hardlimit = XFS_FSB_TO_B(mp, dqp->q_rtb.hardlimit);
        dst->d_rt_spc_softlimit = XFS_FSB_TO_B(mp, dqp->q_rtb.softlimit);
        dst->d_rt_space = XFS_FSB_TO_B(mp, dqp->q_rtb.reserved);
        dst->d_rt_spc_timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
-       dst->d_rt_spc_warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
+       dst->d_rt_spc_warns = dqp->q_rtb.warnings;
 
        /*
         * Internally, we don't reset all the timers when quota enforcement
index 1c2a45989aafeee0c29127c815f02004faaa8f61..58cbc8f216f19a1edece323daad3fc7614630d04 100644 (file)
@@ -592,7 +592,7 @@ xfs_trans_dqresv(
                if (!softlimit)
                        softlimit = defq->bsoftlimit;
                timer = be32_to_cpu(dqp->q_core.d_btimer);
-               warns = be16_to_cpu(dqp->q_core.d_bwarns);
+               warns = dqp->q_blk.warnings;
                warnlimit = defq->bwarnlimit;
                resbcountp = &dqp->q_blk.reserved;
        } else {
@@ -604,7 +604,7 @@ xfs_trans_dqresv(
                if (!softlimit)
                        softlimit = defq->rtbsoftlimit;
                timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
-               warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
+               warns = dqp->q_rtb.warnings;
                warnlimit = defq->rtbwarnlimit;
                resbcountp = &dqp->q_rtb.reserved;
        }
@@ -639,7 +639,7 @@ xfs_trans_dqresv(
                if (ninos > 0) {
                        total_count = dqp->q_ino.reserved + ninos;
                        timer = be32_to_cpu(dqp->q_core.d_itimer);
-                       warns = be16_to_cpu(dqp->q_core.d_iwarns);
+                       warns = dqp->q_ino.warnings;
                        warnlimit = defq->iwarnlimit;
                        hardlimit = dqp->q_ino.hardlimit;
                        if (!hardlimit)