From: Andreas Gruenbacher Date: Wed, 3 Feb 2021 19:07:52 +0100 Subject: [Cluster-devel] [PATCH v4 17/20] gfs2: No revokes for transactions at the tail of the log In-Reply-To: <20210203180755.246596-1-agruenba@redhat.com> References: <20210203180755.246596-1-agruenba@redhat.com> Message-ID: <20210203180755.246596-18-agruenba@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 become obsolete. So instead of writing unnecessary revokes, just skip completed transactions at the tail of the log. Signed-off-by: Andreas Gruenbacher --- fs/gfs2/log.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c index 6fd4ded1e357..b80c96cf721a 100644 --- a/fs/gfs2/log.c +++ b/fs/gfs2/log.c @@ -287,16 +287,34 @@ 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; + if (!sdp->sd_log_error) { + empty = true; + list_for_each_entry_reverse(bd, &tr->tr_ail1_list, bd_ail_st_list) { + bh = bd->bd_bh; + + if (buffer_busy(bh) || !list_empty(&bd->bd_list)) { + 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; + } + } + + empty = true; list_for_each_entry_safe_reverse(bd, s, &tr->tr_ail1_list, bd_ail_st_list) { bh = bd->bd_bh; @@ -311,7 +329,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 +350,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 +369,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