linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 10/18] xfs: stop using q_core timers in the quota code
Date: Tue, 30 Jun 2020 08:42:54 -0700	[thread overview]
Message-ID: <159353177481.2864738.2222411495060044495.stgit@magnolia> (raw)
In-Reply-To: <159353170983.2864738.16885438169173786208.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Add timers 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>
---
 fs/xfs/xfs_dquot.c       |   41 +++++++++++++++++++++++------------------
 fs/xfs/xfs_dquot.h       |    7 +++++++
 fs/xfs/xfs_qm.c          |   15 ++++++---------
 fs/xfs/xfs_qm_syscalls.c |   18 ++++++++----------
 fs/xfs/xfs_trans_dquot.c |    6 +++---
 5 files changed, 47 insertions(+), 40 deletions(-)


diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index a1edb49ceda5..7434ee57ec43 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -116,7 +116,6 @@ xfs_qm_adjust_dqtimers(
 	struct xfs_dquot	*dq)
 {
 	struct xfs_quotainfo	*qi = mp->m_quotainfo;
-	struct xfs_disk_dquot	*d = &dq->q_core;
 	struct xfs_def_quota	*defq;
 
 	ASSERT(dq->q_id);
@@ -131,13 +130,13 @@ xfs_qm_adjust_dqtimers(
 		ASSERT(dq->q_rtb.softlimit <= dq->q_rtb.hardlimit);
 #endif
 
-	if (!d->d_btimer) {
+	if (!dq->q_blk.timer) {
 		if ((dq->q_blk.softlimit &&
 		     (dq->q_blk.count > dq->q_blk.softlimit)) ||
 		    (dq->q_blk.hardlimit &&
 		     (dq->q_blk.count > dq->q_blk.hardlimit))) {
-			d->d_btimer = cpu_to_be32(ktime_get_real_seconds() +
-					defq->btimelimit);
+			dq->q_blk.timer = ktime_get_real_seconds() +
+					defq->btimelimit;
 		} else {
 			dq->q_blk.warnings = 0;
 		}
@@ -146,17 +145,17 @@ xfs_qm_adjust_dqtimers(
 		     (dq->q_blk.count <= dq->q_blk.softlimit)) &&
 		    (!dq->q_blk.hardlimit ||
 		    (dq->q_blk.count <= dq->q_blk.hardlimit))) {
-			d->d_btimer = 0;
+			dq->q_blk.timer = 0;
 		}
 	}
 
-	if (!d->d_itimer) {
+	if (!dq->q_ino.timer) {
 		if ((dq->q_ino.softlimit &&
 		     (dq->q_ino.count > dq->q_ino.softlimit)) ||
 		    (dq->q_ino.hardlimit &&
 		     (dq->q_ino.count > dq->q_ino.hardlimit))) {
-			d->d_itimer = cpu_to_be32(ktime_get_real_seconds() +
-					defq->itimelimit);
+			dq->q_ino.timer = ktime_get_real_seconds() +
+					defq->itimelimit;
 		} else {
 			dq->q_ino.warnings = 0;
 		}
@@ -165,17 +164,17 @@ xfs_qm_adjust_dqtimers(
 		     (dq->q_ino.count <= dq->q_ino.softlimit))  &&
 		    (!dq->q_ino.hardlimit ||
 		     (dq->q_ino.count <= dq->q_ino.hardlimit))) {
-			d->d_itimer = 0;
+			dq->q_ino.timer = 0;
 		}
 	}
 
-	if (!d->d_rtbtimer) {
+	if (!dq->q_rtb.timer) {
 		if ((dq->q_rtb.softlimit &&
 		     (dq->q_rtb.count > dq->q_rtb.softlimit)) ||
 		    (dq->q_rtb.hardlimit &&
 		     (dq->q_rtb.count > dq->q_rtb.hardlimit))) {
-			d->d_rtbtimer = cpu_to_be32(ktime_get_real_seconds() +
-					defq->rtbtimelimit);
+			dq->q_rtb.timer = ktime_get_real_seconds() +
+					defq->rtbtimelimit;
 		} else {
 			dq->q_rtb.warnings = 0;
 		}
@@ -184,7 +183,7 @@ xfs_qm_adjust_dqtimers(
 		     (dq->q_rtb.count <= dq->q_rtb.softlimit)) &&
 		    (!dq->q_rtb.hardlimit ||
 		     (dq->q_rtb.count <= dq->q_rtb.hardlimit))) {
-			d->d_rtbtimer = 0;
+			dq->q_rtb.timer = 0;
 		}
 	}
 }
@@ -546,6 +545,10 @@ xfs_dquot_from_disk(
 	dqp->q_ino.warnings = be16_to_cpu(ddqp->d_iwarns);
 	dqp->q_rtb.warnings = be16_to_cpu(ddqp->d_rtbwarns);
 
+	dqp->q_blk.timer = be32_to_cpu(ddqp->d_btimer);
+	dqp->q_ino.timer = be32_to_cpu(ddqp->d_itimer);
+	dqp->q_rtb.timer = be32_to_cpu(ddqp->d_rtbtimer);
+
 	/*
 	 * Reservation counters are defined as reservation plus current usage
 	 * to avoid having to add every time.
@@ -581,6 +584,10 @@ xfs_dquot_to_disk(
 	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);
+
+	ddqp->d_btimer = cpu_to_be32(dqp->q_blk.timer);
+	ddqp->d_itimer = cpu_to_be32(dqp->q_ino.timer);
+	ddqp->d_rtbtimer = cpu_to_be32(dqp->q_rtb.timer);
 }
 
 /* Allocate and initialize the dquot buffer for this in-core dquot. */
@@ -1135,8 +1142,6 @@ static xfs_failaddr_t
 xfs_qm_dqflush_check(
 	struct xfs_dquot	*dqp)
 {
-	struct xfs_disk_dquot	*ddq = &dqp->q_core;
-
 	if (hweight8(dqp->dq_flags & XFS_DQ_ALLTYPES) != 1)
 		return __this_address;
 
@@ -1144,15 +1149,15 @@ xfs_qm_dqflush_check(
 		return NULL;
 
 	if (dqp->q_blk.softlimit && dqp->q_blk.count > dqp->q_blk.softlimit &&
-	    !ddq->d_btimer)
+	    !dqp->q_blk.timer)
 		return __this_address;
 
 	if (dqp->q_ino.softlimit && dqp->q_ino.count > dqp->q_ino.softlimit &&
-	    !ddq->d_itimer)
+	    !dqp->q_ino.timer)
 		return __this_address;
 
 	if (dqp->q_rtb.softlimit && dqp->q_rtb.count > dqp->q_rtb.softlimit &&
-	    !ddq->d_rtbtimer)
+	    !dqp->q_rtb.timer)
 		return __this_address;
 
 	return NULL;
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h
index 5840bc54b772..414bae537b1d 100644
--- a/fs/xfs/xfs_dquot.h
+++ b/fs/xfs/xfs_dquot.h
@@ -38,6 +38,13 @@ struct xfs_dquot_res {
 	xfs_qcnt_t		hardlimit;
 	xfs_qcnt_t		softlimit;
 
+	/*
+	 * For root dquots, this is the default grace period, in seconds.
+	 * Otherwise, this is when the quota grace period expires,
+	 * in seconds since the Unix epoch.
+	 */
+	time64_t		timer;
+
 	/*
 	 * For root dquots, this is the maximum number of warnings that will
 	 * be issued for this quota type.  Otherwise, this is the number of
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 4e233cfef46d..a56c6e4a5d99 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -579,7 +579,6 @@ xfs_qm_init_timelimits(
 {
 	struct xfs_quotainfo	*qinf = mp->m_quotainfo;
 	struct xfs_def_quota	*defq;
-	struct xfs_disk_dquot	*ddqp;
 	struct xfs_dquot	*dqp;
 	int			error;
 
@@ -603,19 +602,17 @@ xfs_qm_init_timelimits(
 	if (error)
 		return;
 
-	ddqp = &dqp->q_core;
-
 	/*
 	 * The warnings and timers set the grace period given to
 	 * a user or group before he or she can not perform any
 	 * more writing. If it is zero, a default is used.
 	 */
-	if (ddqp->d_btimer)
-		defq->btimelimit = be32_to_cpu(ddqp->d_btimer);
-	if (ddqp->d_itimer)
-		defq->itimelimit = be32_to_cpu(ddqp->d_itimer);
-	if (ddqp->d_rtbtimer)
-		defq->rtbtimelimit = be32_to_cpu(ddqp->d_rtbtimer);
+	if (dqp->q_blk.timer)
+		defq->btimelimit = dqp->q_blk.timer;
+	if (dqp->q_ino.timer)
+		defq->itimelimit = dqp->q_ino.timer;
+	if (dqp->q_rtb.timer)
+		defq->rtbtimelimit = dqp->q_rtb.timer;
 	if (dqp->q_blk.warnings)
 		defq->bwarnlimit = dqp->q_blk.warnings;
 	if (dqp->q_ino.warnings)
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 5d3bccdbd3bf..1b2b70b1660f 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -447,7 +447,6 @@ xfs_qm_scall_setqlim(
 	struct qc_dqblk		*newlim)
 {
 	struct xfs_quotainfo	*q = mp->m_quotainfo;
-	struct xfs_disk_dquot	*ddq;
 	struct xfs_dquot	*dqp;
 	struct xfs_trans	*tp;
 	struct xfs_def_quota	*defq;
@@ -488,7 +487,6 @@ xfs_qm_scall_setqlim(
 
 	xfs_dqlock(dqp);
 	xfs_trans_dqjoin(tp, dqp);
-	ddq = &dqp->q_core;
 
 	/*
 	 * Make sure that hardlimits are >= soft limits before changing.
@@ -573,11 +571,11 @@ xfs_qm_scall_setqlim(
 	 * the soft limit.
 	 */
 	if (newlim->d_fieldmask & QC_SPC_TIMER)
-		ddq->d_btimer = cpu_to_be32(newlim->d_spc_timer);
+		dqp->q_blk.timer = newlim->d_spc_timer;
 	if (newlim->d_fieldmask & QC_INO_TIMER)
-		ddq->d_itimer = cpu_to_be32(newlim->d_ino_timer);
+		dqp->q_ino.timer = newlim->d_ino_timer;
 	if (newlim->d_fieldmask & QC_RT_SPC_TIMER)
-		ddq->d_rtbtimer = cpu_to_be32(newlim->d_rt_spc_timer);
+		dqp->q_rtb.timer = newlim->d_rt_spc_timer;
 
 	if (id == 0) {
 		if (newlim->d_fieldmask & QC_SPC_TIMER)
@@ -621,18 +619,18 @@ xfs_qm_scall_getquota_fill_qc(
 	memset(dst, 0, sizeof(*dst));
 	dst->d_spc_hardlimit = XFS_FSB_TO_B(mp, dqp->q_blk.hardlimit);
 	dst->d_spc_softlimit = XFS_FSB_TO_B(mp, dqp->q_blk.softlimit);
-	dst->d_ino_hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit);
-	dst->d_ino_softlimit = be64_to_cpu(dqp->q_core.d_ino_softlimit);
+	dst->d_ino_hardlimit = dqp->q_ino.hardlimit;
+	dst->d_ino_softlimit = dqp->q_ino.softlimit;
 	dst->d_space = XFS_FSB_TO_B(mp, dqp->q_blk.reserved);
 	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_spc_timer = dqp->q_blk.timer;
+	dst->d_ino_timer = dqp->q_ino.timer;
 	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_timer = dqp->q_rtb.timer;
 	dst->d_rt_spc_warns = dqp->q_rtb.warnings;
 
 	/*
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c
index 21ed8eda3c80..28b59a4069a3 100644
--- a/fs/xfs/xfs_trans_dquot.c
+++ b/fs/xfs/xfs_trans_dquot.c
@@ -591,7 +591,7 @@ xfs_trans_dqresv(
 		softlimit = dqp->q_blk.softlimit;
 		if (!softlimit)
 			softlimit = defq->bsoftlimit;
-		timer = be32_to_cpu(dqp->q_core.d_btimer);
+		timer = dqp->q_blk.timer;
 		warns = dqp->q_blk.warnings;
 		warnlimit = defq->bwarnlimit;
 		resbcountp = &dqp->q_blk.reserved;
@@ -603,7 +603,7 @@ xfs_trans_dqresv(
 		softlimit = dqp->q_rtb.softlimit;
 		if (!softlimit)
 			softlimit = defq->rtbsoftlimit;
-		timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
+		timer = dqp->q_rtb.timer;
 		warns = dqp->q_rtb.warnings;
 		warnlimit = defq->rtbwarnlimit;
 		resbcountp = &dqp->q_rtb.reserved;
@@ -638,7 +638,7 @@ xfs_trans_dqresv(
 		}
 		if (ninos > 0) {
 			total_count = dqp->q_ino.reserved + ninos;
-			timer = be32_to_cpu(dqp->q_core.d_itimer);
+			timer = dqp->q_ino.timer;
 			warns = dqp->q_ino.warnings;
 			warnlimit = defq->iwarnlimit;
 			hardlimit = dqp->q_ino.hardlimit;


  parent reply	other threads:[~2020-06-30 15:43 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-30 15:41 [PATCH 00/18] xfs: remove xfs_disk_quot from incore dquot Darrick J. Wong
2020-06-30 15:41 ` [PATCH 01/18] xfs: clear XFS_DQ_FREEING if we can't lock the dquot buffer to flush Darrick J. Wong
2020-06-30 21:35   ` Allison Collins
2020-07-01  8:32   ` Chandan Babu R
2020-07-01  8:33   ` Christoph Hellwig
2020-07-01 22:42     ` Dave Chinner
2020-06-30 15:42 ` [PATCH 02/18] xfs: fix inode quota reservation checks Darrick J. Wong
2020-06-30 21:35   ` Allison Collins
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:34   ` Christoph Hellwig
2020-06-30 15:42 ` [PATCH 03/18] xfs: validate ondisk/incore dquot flags Darrick J. Wong
2020-06-30 21:35   ` Allison Collins
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:42   ` Christoph Hellwig
2020-07-01 18:25     ` Darrick J. Wong
2020-07-02  6:30       ` Christoph Hellwig
2020-07-02 15:13         ` Darrick J. Wong
2020-07-01 22:41   ` Dave Chinner
2020-07-01 23:16     ` Darrick J. Wong
2020-06-30 15:42 ` [PATCH 04/18] xfs: stop using q_core.d_flags in the quota code Darrick J. Wong
2020-07-01  8:34   ` Chandan Babu R
2020-07-01  8:47   ` Christoph Hellwig
2020-07-01 19:02     ` Darrick J. Wong
2020-07-01 20:15   ` Allison Collins
2020-07-01 22:50   ` Dave Chinner
2020-07-01 23:19     ` Darrick J. Wong
2020-07-01 23:44       ` Dave Chinner
2020-07-01 23:50         ` Darrick J. Wong
2020-07-03  0:58           ` Dave Chinner
2020-07-03 18:01             ` Darrick J. Wong
2020-06-30 15:42 ` [PATCH 05/18] xfs: stop using q_core.d_id " Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:48   ` Christoph Hellwig
2020-07-01 20:16   ` Allison Collins
2020-06-30 15:42 ` [PATCH 06/18] xfs: use a per-resource struct for incore dquot data Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:49   ` Christoph Hellwig
2020-07-01 20:16   ` Allison Collins
2020-06-30 15:42 ` [PATCH 07/18] xfs: stop using q_core limits in the quota code Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:50   ` Christoph Hellwig
2020-07-01 20:16   ` Allison Collins
2020-07-01 23:01   ` Dave Chinner
2020-07-01 23:13     ` Darrick J. Wong
2020-07-01 23:33       ` Darrick J. Wong
2020-07-01 23:45         ` Dave Chinner
2020-06-30 15:42 ` [PATCH 08/18] xfs: stop using q_core counters " Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:51   ` Christoph Hellwig
2020-07-01 23:20   ` Allison Collins
2020-06-30 15:42 ` [PATCH 09/18] xfs: stop using q_core warning " Darrick J. Wong
2020-07-01  8:33   ` Chandan Babu R
2020-07-01  8:51   ` Christoph Hellwig
2020-07-01 23:20   ` Allison Collins
2020-06-30 15:42 ` Darrick J. Wong [this message]
2020-07-01  8:34   ` [PATCH 10/18] xfs: stop using q_core timers " Chandan Babu R
2020-07-01  8:51   ` Christoph Hellwig
2020-07-01 23:20   ` Allison Collins
2020-06-30 15:43 ` [PATCH 11/18] xfs: remove qcore from incore dquots Darrick J. Wong
2020-07-01  8:34   ` Chandan Babu R
2020-07-01  8:52   ` Christoph Hellwig
2020-07-01 23:07   ` Dave Chinner
2020-07-01 23:14     ` Darrick J. Wong
2020-07-02  2:06   ` Allison Collins
2020-06-30 15:43 ` [PATCH 12/18] xfs: refactor default quota limits by resource Darrick J. Wong
2020-07-01  8:52   ` Chandan Babu R
2020-07-01  8:53   ` Christoph Hellwig
2020-07-01 23:30   ` Dave Chinner
2020-07-02  0:07     ` Darrick J. Wong
2020-07-02  2:06   ` Allison Collins
2020-06-30 15:43 ` [PATCH 13/18] xfs: remove unnecessary arguments from quota adjust functions Darrick J. Wong
2020-07-01  8:53   ` Christoph Hellwig
2020-07-01  8:58   ` Chandan Babu R
2020-07-02  2:06   ` Allison Collins
2020-06-30 15:43 ` [PATCH 14/18] xfs: refactor quota exceeded test Darrick J. Wong
2020-07-01  8:56   ` Christoph Hellwig
2020-07-01 17:51     ` Darrick J. Wong
2020-07-01 18:48       ` Eric Sandeen
2020-07-01 23:34       ` Dave Chinner
2020-07-01 10:19   ` Chandan Babu R
2020-07-02 18:57   ` Allison Collins
2020-06-30 15:43 ` [PATCH 15/18] xfs: refactor xfs_qm_scall_setqlim Darrick J. Wong
2020-07-01  8:56   ` Christoph Hellwig
2020-07-03  4:11   ` Allison Collins
2020-07-03 12:39   ` Chandan Babu R
2020-06-30 15:43 ` [PATCH 16/18] xfs: refactor xfs_trans_dqresv Darrick J. Wong
2020-07-03  4:11   ` Allison Collins
2020-07-03 13:00   ` Chandan Babu R
2020-06-30 15:43 ` [PATCH 17/18] xfs: refactor xfs_trans_apply_dquot_deltas Darrick J. Wong
2020-07-04 20:41   ` Allison Collins
2020-07-06 13:40   ` Chandan Babu R
2020-06-30 15:43 ` [PATCH 18/18] xfs: add more dquot tracepoints Darrick J. Wong
2020-07-04 20:41   ` Allison Collins
2020-07-06 13:42   ` Chandan Babu R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=159353177481.2864738.2222411495060044495.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).