xfs: refactor verifier callers to print address of failing check
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:51:03 +0000 (10:51 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 8 Jan 2018 18:54:46 +0000 (10:54 -0800)
Refactor the callers of verifiers to print the instruction address of a
failing check.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
20 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_error.c
fs/xfs/xfs_error.h

index 4d7ef74f5783050dc3b01feeec8fa8b3ca7714d3..6bace8cb47dab11c88d82468895807e9c3937131 100644 (file)
@@ -557,6 +557,7 @@ xfs_agfl_read_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t  fa;
 
        /*
         * There is no verification of non-crc AGFLs because mkfs does not
@@ -568,9 +569,12 @@ xfs_agfl_read_verify(
                return;
 
        if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_agfl_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_agfl_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -579,13 +583,15 @@ xfs_agfl_write_verify(
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
+       xfs_failaddr_t          fa;
 
        /* no verification of non-crc AGFLs */
        if (!xfs_sb_version_hascrc(&mp->m_sb))
                return;
 
-       if (xfs_agfl_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_agfl_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
@@ -2455,13 +2461,16 @@ xfs_agf_read_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t  fa;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (XFS_TEST_ERROR(xfs_agf_verify(mp, bp), mp,
-                               XFS_ERRTAG_ALLOC_READ_AGF))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_agf_verify(mp, bp);
+               if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -2470,9 +2479,11 @@ xfs_agf_write_verify(
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
+       xfs_failaddr_t          fa;
 
-       if (xfs_agf_verify(mp, bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_agf_verify(mp, bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
index 4383c05df8cabdb46688e968f877587ebe9beb8d..060d6fa83a7f2612bd5647a2d66d6329c47669b7 100644 (file)
@@ -366,10 +366,15 @@ static void
 xfs_allocbt_read_verify(
        struct xfs_buf  *bp)
 {
+       xfs_failaddr_t  fa;
+
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_allocbt_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_allocbt_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 
        if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -379,9 +384,12 @@ static void
 xfs_allocbt_write_verify(
        struct xfs_buf  *bp)
 {
-       if (xfs_allocbt_verify(bp)) {
+       xfs_failaddr_t  fa;
+
+       fa = xfs_allocbt_verify(bp);
+       if (fa) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index f6281e100469d2017828fb34a6aee0c332f1a230..68c66fa378fdc177a074ed7c26ed49d5f06b3f91 100644 (file)
@@ -295,9 +295,11 @@ xfs_attr3_leaf_write_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
        struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
+       xfs_failaddr_t          fa;
 
-       if (xfs_attr3_leaf_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_attr3_leaf_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
@@ -321,12 +323,16 @@ xfs_attr3_leaf_read_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t          fa;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
             !xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_attr3_leaf_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_attr3_leaf_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
index 06858db972edc18217842458e56993875bb05abb..55514b34321609e4294f805476ea524676f29d2a 100644 (file)
@@ -122,6 +122,7 @@ xfs_attr3_rmt_read_verify(
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
        char            *ptr;
+       xfs_failaddr_t  fa;
        int             len;
        xfs_daddr_t     bno;
        int             blksize = mp->m_attr_geo->blksize;
@@ -137,12 +138,13 @@ xfs_attr3_rmt_read_verify(
 
        while (len > 0) {
                if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
-                       xfs_verifier_error(bp, -EFSBADCRC);
+                       xfs_verifier_error(bp, -EFSBADCRC, __this_address);
                        return;
                }
-               if (xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
-                       xfs_verifier_error(bp, -EFSCORRUPTED);
-                       return;
+               fa = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
+               if (fa) {
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+                       break;
                }
                len -= blksize;
                ptr += blksize;
@@ -150,7 +152,7 @@ xfs_attr3_rmt_read_verify(
        }
 
        if (len != 0)
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
 }
 
 static void
@@ -158,6 +160,7 @@ xfs_attr3_rmt_write_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t  fa;
        int             blksize = mp->m_attr_geo->blksize;
        char            *ptr;
        int             len;
@@ -175,8 +178,9 @@ xfs_attr3_rmt_write_verify(
        while (len > 0) {
                struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
 
-               if (xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
-                       xfs_verifier_error(bp, -EFSCORRUPTED);
+               fa = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
+               if (fa) {
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                        return;
                }
 
@@ -185,7 +189,7 @@ xfs_attr3_rmt_write_verify(
                 * xfs_attr3_rmt_hdr_set() for the explanation.
                 */
                if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) {
-                       xfs_verifier_error(bp, -EFSCORRUPTED);
+                       xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
                        return;
                }
                xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
@@ -196,7 +200,7 @@ xfs_attr3_rmt_write_verify(
        }
 
        if (len != 0)
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
 }
 
 const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
index 0fdae57e794472be0ab4666b0d8712f71ed9254d..64ae0eea9812da86b086151bac4a24e2571ce57a 100644 (file)
@@ -468,10 +468,15 @@ static void
 xfs_bmbt_read_verify(
        struct xfs_buf  *bp)
 {
+       xfs_failaddr_t  fa;
+
        if (!xfs_btree_lblock_verify_crc(bp))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_bmbt_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_bmbt_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 
        if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -481,9 +486,12 @@ static void
 xfs_bmbt_write_verify(
        struct xfs_buf  *bp)
 {
-       if (xfs_bmbt_verify(bp)) {
+       xfs_failaddr_t  fa;
+
+       fa = xfs_bmbt_verify(bp);
+       if (fa) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
        xfs_btree_lblock_calc_crc(bp);
index 60a2572ba4e38b45e182e6fac5573ec02f5f0e16..0ae39617a6c1e61ec732764927b4116dd441f944 100644 (file)
@@ -184,9 +184,11 @@ xfs_da3_node_write_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
        struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
+       xfs_failaddr_t          fa;
 
-       if (xfs_da3_node_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_da3_node_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
@@ -210,17 +212,20 @@ xfs_da3_node_read_verify(
        struct xfs_buf          *bp)
 {
        struct xfs_da_blkinfo   *info = bp->b_addr;
+       xfs_failaddr_t          fa;
 
        switch (be16_to_cpu(info->magic)) {
                case XFS_DA3_NODE_MAGIC:
                        if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) {
-                               xfs_verifier_error(bp, -EFSBADCRC);
+                               xfs_verifier_error(bp, -EFSBADCRC,
+                                               __this_address);
                                break;
                        }
                        /* fall through */
                case XFS_DA_NODE_MAGIC:
-                       if (xfs_da3_node_verify(bp))
-                               xfs_verifier_error(bp, -EFSCORRUPTED);
+                       fa = xfs_da3_node_verify(bp);
+                       if (fa)
+                               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                        return;
                case XFS_ATTR_LEAF_MAGIC:
                case XFS_ATTR3_LEAF_MAGIC:
@@ -233,7 +238,7 @@ xfs_da3_node_read_verify(
                        bp->b_ops->verify_read(bp);
                        return;
                default:
-                       xfs_verifier_error(bp, -EFSCORRUPTED);
+                       xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
                        break;
        }
 }
index 3b728794659c5aa04612a9c5715e2cee3a3d17bd..cfd2777bf918473caa1b6f00073275fe5cc6ce7b 100644 (file)
@@ -86,12 +86,16 @@ xfs_dir3_block_read_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t          fa;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
             !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_dir3_block_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_dir3_block_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -101,9 +105,11 @@ xfs_dir3_block_write_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
        struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
+       xfs_failaddr_t          fa;
 
-       if (xfs_dir3_block_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_dir3_block_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
index 3eda2474ad0febde21f5f74fb0ce2b3006b1d098..2fa7c34023fbae8b189e95ad64bd02e321cf0389 100644 (file)
@@ -284,7 +284,7 @@ xfs_dir3_data_reada_verify(
                bp->b_ops->verify_read(bp);
                return;
        default:
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
                break;
        }
 }
@@ -294,12 +294,16 @@ xfs_dir3_data_read_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t          fa;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_dir3_data_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_dir3_data_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -309,9 +313,11 @@ xfs_dir3_data_write_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
        struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
+       xfs_failaddr_t          fa;
 
-       if (xfs_dir3_data_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_dir3_data_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
index a8694860566bed6459f8218b6aa040f9963f8e03..a03d67995811035b91cc6bd84ab86cbf6a58cd25 100644 (file)
@@ -190,12 +190,16 @@ __read_verify(
        uint16_t        magic)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t          fa;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
             !xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_dir3_leaf_verify(bp, magic))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_dir3_leaf_verify(bp, magic);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -206,9 +210,11 @@ __write_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
        struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
+       xfs_failaddr_t          fa;
 
-       if (xfs_dir3_leaf_verify(bp, magic)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_dir3_leaf_verify(bp, magic);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
index 051a21f3ad06f910b66cc0bf26df10c381c6c701..3bdbe18972121d76891aa11d1024926a4b4a6ad4 100644 (file)
@@ -124,12 +124,16 @@ xfs_dir3_free_read_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount        *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t          fa;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_dir3_free_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_dir3_free_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -139,9 +143,11 @@ xfs_dir3_free_write_verify(
        struct xfs_mount        *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
        struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
+       xfs_failaddr_t          fa;
 
-       if (xfs_dir3_free_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_dir3_free_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
@@ -161,7 +167,7 @@ const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
 };
 
 /* Everything ok in the free block header? */
-static bool
+static xfs_failaddr_t
 xfs_dir3_free_header_check(
        struct xfs_inode        *dp,
        xfs_dablk_t             fbno,
@@ -205,6 +211,7 @@ __xfs_dir3_free_read(
        xfs_daddr_t             mappedbno,
        struct xfs_buf          **bpp)
 {
+       xfs_failaddr_t          fa;
        int                     err;
 
        err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
@@ -213,8 +220,9 @@ __xfs_dir3_free_read(
                return err;
 
        /* Check things that we can't do in the verifier. */
-       if (xfs_dir3_free_header_check(dp, fbno, *bpp)) {
-               xfs_verifier_error(*bpp, -EFSCORRUPTED);
+       fa = xfs_dir3_free_header_check(dp, fbno, *bpp);
+       if (fa) {
+               xfs_verifier_error(*bpp, -EFSCORRUPTED, fa);
                xfs_trans_brelse(tp, *bpp);
                return -EFSCORRUPTED;
        }
index a3f1eccc614bcc0245b6347f43e659b4da58e09d..5e022c1a52c4336f5edcc4dc9e04ba9060809649 100644 (file)
@@ -249,9 +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_verifier_error(bp, -EFSBADCRC);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
        else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
 }
 
 /*
@@ -285,7 +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_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
                return;
        }
 }
index f53f9bc486e83c16bab2750dee451fbbbe9d025e..344b6a3525e1b06bc32287ac91f79e7429d5c9c8 100644 (file)
@@ -2541,13 +2541,16 @@ xfs_agi_read_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t  fa;
 
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            !xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (XFS_TEST_ERROR(xfs_agi_verify(bp), mp,
-                               XFS_ERRTAG_IALLOC_READ_AGI))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_agi_verify(bp);
+               if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -2556,9 +2559,11 @@ xfs_agi_write_verify(
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
+       xfs_failaddr_t          fa;
 
-       if (xfs_agi_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_agi_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
index 8fe126bcc5bde84cadf549dad88b8887a36ff49b..9c691ad00220cea23b539ddf91b399fce2b8e7ad 100644 (file)
@@ -295,10 +295,15 @@ static void
 xfs_inobt_read_verify(
        struct xfs_buf  *bp)
 {
+       xfs_failaddr_t  fa;
+
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_inobt_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_inobt_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 
        if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -308,9 +313,12 @@ static void
 xfs_inobt_write_verify(
        struct xfs_buf  *bp)
 {
-       if (xfs_inobt_verify(bp)) {
+       xfs_failaddr_t  fa;
+
+       fa = xfs_inobt_verify(bp);
+       if (fa) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index 607dcca30668fb5e747b61690ff02f4b715020af..a43a3702af938a294e2c7963078a1b0517cc855d 100644 (file)
@@ -113,7 +113,7 @@ xfs_inode_buf_verify(
                                return;
                        }
 
-                       xfs_verifier_error(bp, -EFSCORRUPTED);
+                       xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
 #ifdef DEBUG
                        xfs_alert(mp,
                                "bad inode magic/vsn daddr %lld #%d (magic=%x)",
index aa090510e8e090080d8e6b909173c85a75ff40e2..715c272a609ce6bd64021a585731ea2d560d59f4 100644 (file)
@@ -256,10 +256,15 @@ STATIC void
 xfs_refcountbt_read_verify(
        struct xfs_buf  *bp)
 {
+       xfs_failaddr_t  fa;
+
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_refcountbt_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_refcountbt_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 
        if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -269,9 +274,12 @@ STATIC void
 xfs_refcountbt_write_verify(
        struct xfs_buf  *bp)
 {
-       if (xfs_refcountbt_verify(bp)) {
+       xfs_failaddr_t  fa;
+
+       fa = xfs_refcountbt_verify(bp);
+       if (fa) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index 333fd5c08f9f1f992fcc5219516368661c55f9f7..d089a48ac530dad31ccdfe752753ded9922891f8 100644 (file)
@@ -348,10 +348,15 @@ static void
 xfs_rmapbt_read_verify(
        struct xfs_buf  *bp)
 {
+       xfs_failaddr_t  fa;
+
        if (!xfs_btree_sblock_verify_crc(bp))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_rmapbt_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_rmapbt_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 
        if (bp->b_error)
                trace_xfs_btree_corrupt(bp, _RET_IP_);
@@ -361,9 +366,12 @@ static void
 xfs_rmapbt_write_verify(
        struct xfs_buf  *bp)
 {
-       if (xfs_rmapbt_verify(bp)) {
+       xfs_failaddr_t  fa;
+
+       fa = xfs_rmapbt_verify(bp);
+       if (fa) {
                trace_xfs_btree_corrupt(bp, _RET_IP_);
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
        xfs_btree_sblock_calc_crc(bp);
index 96a82672989a23151a4b73a1b408a9b55e44ba12..63e0331b1d2480524b1670067862ed7ccd1a440e 100644 (file)
@@ -641,7 +641,7 @@ xfs_sb_read_verify(
 
 out_error:
        if (error == -EFSCORRUPTED || error == -EFSBADCRC)
-               xfs_verifier_error(bp, error);
+               xfs_verifier_error(bp, error, __this_address);
        else if (error)
                xfs_buf_ioerror(bp, error);
 }
@@ -677,7 +677,7 @@ xfs_sb_write_verify(
 
        error = xfs_sb_verify(bp, false);
        if (error) {
-               xfs_verifier_error(bp, error);
+               xfs_verifier_error(bp, error, __this_address);
                return;
        }
 
index 64db737c49d5618523093dc61fa3c5bb0d477841..5497014f52930eafca3abed8144f8654ec6f5642 100644 (file)
@@ -129,15 +129,19 @@ xfs_symlink_read_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t  fa;
 
        /* no verification of non-crc buffers */
        if (!xfs_sb_version_hascrc(&mp->m_sb))
                return;
 
        if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
-               xfs_verifier_error(bp, -EFSBADCRC);
-       else if (xfs_symlink_verify(bp))
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+               xfs_verifier_error(bp, -EFSBADCRC, __this_address);
+       else {
+               fa = xfs_symlink_verify(bp);
+               if (fa)
+                       xfs_verifier_error(bp, -EFSCORRUPTED, fa);
+       }
 }
 
 static void
@@ -146,13 +150,15 @@ xfs_symlink_write_verify(
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
        struct xfs_buf_log_item *bip = bp->b_fspriv;
+       xfs_failaddr_t          fa;
 
        /* no verification of non-crc buffers */
        if (!xfs_sb_version_hascrc(&mp->m_sb))
                return;
 
-       if (xfs_symlink_verify(bp)) {
-               xfs_verifier_error(bp, -EFSCORRUPTED);
+       fa = xfs_symlink_verify(bp);
+       if (fa) {
+               xfs_verifier_error(bp, -EFSCORRUPTED, fa);
                return;
        }
 
index c0a98c42033d03088c08edb780c3806b33630219..21db07cc7a11f8289d91cf97d0d88db686907d94 100644 (file)
@@ -348,15 +348,18 @@ xfs_corruption_error(
 void
 xfs_verifier_error(
        struct xfs_buf          *bp,
-       int                     error)
+       int                     error,
+       xfs_failaddr_t          failaddr)
 {
-       struct xfs_mount *mp = bp->b_target->bt_mount;
+       struct xfs_mount        *mp = bp->b_target->bt_mount;
+       xfs_failaddr_t          fa;
 
-       __xfs_buf_ioerror(bp, error, __return_address);
+       fa = failaddr ? failaddr : __return_address;
+       __xfs_buf_ioerror(bp, error, fa);
 
        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);
+                 fa, bp->b_ops->name, bp->b_bn);
 
        xfs_alert(mp, "Unmount and run xfs_repair");
 
index 598756281d8d701ef5e3db4fcabf4914359846d3..11f80e072403811c37be2575890baff381efe4ce 100644 (file)
@@ -25,7 +25,8 @@ 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, int error);
+extern void xfs_verifier_error(struct xfs_buf *bp, int error,
+                       xfs_failaddr_t failaddr);
 
 #define        XFS_ERROR_REPORT(e, lvl, mp)    \
        xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)