From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 06/16] xfs: check btree block ownership with bnobt/rmapbt when scrubbing btree
Date: Tue, 28 Nov 2017 17:26:00 -0800 [thread overview]
Message-ID: <151191876080.8553.10718319703301125265.stgit@magnolia> (raw)
In-Reply-To: <151191872395.8553.15627872818207535470.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
When scanning a metadata btree block, cross-reference the block location
with the free space btree and the reverse mapping btree to ensure that
the rmapbt knows about the block and the bnobt does not. Add a
mechanism to defer checks when we happen to be scanning the bnobt/rmapbt
itself because it's less efficient to repeatedly clone and destroy the
cursor.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/scrub/btree.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 92 insertions(+)
diff --git a/fs/xfs/scrub/btree.c b/fs/xfs/scrub/btree.c
index 8d48b5b1..40fc26f 100644
--- a/fs/xfs/scrub/btree.c
+++ b/fs/xfs/scrub/btree.c
@@ -359,6 +359,80 @@ xfs_scrub_btree_block_check_siblings(
return error;
}
+struct check_owner {
+ struct list_head list;
+ xfs_daddr_t daddr;
+ int level;
+};
+
+/*
+ * Make sure this btree block isn't in the free list and that there's
+ * an rmap record for it.
+ */
+STATIC int
+xfs_scrub_btree_check_block_owner(
+ struct xfs_scrub_btree *bs,
+ int level,
+ xfs_daddr_t daddr)
+{
+ struct xfs_scrub_ag sa = { 0 };
+ struct xfs_scrub_ag *psa;
+ xfs_agnumber_t agno;
+ int error = 0;
+
+ agno = xfs_daddr_to_agno(bs->cur->bc_mp, daddr);
+
+ if (bs->cur->bc_flags & XFS_BTREE_LONG_PTRS) {
+ error = xfs_scrub_ag_init(bs->sc, agno, &sa);
+ if (!xfs_scrub_btree_xref_process_error(bs->sc, bs->cur,
+ level, &error))
+ return error;
+ psa = &sa;
+ } else {
+ psa = &bs->sc->sa;
+ }
+
+ if (psa == &sa)
+ xfs_scrub_ag_free(bs->sc, &sa);
+
+ return error;
+}
+
+/* Check the owner of a btree block. */
+STATIC int
+xfs_scrub_btree_check_owner(
+ struct xfs_scrub_btree *bs,
+ int level,
+ struct xfs_buf *bp)
+{
+ struct xfs_btree_cur *cur = bs->cur;
+ struct check_owner *co;
+
+ if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && bp == NULL)
+ return 0;
+
+ /*
+ * We want to cross-reference each btree block with the bnobt
+ * and the rmapbt. We cannot cross-reference the bnobt or
+ * rmapbt while scanning the bnobt or rmapbt, respectively,
+ * because we cannot alter the cursor and we'd prefer not to
+ * duplicate cursors. Therefore, save the buffer daddr for
+ * later scanning.
+ */
+ if (cur->bc_btnum == XFS_BTNUM_BNO || cur->bc_btnum == XFS_BTNUM_RMAP) {
+ co = kmem_alloc(sizeof(struct check_owner),
+ KM_MAYFAIL | KM_NOFS);
+ if (!co)
+ return -ENOMEM;
+ co->level = level;
+ co->daddr = XFS_BUF_ADDR(bp);
+ list_add_tail(&co->list, &bs->to_check);
+ return 0;
+ }
+
+ return xfs_scrub_btree_check_block_owner(bs, level, XFS_BUF_ADDR(bp));
+}
+
/*
* Grab and scrub a btree block given a btree pointer. Returns block
* and buffer pointers (if applicable) if they're ok to use.
@@ -395,6 +469,14 @@ xfs_scrub_btree_get_block(
}
/*
+ * Check the block's owner; this function absorbs error codes
+ * for us.
+ */
+ error = xfs_scrub_btree_check_owner(bs, level, *pbp);
+ if (error)
+ return error;
+
+ /*
* Check the block's siblings; this function absorbs error codes
* for us.
*/
@@ -465,6 +547,8 @@ xfs_scrub_btree(
struct xfs_btree_block *block;
int level;
struct xfs_buf *bp;
+ struct check_owner *co;
+ struct check_owner *n;
int i;
int error = 0;
@@ -556,6 +640,14 @@ xfs_scrub_btree(
}
out:
+ /* Process deferred owner checks on btree blocks. */
+ list_for_each_entry_safe(co, n, &bs.to_check, list) {
+ if (!error)
+ error = xfs_scrub_btree_check_block_owner(&bs,
+ co->level, co->daddr);
+ list_del(&co->list);
+ kmem_free(co);
+ }
return error;
}
next prev parent reply other threads:[~2017-11-29 1:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 1:25 [PATCH v10 00/16] xfs: online scrub xref support Darrick J. Wong
2017-11-29 1:25 ` [PATCH 01/16] xfs: add scrub cross-referencing helpers for the free space btrees Darrick J. Wong
2017-11-29 1:25 ` [PATCH 02/16] xfs: add scrub cross-referencing helpers for the inode btrees Darrick J. Wong
2017-11-29 1:25 ` [PATCH 03/16] xfs: add scrub cross-referencing helpers for the rmap btrees Darrick J. Wong
2017-11-29 1:25 ` [PATCH 04/16] xfs: add scrub cross-referencing helpers for the refcount btrees Darrick J. Wong
2017-11-29 1:25 ` [PATCH 05/16] xfs: set up scrub cross-referencing helpers Darrick J. Wong
2017-11-29 1:26 ` Darrick J. Wong [this message]
2017-11-29 1:26 ` [PATCH 07/16] xfs: introduce scrubber cross-referencing stubs Darrick J. Wong
2017-11-29 1:26 ` [PATCH 08/16] xfs: scrub should cross-reference with the bnobt Darrick J. Wong
2017-11-29 1:26 ` [PATCH 09/16] xfs: cross-reference bnobt records with cntbt Darrick J. Wong
2017-11-29 1:26 ` [PATCH 10/16] xfs: cross-reference inode btrees during scrub Darrick J. Wong
2017-11-29 1:26 ` [PATCH 11/16] xfs: cross-reference reverse-mapping btree Darrick J. Wong
2017-11-29 1:26 ` [PATCH 12/16] xfs: cross-reference the rmapbt data with the refcountbt Darrick J. Wong
2017-11-29 1:26 ` [PATCH 13/16] xfs: cross-reference refcount btree during scrub Darrick J. Wong
2017-11-29 1:26 ` [PATCH 14/16] xfs: scrub should cross-reference the realtime bitmap Darrick J. Wong
2017-11-29 1:26 ` [PATCH 15/16] xfs: cross-reference the block mappings when possible Darrick J. Wong
2017-11-29 1:27 ` [PATCH 16/16] xfs: abort scrubs if the oom killer fires Darrick J. Wong
-- strict thread matches above, loose matches on Subject: below --
2017-08-11 7:10 [PATCH v9 00/16] xfs: online scrub xref support Darrick J. Wong
2017-08-11 7:10 ` [PATCH 06/16] xfs: check btree block ownership with bnobt/rmapbt when scrubbing btree 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=151191876080.8553.10718319703301125265.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).