All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 3/4] xfs: set the buffer type after holding the AG[IF] across trans_roll
Date: Sun, 02 Oct 2022 11:19:48 -0700	[thread overview]
Message-ID: <166473478893.1083155.2555785331844801316.stgit@magnolia> (raw)
In-Reply-To: <166473478844.1083155.9238102682926048449.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

Currently, the only way to lock an allocation group is to hold the AGI
and AGF buffers.  If repair needs to roll the transaction while
repairing some AG metadata, it maintains that lock by holding the two
buffers across the transaction roll and joins them afterwards.

However, repair is not the same as the other parts of XFS that employ
this bhold/bjoin sequence, because it's possible that the AGI or AGF
buffers are not actually dirty before the roll.  In this case, the
buffer log item can detach from the buffer, which means that we have to
re-set the buffer type in the bli after joining the buffer to the new
transaction so that log recovery will know what to do if the fs fails.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/scrub/repair.c |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)


diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 2ada7fc1c398..92c661b98892 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -138,11 +138,23 @@ xrep_roll_ag_trans(
 	if (error)
 		return error;
 
-	/* Join AG headers to the new transaction. */
-	if (sc->sa.agi_bp)
+	/*
+	 * Join AG headers to the new transaction.  The buffer log item can
+	 * detach from the buffer across the transaction roll if the bli is
+	 * clean, so ensure the buffer type is still set on the AG header
+	 * buffers' blis before we return.
+	 *
+	 * Normal code would never hold a clean buffer across a roll, but scrub
+	 * needs both buffers to maintain a total lock on the AG.
+	 */
+	if (sc->sa.agi_bp) {
 		xfs_trans_bjoin(sc->tp, sc->sa.agi_bp);
-	if (sc->sa.agf_bp)
+		xfs_trans_buf_set_type(sc->tp, sc->sa.agi_bp, XFS_BLFT_AGI_BUF);
+	}
+	if (sc->sa.agf_bp) {
 		xfs_trans_bjoin(sc->tp, sc->sa.agf_bp);
+		xfs_trans_buf_set_type(sc->tp, sc->sa.agf_bp, XFS_BLFT_AGF_BUF);
+	}
 
 	return 0;
 }


  reply	other threads:[~2022-10-02 18:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 18:19 [PATCHSET v23.1 0/4] xfs: fix handling of AG[IF] header buffers during scrub Darrick J. Wong
2022-10-02 18:19 ` Darrick J. Wong [this message]
2022-10-13 22:25   ` [PATCH 3/4] xfs: set the buffer type after holding the AG[IF] across trans_roll Dave Chinner
2022-10-13 23:19     ` Darrick J. Wong
2022-10-14  1:28       ` Dave Chinner
2022-10-24  4:16         ` Darrick J. Wong
2022-10-31 18:08   ` [PATCH v23.2 3/4] xfs: log the AGI/AGF buffers when rolling transactions during an AG repair Darrick J. Wong
2022-10-31 21:17     ` Dave Chinner
2022-10-02 18:19 ` [PATCH 2/4] xfs: don't track the AGFL buffer in the scrub AG context Darrick J. Wong
2022-10-13 22:32   ` Dave Chinner
2022-10-02 18:19 ` [PATCH 1/4] xfs: fully initialize xfs_da_args in xchk_directory_blocks Darrick J. Wong
2022-10-13 22:33   ` Dave Chinner
2022-10-02 18:19 ` [PATCH 4/4] xfs: make AGFL repair function avoid crosslinked blocks Darrick J. Wong
2022-10-13 22:35   ` Dave Chinner

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=166473478893.1083155.2555785331844801316.stgit@magnolia \
    --to=djwong@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.