xfs: refactor xfs_verifier_error and xfs_buf_ioerror
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:51:02 +0000 (10:51 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:54:45 +0000 (10:54 -0800)
Since all verification errors also mark the buffer as having an error,
we can combine these two calls.  Later we'll add a xfs_failaddr_t
parameter to promote the idea of reporting corruption errors and the
address of the failing check to enable better debugging reports.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
23 files changed:
fs/xfs/libxfs/xfs_alloc.c
fs/xfs/libxfs/xfs_alloc_btree.c
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_attr_remote.c
fs/xfs/libxfs/xfs_bmap_btree.c
fs/xfs/libxfs/xfs_da_btree.c
fs/xfs/libxfs/xfs_dir2_block.c
fs/xfs/libxfs/xfs_dir2_data.c
fs/xfs/libxfs/xfs_dir2_leaf.c
fs/xfs/libxfs/xfs_dir2_node.c
fs/xfs/libxfs/xfs_dquot_buf.c
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_ialloc_btree.c
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_refcount_btree.c
fs/xfs/libxfs/xfs_rmap_btree.c
fs/xfs/libxfs/xfs_sb.c
fs/xfs/libxfs/xfs_symlink_remote.c
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_error.c
fs/xfs/xfs_error.h
fs/xfs/xfs_trace.h

index 83ed7715f856d2025509c308583436e63d0043a5..055ffa8b7a5204b0aba33658e4aa37440b35fd9d 100644 (file)
@@ -567,12 +567,9 @@ xfs_agfl_read_verify(
                return;
 
        if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_agfl_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -587,8 +584,7 @@ xfs_agfl_write_verify(
                return;
 
        if (!xfs_agfl_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
@@ -2461,13 +2457,10 @@ xfs_agf_read_verify(
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp,
                                XFS_ERRTAG_ALLOC_READ_AGF))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -2478,8 +2471,7 @@ xfs_agf_write_verify(
        struct xfs_buf_log_item *bip = bp->b_fspriv;
 
        if (!xfs_agf_verify(mp, bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
index cfde0a0f97061ec9e57973553910ca8adbcd66c8..752d6aa10e547c40dbcfa49fa18cd1090a1a2f0b 100644 (file)
@@ -364,14 +364,12 @@ xfs_allocbt_read_verify(
        struct xfs_buf  *bp)
 {
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_allocbt_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 
-       if (bp->b_error) {
+       if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp);
-       }
 }
 
 static void
@@ -380,8 +378,7 @@ xfs_allocbt_write_verify(
 {
        if (!xfs_allocbt_verify(bp)) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index 601eaa36f1ada22e2213f9178bcb5cdb5868034d..6a9805ad95cb48c22bce046cdd70b5e5fb5aa4dd 100644 (file)
@@ -297,8 +297,7 @@ xfs_attr3_leaf_write_verify(
        struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
 
        if (!xfs_attr3_leaf_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
@@ -325,12 +324,9 @@ xfs_attr3_leaf_read_verify(
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
             !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_attr3_leaf_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
index d56caf037ca0e7948035f5e987caff7a1a0d8e07..231b569bb230af955933b1714eaf733ab4bbc2a4 100644 (file)
@@ -137,22 +137,20 @@ xfs_attr3_rmt_read_verify(
 
        while (len > 0) {
                if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
-                       xfs_buf_ioerror(bp, -EFSBADCRC);
-                       break;
+                       xfs_verifier_error(bp, -EFSBADCRC);
+                       return;
                }
                if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
-                       xfs_buf_ioerror(bp, -EFSCORRUPTED);
-                       break;
+                       xfs_verifier_error(bp, -EFSCORRUPTED);
+                       return;
                }
                len -= blksize;
                ptr += blksize;
                bno += BTOBB(blksize);
        }
 
-       if (bp->b_error)
-               xfs_verifier_error(bp);
-       else
-               ASSERT(len == 0);
+       if (len != 0)
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -178,8 +176,7 @@ xfs_attr3_rmt_write_verify(
                struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
 
                if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
-                       xfs_buf_ioerror(bp, -EFSCORRUPTED);
-                       xfs_verifier_error(bp);
+                       xfs_verifier_error(bp, -EFSCORRUPTED);
                        return;
                }
 
@@ -188,8 +185,7 @@ xfs_attr3_rmt_write_verify(
                 * xfs_attr3_rmt_hdr_set() for the explanation.
                 */
                if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) {
-                       xfs_buf_ioerror(bp, -EFSCORRUPTED);
-                       xfs_verifier_error(bp);
+                       xfs_verifier_error(bp, -EFSCORRUPTED);
                        return;
                }
                xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
@@ -198,7 +194,9 @@ xfs_attr3_rmt_write_verify(
                ptr += blksize;
                bno += BTOBB(blksize);
        }
-       ASSERT(len == 0);
+
+       if (len != 0)
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
index 862be9c5eb086f5adfbfab370fb223d3f2d013ef..b6d61c7161d17f3589e4f254a8eee7a8eb41e1f3 100644 (file)
@@ -467,14 +467,12 @@ xfs_bmbt_read_verify(
        struct xfs_buf  *bp)
 {
        if (!xfs_btree_lblock_verify_crc(bp))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_bmbt_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 
-       if (bp->b_error) {
+       if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp);
-       }
 }
 
 static void
@@ -483,8 +481,7 @@ xfs_bmbt_write_verify(
 {
        if (!xfs_bmbt_verify(bp)) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
        xfs_btree_lblock_calc_crc(bp);
index 651611530d2ff91f77a569a77a944d9f9569c9dd..27b5ed375e6113ce4a5d478f8e9afe6ebcacb1a9 100644 (file)
@@ -186,8 +186,7 @@ xfs_da3_node_write_verify(
        struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
 
        if (!xfs_da3_node_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
@@ -215,15 +214,13 @@ xfs_da3_node_read_verify(
        switch (be16_to_cpu(info->magic)) {
                case XFS_DA3_NODE_MAGIC:
                        if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) {
-                               xfs_buf_ioerror(bp, -EFSBADCRC);
+                               xfs_verifier_error(bp, -EFSBADCRC);
                                break;
                        }
                        /* fall through */
                case XFS_DA_NODE_MAGIC:
-                       if (!xfs_da3_node_verify(bp)) {
-                               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-                               break;
-                       }
+                       if (!xfs_da3_node_verify(bp))
+                               xfs_verifier_error(bp, -EFSCORRUPTED);
                        return;
                case XFS_ATTR_LEAF_MAGIC:
                case XFS_ATTR3_LEAF_MAGIC:
@@ -236,12 +233,9 @@ xfs_da3_node_read_verify(
                        bp->b_ops->verify_read(bp);
                        return;
                default:
-                       xfs_buf_ioerror(bp, -EFSCORRUPTED);
+                       xfs_verifier_error(bp, -EFSCORRUPTED);
                        break;
        }
-
-       /* corrupt block */
-       xfs_verifier_error(bp);
 }
 
 const struct xfs_buf_ops xfs_da3_node_buf_ops = {
index e4272494b17f8cda2cedb87c4064923af04edb4b..a5d95c9ddd3689c0ed717dacce77c7c6997c29b0 100644 (file)
@@ -89,12 +89,9 @@ xfs_dir3_block_read_verify(
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
             !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_dir3_block_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -106,8 +103,7 @@ xfs_dir3_block_write_verify(
        struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
 
        if (!xfs_dir3_block_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
index af15f7052f3a1bf1ef0756c1f3da320e86828644..e1546fb33393e17733224f6de5064d2880b05bbf 100644 (file)
@@ -267,8 +267,7 @@ xfs_dir3_data_reada_verify(
                bp->b_ops->verify_read(bp);
                return;
        default:
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                break;
        }
 }
@@ -280,13 +279,10 @@ xfs_dir3_data_read_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
-            !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
-                xfs_buf_ioerror(bp, -EFSBADCRC);
+           !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_dir3_data_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -298,8 +294,7 @@ xfs_dir3_data_write_verify(
        struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
 
        if (!xfs_dir3_data_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
index 27297a689d9c26acea0a10e643b8c0694867b8b4..071f879cc114f12a8fbd8f347c5abca35e8d8da5 100644 (file)
@@ -184,12 +184,9 @@ __read_verify(
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
             !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_dir3_leaf_verify(bp, magic))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -202,8 +199,7 @@ __write_verify(
        struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
 
        if (!xfs_dir3_leaf_verify(bp, magic)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
index 682e2bf370c72923b43ee7da7d778ba774f66551..888301d22c457dc2012bd4bf71e8a7cf55446ead 100644 (file)
@@ -118,12 +118,9 @@ xfs_dir3_free_read_verify(
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_dir3_free_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -135,8 +132,7 @@ xfs_dir3_free_write_verify(
        struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
 
        if (!xfs_dir3_free_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
@@ -209,8 +205,7 @@ __xfs_dir3_free_read(
 
        /* Check things that we can't do in the verifier. */
        if (!xfs_dir3_free_header_check(dp, fbno, *bpp)) {
-               xfs_buf_ioerror(*bpp, -EFSCORRUPTED);
-               xfs_verifier_error(*bpp);
+               xfs_verifier_error(*bpp, -EFSCORRUPTED);
                xfs_trans_brelse(tp, *bpp);
                return -EFSCORRUPTED;
        }
index 747085b4ef4406d387464b40fdea302b83c25c4c..a3f1eccc614bcc0245b6347f43e659b4da58e09d 100644 (file)
@@ -249,12 +249,9 @@ xfs_dquot_buf_read_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
 
        if (!xfs_dquot_buf_verify_crc(mp, bp))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 /*
@@ -288,8 +285,7 @@ xfs_dquot_buf_write_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
 
        if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 }
index 3b57ef0f2f76c758e6a9c8b89b7a0c470cdd09a9..3a41e852206e9eb7c2eaba4790624a92dd4fecef 100644 (file)
@@ -2544,13 +2544,10 @@ xfs_agi_read_verify(
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (XFS_TEST_ERROR(!xfs_agi_verify(bp), mp,
                                XFS_ERRTAG_IALLOC_READ_AGI))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -2561,8 +2558,7 @@ xfs_agi_write_verify(
        struct xfs_buf_log_item *bip = bp->b_fspriv;
 
        if (!xfs_agi_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
index 317caba9faa67d4c01d057c24015c0d8964cca60..d86bdce6652a94581a0c72cca8778acefabcdebf 100644 (file)
@@ -294,14 +294,12 @@ xfs_inobt_read_verify(
        struct xfs_buf  *bp)
 {
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_inobt_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 
-       if (bp->b_error) {
+       if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp);
-       }
 }
 
 static void
@@ -310,8 +308,7 @@ xfs_inobt_write_verify(
 {
        if (!xfs_inobt_verify(bp)) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index 6b7989038d75521678981f524961e0154d0c7760..b625f65bc412341620eb92c0ce48959e8832dcb0 100644 (file)
@@ -113,8 +113,7 @@ xfs_inode_buf_verify(
                                return;
                        }
 
-                       xfs_buf_ioerror(bp, -EFSCORRUPTED);
-                       xfs_verifier_error(bp);
+                       xfs_verifier_error(bp, -EFSCORRUPTED);
 #ifdef DEBUG
                        xfs_alert(mp,
                                "bad inode magic/vsn daddr %lld #%d (magic=%x)",
index 3c59dd3d58d714dc3f5b586906c8cc63e0265822..ce940ebe230cc8f87c25b39b9d8220fa9d4c5812 100644 (file)
@@ -255,14 +255,12 @@ xfs_refcountbt_read_verify(
        struct xfs_buf  *bp)
 {
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_refcountbt_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 
-       if (bp->b_error) {
+       if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp);
-       }
 }
 
 STATIC void
@@ -271,8 +269,7 @@ xfs_refcountbt_write_verify(
 {
        if (!xfs_refcountbt_verify(bp)) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index 9d9c9192584c97dba7733f74e6892adb33f8b163..6325908463c2f65e5422cd4bbe5f0b74a4eae700 100644 (file)
@@ -347,14 +347,12 @@ xfs_rmapbt_read_verify(
        struct xfs_buf  *bp)
 {
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_rmapbt_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 
-       if (bp->b_error) {
+       if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp);
-       }
 }
 
 static void
@@ -363,8 +361,7 @@ xfs_rmapbt_write_verify(
 {
        if (!xfs_rmapbt_verify(bp)) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index 9b5aae2bcc0b7817922c25f24fb6c5324bb9ac1c..96a82672989a23151a4b73a1b408a9b55e44ba12 100644 (file)
@@ -640,11 +640,10 @@ xfs_sb_read_verify(
        error = xfs_sb_verify(bp, true);
 
 out_error:
-       if (error) {
+       if (error == -EFSCORRUPTED || error == -EFSBADCRC)
+               xfs_verifier_error(bp, error);
+       else if (error)
                xfs_buf_ioerror(bp, error);
-               if (error == -EFSCORRUPTED || error == -EFSBADCRC)
-                       xfs_verifier_error(bp);
-       }
 }
 
 /*
@@ -678,8 +677,7 @@ xfs_sb_write_verify(
 
        error = xfs_sb_verify(bp, false);
        if (error) {
-               xfs_buf_ioerror(bp, error);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, error);
                return;
        }
 
index c484877129a0d0b55c6f94517c0a1ac1703550fc..58c21a6e0eff85479b59171efd13f02f057c7dbb 100644 (file)
@@ -135,12 +135,9 @@ xfs_symlink_read_verify(
                return;
 
        if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
-               xfs_buf_ioerror(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC);
        else if (!xfs_symlink_verify(bp))
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-
-       if (bp->b_error)
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
 }
 
 static void
@@ -155,8 +152,7 @@ xfs_symlink_write_verify(
                return;
 
        if (!xfs_symlink_verify(bp)) {
-               xfs_buf_ioerror(bp, -EFSCORRUPTED);
-               xfs_verifier_error(bp);
+               xfs_verifier_error(bp, -EFSCORRUPTED);
                return;
        }
 
index 4c6e86d861fda1a452dbeb20c1d3d64018627a20..45987a2789304de7a239f43be196404490b1ccac 100644 (file)
@@ -1180,13 +1180,14 @@ xfs_buf_ioend_async(
 }
 
 void
-xfs_buf_ioerror(
+__xfs_buf_ioerror(
        xfs_buf_t               *bp,
-       int                     error)
+       int                     error,
+       xfs_failaddr_t          failaddr)
 {
        ASSERT(error <= 0 && error >= -1000);
        bp->b_error = error;
-       trace_xfs_buf_ioerror(bp, error, _RET_IP_);
+       trace_xfs_buf_ioerror(bp, error, failaddr);
 }
 
 void
index f873bb786824280f01eeb90bf6e891f5d5ae7165..6f907a365f85cb30509e8413a00cf64517423adc 100644 (file)
@@ -315,7 +315,9 @@ extern void xfs_buf_unlock(xfs_buf_t *);
 /* Buffer Read and Write Routines */
 extern int xfs_bwrite(struct xfs_buf *bp);
 extern void xfs_buf_ioend(struct xfs_buf *bp);
-extern void xfs_buf_ioerror(xfs_buf_t *, int);
+extern void __xfs_buf_ioerror(struct xfs_buf *bp, int error,
+               xfs_failaddr_t failaddr);
+#define xfs_buf_ioerror(bp, err) __xfs_buf_ioerror((bp), (err), __this_address)
 extern void xfs_buf_ioerror_alert(struct xfs_buf *, const char *func);
 extern void xfs_buf_submit(struct xfs_buf *bp);
 extern int xfs_buf_submit_wait(struct xfs_buf *bp);
index 4c9f35d983b2a567aeef32565023efead34e1b25..c0a98c42033d03088c08edb780c3806b33630219 100644 (file)
@@ -347,10 +347,13 @@ xfs_corruption_error(
  */
 void
 xfs_verifier_error(
-       struct xfs_buf          *bp)
+       struct xfs_buf          *bp,
+       int                     error)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
 
+       __xfs_buf_ioerror(bp, error, __return_address);
+
        xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx",
                  bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
                  __return_address, bp->b_ops->name, bp->b_bn);
index ea816c1bf8dbf2a83a89af5cae738a8791e06e6c..598756281d8d701ef5e3db4fcabf4914359846d3 100644 (file)
@@ -25,7 +25,7 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
 extern void xfs_corruption_error(const char *tag, int level,
                        struct xfs_mount *mp, void *p, const char *filename,
                        int linenum, void *ra);
-extern void xfs_verifier_error(struct xfs_buf *bp);
+extern void xfs_verifier_error(struct xfs_buf *bp, int error);
 
 #define        XFS_ERROR_REPORT(e, lvl, mp)    \
        xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
index d718a10c22714b5551d44bb2f8e662ac93199078..9235b2c2969558ee73c436c35249413ff12942d8 100644 (file)
@@ -390,7 +390,7 @@ DEFINE_BUF_FLAGS_EVENT(xfs_buf_get);
 DEFINE_BUF_FLAGS_EVENT(xfs_buf_read);
 
 TRACE_EVENT(xfs_buf_ioerror,
-       TP_PROTO(struct xfs_buf *bp, int error, unsigned long caller_ip),
+       TP_PROTO(struct xfs_buf *bp, int error, xfs_failaddr_t caller_ip),
        TP_ARGS(bp, error, caller_ip),
        TP_STRUCT__entry(
                __field(dev_t, dev)
@@ -401,7 +401,7 @@ TRACE_EVENT(xfs_buf_ioerror,
                __field(int, pincount)
                __field(unsigned, lockval)
                __field(int, error)
-               __field(unsigned long, caller_ip)
+               __field(xfs_failaddr_t, caller_ip)
        ),
        TP_fast_assign(
                __entry->dev = bp->b_target->bt_dev;
@@ -415,7 +415,7 @@ TRACE_EVENT(xfs_buf_ioerror,
                __entry->caller_ip = caller_ip;
        ),
        TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d "
-                 "lock %d error %d flags %s caller %ps",
+                 "lock %d error %d flags %s caller %pS",
                  MAJOR(__entry->dev), MINOR(__entry->dev),
                  (unsigned long long)__entry->bno,
                  __entry->buffer_length,