Home Home > GIT Browse > SLE15
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Iliopoulos <ailiopoulos@suse.com>2019-05-17 17:18:17 +0200
committerAnthony Iliopoulos <ailiopoulos@suse.com>2019-05-17 17:18:17 +0200
commita98bae69f689ffcad33ed6dc223fc0c5968d6b09 (patch)
tree56c910f1823a55797bd43e4a4bd86f771ae5afaa
parent69250e0c5bee7f3dfdf0966b05f2e3b79d6527cf (diff)
xfs: refactor btree pointer checks (bsc#1123663).
-rw-r--r--patches.fixes/xfs-refactor-btree-pointer-checks.patch162
-rw-r--r--series.conf1
2 files changed, 163 insertions, 0 deletions
diff --git a/patches.fixes/xfs-refactor-btree-pointer-checks.patch b/patches.fixes/xfs-refactor-btree-pointer-checks.patch
new file mode 100644
index 0000000000..ceae8b7a6a
--- /dev/null
+++ b/patches.fixes/xfs-refactor-btree-pointer-checks.patch
@@ -0,0 +1,162 @@
+From f135761a73b18877bdfb44018fe993172c7be203 Mon Sep 17 00:00:00 2001
+From: "Darrick J. Wong" <darrick.wong@oracle.com>
+Date: Tue, 17 Oct 2017 21:37:33 -0700
+Subject: [PATCH] xfs: refactor btree pointer checks
+Git-commit: f135761a73b18877bdfb44018fe993172c7be203
+Patch-mainline: v4.15-rc1
+References: bsc#1123663
+
+Refactor the btree pointer checks so that we can call them from the
+scrub code without logging errors to dmesg. Preserve the existing error
+reporting for regular operations.
+
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Reviewed-by: Dave Chinner <dchinner@redhat.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/libxfs/xfs_bmap.c | 4 +--
+ fs/xfs/libxfs/xfs_btree.c | 70 ++++++++++++++++++++++-------------------------
+ fs/xfs/libxfs/xfs_btree.h | 13 +++++++--
+ 3 files changed, 45 insertions(+), 42 deletions(-)
+
+diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
+index dd6672b81c26..7eac21a310bf 100644
+--- a/fs/xfs/libxfs/xfs_bmap.c
++++ b/fs/xfs/libxfs/xfs_bmap.c
+@@ -646,8 +646,8 @@ xfs_bmap_btree_to_extents(
+ cbno = be64_to_cpu(*pp);
+ *logflagsp = 0;
+ #ifdef DEBUG
+- if ((error = xfs_btree_check_lptr(cur, cbno, 1)))
+- return error;
++ XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
++ xfs_btree_check_lptr(cur, cbno, 1));
+ #endif
+ error = xfs_btree_read_bufl(mp, tp, cbno, 0, &cbp, XFS_BMAP_BTREE_REF,
+ &xfs_bmbt_buf_ops);
+diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
+index 5bfb88261c7e..ae19f242c237 100644
+--- a/fs/xfs/libxfs/xfs_btree.c
++++ b/fs/xfs/libxfs/xfs_btree.c
+@@ -177,59 +177,53 @@ xfs_btree_check_block(
+ return xfs_btree_check_sblock(cur, block, level, bp);
+ }
+
+-/*
+- * Check that (long) pointer is ok.
+- */
+-int /* error (0 or EFSCORRUPTED) */
++/* Check that this long pointer is valid and points within the fs. */
++bool
+ xfs_btree_check_lptr(
+- struct xfs_btree_cur *cur, /* btree cursor */
+- xfs_fsblock_t bno, /* btree block disk address */
+- int level) /* btree block level */
++ struct xfs_btree_cur *cur,
++ xfs_fsblock_t fsbno,
++ int level)
+ {
+- XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
+- level > 0 &&
+- bno != NULLFSBLOCK &&
+- XFS_FSB_SANITY_CHECK(cur->bc_mp, bno));
+- return 0;
++ if (level <= 0)
++ return false;
++ return xfs_verify_fsbno(cur->bc_mp, fsbno);
+ }
+
+-#ifdef DEBUG
+-/*
+- * Check that (short) pointer is ok.
+- */
+-STATIC int /* error (0 or EFSCORRUPTED) */
++/* Check that this short pointer is valid and points within the AG. */
++bool
+ xfs_btree_check_sptr(
+- struct xfs_btree_cur *cur, /* btree cursor */
+- xfs_agblock_t bno, /* btree block disk address */
+- int level) /* btree block level */
++ struct xfs_btree_cur *cur,
++ xfs_agblock_t agbno,
++ int level)
+ {
+- xfs_agblock_t agblocks = cur->bc_mp->m_sb.sb_agblocks;
+-
+- XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
+- level > 0 &&
+- bno != NULLAGBLOCK &&
+- bno != 0 &&
+- bno < agblocks);
+- return 0;
++ if (level <= 0)
++ return false;
++ return xfs_verify_agbno(cur->bc_mp, cur->bc_private.a.agno, agbno);
+ }
+
++#ifdef DEBUG
+ /*
+- * Check that block ptr is ok.
++ * Check that a given (indexed) btree pointer at a certain level of a
++ * btree is valid and doesn't point past where it should.
+ */
+-STATIC int /* error (0 or EFSCORRUPTED) */
++int
+ xfs_btree_check_ptr(
+- struct xfs_btree_cur *cur, /* btree cursor */
+- union xfs_btree_ptr *ptr, /* btree block disk address */
+- int index, /* offset from ptr to check */
+- int level) /* btree block level */
++ struct xfs_btree_cur *cur,
++ union xfs_btree_ptr *ptr,
++ int index,
++ int level)
+ {
+ if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
+- return xfs_btree_check_lptr(cur,
+- be64_to_cpu((&ptr->l)[index]), level);
++ XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
++ xfs_btree_check_lptr(cur,
++ be64_to_cpu((&ptr->l)[index]), level));
+ } else {
+- return xfs_btree_check_sptr(cur,
+- be32_to_cpu((&ptr->s)[index]), level);
++ XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
++ xfs_btree_check_sptr(cur,
++ be32_to_cpu((&ptr->s)[index]), level));
+ }
++
++ return 0;
+ }
+ #endif
+
+diff --git a/fs/xfs/libxfs/xfs_btree.h b/fs/xfs/libxfs/xfs_btree.h
+index f2a88c3b1159..8f52eda8eb82 100644
+--- a/fs/xfs/libxfs/xfs_btree.h
++++ b/fs/xfs/libxfs/xfs_btree.h
+@@ -269,10 +269,19 @@ xfs_btree_check_block(
+ /*
+ * Check that (long) pointer is ok.
+ */
+-int /* error (0 or EFSCORRUPTED) */
++bool /* error (0 or EFSCORRUPTED) */
+ xfs_btree_check_lptr(
+ struct xfs_btree_cur *cur, /* btree cursor */
+- xfs_fsblock_t ptr, /* btree block disk address */
++ xfs_fsblock_t fsbno, /* btree block disk address */
++ int level); /* btree block level */
++
++/*
++ * Check that (short) pointer is ok.
++ */
++bool /* error (0 or EFSCORRUPTED) */
++xfs_btree_check_sptr(
++ struct xfs_btree_cur *cur, /* btree cursor */
++ xfs_agblock_t agbno, /* btree block disk address */
+ int level); /* btree block level */
+
+ /*
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 930df40c13..f089aed6da 100644
--- a/series.conf
+++ b/series.conf
@@ -8238,6 +8238,7 @@
patches.fixes/0028-xfs-remove-xfs_bmbt_get_state.patch
patches.fixes/xfs-return-a-distinct-error-code-value-for-IGET_INCO.patch
patches.fixes/xfs-create-block-pointer-check-functions.patch
+ patches.fixes/xfs-refactor-btree-pointer-checks.patch
patches.fixes/0029-xfs-add-a-xfs_bmap_fork_to_state-helper.patch
patches.fixes/0030-xfs-make-better-use-of-the-state-variable-in-xfs_bma.patch
patches.fixes/0031-xfs-remove-post-bmap-tracing-in-xfs_bmap_local_to_ex.patch