gfs2.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: gfs2@lists.linux.dev
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH 08/13] gfs2: quota need_sync cleanup
Date: Tue, 18 Jun 2024 18:05:12 +0200	[thread overview]
Message-ID: <20240618160517.901589-9-agruenba@redhat.com> (raw)
In-Reply-To: <20240618160517.901589-1-agruenba@redhat.com>

Rename variable 'value' to 'change' as it stores a change in value.

Add new 'value' and 'limit' variables for the current value and limit.

Only fetch the tuning parameters when we need them.

Get rid of unnecessary nesting.

No change in functionality.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/quota.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 29a69756cc32..11bd16d8f81c 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -1117,34 +1117,32 @@ static bool need_sync(struct gfs2_quota_data *qd)
 {
 	struct gfs2_sbd *sdp = qd->qd_sbd;
 	struct gfs2_tune *gt = &sdp->sd_tune;
-	s64 value;
+	s64 value, change, limit;
 	unsigned int num, den;
 
 	if (!qd->qd_qb.qb_limit)
 		return false;
 
 	spin_lock(&qd_lock);
-	value = qd->qd_change;
+	change = qd->qd_change;
 	spin_unlock(&qd_lock);
 
+	if (change <= 0)
+		return false;
+	value = (s64)be64_to_cpu(qd->qd_qb.qb_value);
+	limit = (s64)be64_to_cpu(qd->qd_qb.qb_limit);
+	if (value >= limit)
+		return false;
+
 	spin_lock(&gt->gt_spin);
 	num = gt->gt_quota_scale_num;
 	den = gt->gt_quota_scale_den;
 	spin_unlock(&gt->gt_spin);
 
-	if (value <= 0)
-		return false;
-	else if ((s64)be64_to_cpu(qd->qd_qb.qb_value) >=
-		 (s64)be64_to_cpu(qd->qd_qb.qb_limit))
+	change *= gfs2_jindex_size(sdp) * num;
+	change = div_s64(change, den);
+	if (value + change < limit)
 		return false;
-	else {
-		value *= gfs2_jindex_size(sdp) * num;
-		value = div_s64(value, den);
-		value += (s64)be64_to_cpu(qd->qd_qb.qb_value);
-		if (value < (s64)be64_to_cpu(qd->qd_qb.qb_limit))
-			return false;
-	}
-
 	return true;
 }
 
-- 
2.45.1


  parent reply	other threads:[~2024-06-18 16:05 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-18 16:05 [PATCH 00/13] gfs2: quota changes Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 01/13] gfs2: Minor gfs2_quota_init error path cleanup Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 02/13] gfs2: Check quota consistency on mount Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 03/13] gfs2: Revert "introduce qd_bh_get_or_undo" Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 04/13] gfs2: qd_check_sync cleanups Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 05/13] gfs2: Revert "ignore negated quota changes" Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 06/13] gfs2: Revert "Add quota_change type" Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 07/13] gfs2: Fix and clean up function do_qc Andreas Gruenbacher
2024-06-18 16:05 ` Andreas Gruenbacher [this message]
2024-06-18 16:05 ` [PATCH 09/13] gfs2: Fold qd_fish into gfs2_quota_sync Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 10/13] gfs2: Add some missing quota locking Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 11/13] gfs2: Get rid of some unnecessary " Andreas Gruenbacher
2024-06-20 14:22   ` Alexander Aring
2024-06-20 14:45     ` Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 12/13] gfs2: Be more careful with the quota sync generation Andreas Gruenbacher
2024-06-18 16:05 ` [PATCH 13/13] gfs2: Revert "check for no eligible quota changes" Andreas Gruenbacher

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=20240618160517.901589-9-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    --cc=gfs2@lists.linux.dev \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).