From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 2/3] xfs: only invalidate blocks if we're going to free them
Date: Wed, 09 Oct 2019 09:48:47 -0700 [thread overview]
Message-ID: <157063972723.2913192.12835516373692425243.stgit@magnolia> (raw)
In-Reply-To: <157063971218.2913192.8762913814390092382.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
When we're discarding old btree blocks after a repair, only invalidate
the buffers for the ones that we're freeing -- if the metadata was
crosslinked with another data structure, we don't want to touch it.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/scrub/repair.c | 76 +++++++++++++++++++++++--------------------------
fs/xfs/scrub/repair.h | 1 -
2 files changed, 35 insertions(+), 42 deletions(-)
diff --git a/fs/xfs/scrub/repair.c b/fs/xfs/scrub/repair.c
index 3a58788e0bd8..e21faef6db5a 100644
--- a/fs/xfs/scrub/repair.c
+++ b/fs/xfs/scrub/repair.c
@@ -423,44 +423,6 @@ xrep_init_btblock(
* buffers associated with @bitmap.
*/
-/*
- * Invalidate buffers for per-AG btree blocks we're dumping. This function
- * is not intended for use with file data repairs; we have bunmapi for that.
- */
-int
-xrep_invalidate_blocks(
- struct xfs_scrub *sc,
- struct xfs_bitmap *bitmap)
-{
- struct xfs_bitmap_range *bmr;
- struct xfs_bitmap_range *n;
- struct xfs_buf *bp;
- xfs_fsblock_t fsbno;
-
- /*
- * For each block in each extent, see if there's an incore buffer for
- * exactly that block; if so, invalidate it. The buffer cache only
- * lets us look for one buffer at a time, so we have to look one block
- * at a time. Avoid invalidating AG headers and post-EOFS blocks
- * because we never own those; and if we can't TRYLOCK the buffer we
- * assume it's owned by someone else.
- */
- for_each_xfs_bitmap_block(fsbno, bmr, n, bitmap) {
- /* Skip AG headers and post-EOFS blocks */
- if (!xfs_verify_fsbno(sc->mp, fsbno))
- continue;
- bp = xfs_buf_incore(sc->mp->m_ddev_targp,
- XFS_FSB_TO_DADDR(sc->mp, fsbno),
- XFS_FSB_TO_BB(sc->mp, 1), XBF_TRYLOCK);
- if (bp) {
- xfs_trans_bjoin(sc->tp, bp);
- xfs_trans_binval(sc->tp, bp);
- }
- }
-
- return 0;
-}
-
/* Ensure the freelist is the correct size. */
int
xrep_fix_freelist(
@@ -515,6 +477,35 @@ xrep_put_freelist(
return 0;
}
+/* Try to invalidate the incore buffer for a block that we're about to free. */
+STATIC void
+xrep_reap_invalidate_block(
+ struct xfs_scrub *sc,
+ xfs_fsblock_t fsbno)
+{
+ struct xfs_buf *bp;
+
+ /*
+ * For each block in each extent, see if there's an incore buffer for
+ * exactly that block; if so, invalidate it. The buffer cache only
+ * lets us look for one buffer at a time, so we have to look one block
+ * at a time. Avoid invalidating AG headers and post-EOFS blocks
+ * because we never own those; and if we can't TRYLOCK the buffer we
+ * assume it's owned by someone else.
+ */
+ /* Skip AG headers and post-EOFS blocks */
+ if (!xfs_verify_fsbno(sc->mp, fsbno))
+ return;
+ bp = xfs_buf_incore(sc->mp->m_ddev_targp,
+ XFS_FSB_TO_DADDR(sc->mp, fsbno),
+ XFS_FSB_TO_BB(sc->mp, 1), XBF_TRYLOCK);
+ if (!bp)
+ return;
+
+ xfs_trans_bjoin(sc->tp, bp);
+ xfs_trans_binval(sc->tp, bp);
+}
+
/* Dispose of a single block. */
STATIC int
xrep_reap_block(
@@ -568,12 +559,15 @@ xrep_reap_block(
* blow on writeout, the filesystem will shut down, and the admin gets
* to run xfs_repair.
*/
- if (has_other_rmap)
+ if (has_other_rmap) {
error = xfs_rmap_free(sc->tp, agf_bp, agno, agbno, 1, oinfo);
- else if (resv == XFS_AG_RESV_AGFL)
+ } else if (resv == XFS_AG_RESV_AGFL) {
+ xrep_reap_invalidate_block(sc, fsbno);
error = xrep_put_freelist(sc, agbno);
- else
+ } else {
+ xrep_reap_invalidate_block(sc, fsbno);
error = xfs_free_extent(sc->tp, fsbno, 1, oinfo, resv);
+ }
if (agf_bp != sc->sa.agf_bp)
xfs_trans_brelse(sc->tp, agf_bp);
if (error)
diff --git a/fs/xfs/scrub/repair.h b/fs/xfs/scrub/repair.h
index 60c61d7052a8..eab41928990f 100644
--- a/fs/xfs/scrub/repair.h
+++ b/fs/xfs/scrub/repair.h
@@ -31,7 +31,6 @@ int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
struct xfs_bitmap;
int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
-int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xfs_bitmap *btlist);
int xrep_reap_extents(struct xfs_scrub *sc, struct xfs_bitmap *exlist,
const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
next prev parent reply other threads:[~2019-10-09 16:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-09 16:48 [PATCH 0/3] xfs: fix online repair block reaping Darrick J. Wong
2019-10-09 16:48 ` [PATCH 1/3] xfs: xrep_reap_extents should not destroy the bitmap Darrick J. Wong
2019-10-17 12:54 ` Brian Foster
2019-10-09 16:48 ` Darrick J. Wong [this message]
2019-10-17 12:55 ` [PATCH 2/3] xfs: only invalidate blocks if we're going to free them Brian Foster
2019-10-25 20:22 ` Darrick J. Wong
2019-10-09 16:48 ` [PATCH 3/3] xfs: use deferred frees to reap old btree blocks Darrick J. Wong
2019-10-17 12:55 ` Brian Foster
2019-10-17 15:06 ` Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2019-10-29 23:30 [PATCH v2 0/3] xfs: fix online repair block reaping Darrick J. Wong
2019-10-29 23:30 ` [PATCH 2/3] xfs: only invalidate blocks if we're going to free them Darrick J. Wong
2020-01-01 1:01 [PATCH v2 0/3] xfs: fix online repair block reaping Darrick J. Wong
2020-01-01 1:01 ` [PATCH 2/3] xfs: only invalidate blocks if we're going to free them Darrick J. Wong
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=157063972723.2913192.12835516373692425243.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).