cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH v2 16/20] gfs2: No revokes for transactions at the tail of the log
Date: Sat, 19 Dec 2020 21:48:44 +0100	[thread overview]
Message-ID: <20201219204848.285781-17-agruenba@redhat.com> (raw)
In-Reply-To: <20201219204848.285781-1-agruenba@redhat.com>

In gfs2_log_flush, we're going through all active transactions.  For
each of the buffers in those transactions that has completed, we either
add a revoke to the active transaction immediately, or we move the
buffer to the transaction's ail2 list, which may result in a revoke
later.

However, whenever a transaction at the tail of the log completes, the
current tail of the log advances.  gfs2_log_flush writes out the log
header for the system transaction, with lh_tail set to that current tail
(sd_log_flush_head).  This implicitly revokes all previous blocks in the
log, so the revokes we've just written immediately become obsolete.
(This is not the case for transactions that haven't completed or aren't
at the tail of the log.)

Fix this by skipping completed transactions at the tail of the log
instead of writing revokes for them.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/gfs2/log.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index b771575bce11..14c5edf2bf51 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -287,15 +287,31 @@ static void gfs2_ail_empty_tr(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
  * @tr: the transaction
  * @max_revokes: If nonzero, issue revokes for the bd items for written buffers
  *
- * returns: the transaction's count of remaining active items
+ * Returns: true if the transaction has completed
  */
 
-static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
+static bool gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
 				int *max_revokes)
 {
 	struct gfs2_bufdata *bd, *s;
 	struct buffer_head *bh;
-	int active_count = 0;
+	bool empty = true;
+
+	if (!sdp->sd_log_error) {
+		list_for_each_entry_reverse(bd, &tr->tr_ail1_list, bd_ail_st_list) {
+			bh = bd->bd_bh;
+
+			if (buffer_busy(bh)) {
+				empty = false;
+				break;
+			}
+		}
+		if (empty) {
+			gfs2_ail_empty_tr(sdp, tr, &tr->tr_ail1_list);
+			gfs2_ail_empty_tr(sdp, tr, &tr->tr_ail2_list);
+			return empty;
+		}
+	}
 
 	list_for_each_entry_safe_reverse(bd, s, &tr->tr_ail1_list,
 					 bd_ail_st_list) {
@@ -311,7 +327,7 @@ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
 		 * for others.
 		 */
 		if (!sdp->sd_log_error && buffer_busy(bh)) {
-			active_count++;
+			empty = false;
 			continue;
 		}
 		if (!buffer_uptodate(bh) &&
@@ -332,7 +348,7 @@ static int gfs2_ail1_empty_one(struct gfs2_sbd *sdp, struct gfs2_trans *tr,
 		}
 		list_move(&bd->bd_ail_st_list, &tr->tr_ail2_list);
 	}
-	return active_count;
+	return empty;
 }
 
 /**
@@ -351,7 +367,7 @@ static int gfs2_ail1_empty(struct gfs2_sbd *sdp, int max_revokes)
 
 	spin_lock(&sdp->sd_ail_lock);
 	list_for_each_entry_safe_reverse(tr, s, &sdp->sd_ail1_list, tr_list) {
-		if (!gfs2_ail1_empty_one(sdp, tr, &max_revokes) && oldest_tr)
+		if (gfs2_ail1_empty_one(sdp, tr, &max_revokes) && oldest_tr)
 			list_move(&tr->tr_list, &sdp->sd_ail2_list);
 		else
 			oldest_tr = 0;
-- 
2.26.2



  parent reply	other threads:[~2020-12-19 20:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-19 20:48 [Cluster-devel] [PATCH v2 00/20] Some log space management cleanups Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 01/20] gfs2: Deobfuscate function jdesc_find_i Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 02/20] gfs2: Simplify the buf_limit and databuf_limit definitions Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 03/20] gfs2: Minor gfs2_write_revokes cleanups Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 04/20] gfs2: Some documentation updates Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 05/20] gfs2: A minor debugging improvement Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 06/20] gfs2: Rename gfs2_{write => add_aux}_revokes Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 07/20] gfs2: Clean up ail2_empty Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 08/20] gfs2: Get rid of on-stack transactions Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 09/20] gfs2: Get rid of sd_reserving_log Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 10/20] gfs2: Move lock flush locking to gfs2_trans_{begin, end} Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 11/20] gfs2: Don't wait for journal flush in clean_journal Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 12/20] gfs2: Clean up gfs2_log_reserve Andreas Gruenbacher
2020-12-22 14:19   ` Bob Peterson
2020-12-22 15:12     ` Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 13/20] gfs2: Use a tighter bound in gfs2_trans_begin Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 14/20] gfs2: Get rid of current_tail() Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 15/20] gfs2: Move function gfs2_ail_empty_tr Andreas Gruenbacher
2020-12-19 20:48 ` Andreas Gruenbacher [this message]
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 17/20] gfs2: Remove sd_log_committed_revoke Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 18/20] gfs2: Remove sd_log_blks_reserved Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 19/20] gfs2: Rework the log space allocation logic Andreas Gruenbacher
2020-12-19 20:48 ` [Cluster-devel] [PATCH v2 20/20] gfs2: Hand out revokes to transactions one by one 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=20201219204848.285781-17-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    /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).