Commit 31ca03c9 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: refactor xfs_verifier_error and xfs_buf_ioerror

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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 9101d370
...@@ -567,12 +567,9 @@ xfs_agfl_read_verify( ...@@ -567,12 +567,9 @@ xfs_agfl_read_verify(
return; return;
if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF)) 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)) else if (!xfs_agfl_verify(bp))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -587,8 +584,7 @@ xfs_agfl_write_verify( ...@@ -587,8 +584,7 @@ xfs_agfl_write_verify(
return; return;
if (!xfs_agfl_verify(bp)) { if (!xfs_agfl_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
...@@ -2461,13 +2457,10 @@ xfs_agf_read_verify( ...@@ -2461,13 +2457,10 @@ xfs_agf_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF)) !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, else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp,
XFS_ERRTAG_ALLOC_READ_AGF)) XFS_ERRTAG_ALLOC_READ_AGF))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -2478,8 +2471,7 @@ xfs_agf_write_verify( ...@@ -2478,8 +2471,7 @@ xfs_agf_write_verify(
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
if (!xfs_agf_verify(mp, bp)) { if (!xfs_agf_verify(mp, bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
......
...@@ -364,14 +364,12 @@ xfs_allocbt_read_verify( ...@@ -364,14 +364,12 @@ xfs_allocbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
else if (!xfs_allocbt_verify(bp)) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp);
}
} }
static void static void
...@@ -380,8 +378,7 @@ xfs_allocbt_write_verify( ...@@ -380,8 +378,7 @@ xfs_allocbt_write_verify(
{ {
if (!xfs_allocbt_verify(bp)) { if (!xfs_allocbt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -297,8 +297,7 @@ xfs_attr3_leaf_write_verify( ...@@ -297,8 +297,7 @@ xfs_attr3_leaf_write_verify(
struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr; struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
if (!xfs_attr3_leaf_verify(bp)) { if (!xfs_attr3_leaf_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
...@@ -325,12 +324,9 @@ xfs_attr3_leaf_read_verify( ...@@ -325,12 +324,9 @@ xfs_attr3_leaf_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_ATTR3_LEAF_CRC_OFF)) !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)) else if (!xfs_attr3_leaf_verify(bp))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = { const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
......
...@@ -137,22 +137,20 @@ xfs_attr3_rmt_read_verify( ...@@ -137,22 +137,20 @@ xfs_attr3_rmt_read_verify(
while (len > 0) { while (len > 0) {
if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) { if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
break; return;
} }
if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) { if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
break; return;
} }
len -= blksize; len -= blksize;
ptr += blksize; ptr += blksize;
bno += BTOBB(blksize); bno += BTOBB(blksize);
} }
if (bp->b_error) if (len != 0)
xfs_verifier_error(bp); xfs_verifier_error(bp, -EFSCORRUPTED);
else
ASSERT(len == 0);
} }
static void static void
...@@ -178,8 +176,7 @@ xfs_attr3_rmt_write_verify( ...@@ -178,8 +176,7 @@ xfs_attr3_rmt_write_verify(
struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr; struct xfs_attr3_rmt_hdr *rmt = (struct xfs_attr3_rmt_hdr *)ptr;
if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) { if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
...@@ -188,8 +185,7 @@ xfs_attr3_rmt_write_verify( ...@@ -188,8 +185,7 @@ xfs_attr3_rmt_write_verify(
* xfs_attr3_rmt_hdr_set() for the explanation. * xfs_attr3_rmt_hdr_set() for the explanation.
*/ */
if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) { if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF); xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
...@@ -198,7 +194,9 @@ xfs_attr3_rmt_write_verify( ...@@ -198,7 +194,9 @@ xfs_attr3_rmt_write_verify(
ptr += blksize; ptr += blksize;
bno += BTOBB(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 = { const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
......
...@@ -467,14 +467,12 @@ xfs_bmbt_read_verify( ...@@ -467,14 +467,12 @@ xfs_bmbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_lblock_verify_crc(bp)) if (!xfs_btree_lblock_verify_crc(bp))
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
else if (!xfs_bmbt_verify(bp)) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp);
}
} }
static void static void
...@@ -483,8 +481,7 @@ xfs_bmbt_write_verify( ...@@ -483,8 +481,7 @@ xfs_bmbt_write_verify(
{ {
if (!xfs_bmbt_verify(bp)) { if (!xfs_bmbt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
xfs_btree_lblock_calc_crc(bp); xfs_btree_lblock_calc_crc(bp);
......
...@@ -186,8 +186,7 @@ xfs_da3_node_write_verify( ...@@ -186,8 +186,7 @@ xfs_da3_node_write_verify(
struct xfs_da3_node_hdr *hdr3 = bp->b_addr; struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
if (!xfs_da3_node_verify(bp)) { if (!xfs_da3_node_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
...@@ -215,15 +214,13 @@ xfs_da3_node_read_verify( ...@@ -215,15 +214,13 @@ xfs_da3_node_read_verify(
switch (be16_to_cpu(info->magic)) { switch (be16_to_cpu(info->magic)) {
case XFS_DA3_NODE_MAGIC: case XFS_DA3_NODE_MAGIC:
if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) { if (!xfs_buf_verify_cksum(bp, XFS_DA3_NODE_CRC_OFF)) {
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
break; break;
} }
/* fall through */ /* fall through */
case XFS_DA_NODE_MAGIC: case XFS_DA_NODE_MAGIC:
if (!xfs_da3_node_verify(bp)) { if (!xfs_da3_node_verify(bp))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
break;
}
return; return;
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
case XFS_ATTR3_LEAF_MAGIC: case XFS_ATTR3_LEAF_MAGIC:
...@@ -236,12 +233,9 @@ xfs_da3_node_read_verify( ...@@ -236,12 +233,9 @@ xfs_da3_node_read_verify(
bp->b_ops->verify_read(bp); bp->b_ops->verify_read(bp);
return; return;
default: default:
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
break; break;
} }
/* corrupt block */
xfs_verifier_error(bp);
} }
const struct xfs_buf_ops xfs_da3_node_buf_ops = { const struct xfs_buf_ops xfs_da3_node_buf_ops = {
......
...@@ -89,12 +89,9 @@ xfs_dir3_block_read_verify( ...@@ -89,12 +89,9 @@ xfs_dir3_block_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) !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)) else if (!xfs_dir3_block_verify(bp))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -106,8 +103,7 @@ xfs_dir3_block_write_verify( ...@@ -106,8 +103,7 @@ xfs_dir3_block_write_verify(
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_block_verify(bp)) { if (!xfs_dir3_block_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
......
...@@ -267,8 +267,7 @@ xfs_dir3_data_reada_verify( ...@@ -267,8 +267,7 @@ xfs_dir3_data_reada_verify(
bp->b_ops->verify_read(bp); bp->b_ops->verify_read(bp);
return; return;
default: default:
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
break; break;
} }
} }
...@@ -280,13 +279,10 @@ xfs_dir3_data_read_verify( ...@@ -280,13 +279,10 @@ xfs_dir3_data_read_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF)) !xfs_buf_verify_cksum(bp, XFS_DIR3_DATA_CRC_OFF))
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
else if (!xfs_dir3_data_verify(bp)) else if (!xfs_dir3_data_verify(bp))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -298,8 +294,7 @@ xfs_dir3_data_write_verify( ...@@ -298,8 +294,7 @@ xfs_dir3_data_write_verify(
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_data_verify(bp)) { if (!xfs_dir3_data_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
......
...@@ -184,12 +184,9 @@ __read_verify( ...@@ -184,12 +184,9 @@ __read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_LEAF_CRC_OFF)) !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)) else if (!xfs_dir3_leaf_verify(bp, magic))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -202,8 +199,7 @@ __write_verify( ...@@ -202,8 +199,7 @@ __write_verify(
struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr; struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_leaf_verify(bp, magic)) { if (!xfs_dir3_leaf_verify(bp, magic)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
......
...@@ -118,12 +118,9 @@ xfs_dir3_free_read_verify( ...@@ -118,12 +118,9 @@ xfs_dir3_free_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_DIR3_FREE_CRC_OFF)) !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)) else if (!xfs_dir3_free_verify(bp))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -135,8 +132,7 @@ xfs_dir3_free_write_verify( ...@@ -135,8 +132,7 @@ xfs_dir3_free_write_verify(
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
if (!xfs_dir3_free_verify(bp)) { if (!xfs_dir3_free_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
...@@ -209,8 +205,7 @@ __xfs_dir3_free_read( ...@@ -209,8 +205,7 @@ __xfs_dir3_free_read(
/* Check things that we can't do in the verifier. */ /* Check things that we can't do in the verifier. */
if (!xfs_dir3_free_header_check(dp, fbno, *bpp)) { if (!xfs_dir3_free_header_check(dp, fbno, *bpp)) {
xfs_buf_ioerror(*bpp, -EFSCORRUPTED); xfs_verifier_error(*bpp, -EFSCORRUPTED);
xfs_verifier_error(*bpp);
xfs_trans_brelse(tp, *bpp); xfs_trans_brelse(tp, *bpp);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
......
...@@ -249,12 +249,9 @@ xfs_dquot_buf_read_verify( ...@@ -249,12 +249,9 @@ xfs_dquot_buf_read_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
if (!xfs_dquot_buf_verify_crc(mp, bp)) 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)) else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
/* /*
...@@ -288,8 +285,7 @@ xfs_dquot_buf_write_verify( ...@@ -288,8 +285,7 @@ xfs_dquot_buf_write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) { if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
} }
......
...@@ -2544,13 +2544,10 @@ xfs_agi_read_verify( ...@@ -2544,13 +2544,10 @@ xfs_agi_read_verify(
if (xfs_sb_version_hascrc(&mp->m_sb) && if (xfs_sb_version_hascrc(&mp->m_sb) &&
!xfs_buf_verify_cksum(bp, XFS_AGI_CRC_OFF)) !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, else if (XFS_TEST_ERROR(!xfs_agi_verify(bp), mp,
XFS_ERRTAG_IALLOC_READ_AGI)) XFS_ERRTAG_IALLOC_READ_AGI))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -2561,8 +2558,7 @@ xfs_agi_write_verify( ...@@ -2561,8 +2558,7 @@ xfs_agi_write_verify(
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
if (!xfs_agi_verify(bp)) { if (!xfs_agi_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
......
...@@ -294,14 +294,12 @@ xfs_inobt_read_verify( ...@@ -294,14 +294,12 @@ xfs_inobt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
else if (!xfs_inobt_verify(bp)) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp);
}
} }
static void static void
...@@ -310,8 +308,7 @@ xfs_inobt_write_verify( ...@@ -310,8 +308,7 @@ xfs_inobt_write_verify(
{ {
if (!xfs_inobt_verify(bp)) { if (!xfs_inobt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -113,8 +113,7 @@ xfs_inode_buf_verify( ...@@ -113,8 +113,7 @@ xfs_inode_buf_verify(
return; return;
} }
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
#ifdef DEBUG #ifdef DEBUG
xfs_alert(mp, xfs_alert(mp,
"bad inode magic/vsn daddr %lld #%d (magic=%x)", "bad inode magic/vsn daddr %lld #%d (magic=%x)",
......
...@@ -255,14 +255,12 @@ xfs_refcountbt_read_verify( ...@@ -255,14 +255,12 @@ xfs_refcountbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
else if (!xfs_refcountbt_verify(bp)) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp);
}
} }
STATIC void STATIC void
...@@ -271,8 +269,7 @@ xfs_refcountbt_write_verify( ...@@ -271,8 +269,7 @@ xfs_refcountbt_write_verify(
{ {
if (!xfs_refcountbt_verify(bp)) { if (!xfs_refcountbt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -347,14 +347,12 @@ xfs_rmapbt_read_verify( ...@@ -347,14 +347,12 @@ xfs_rmapbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_buf_ioerror(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC);
else if (!xfs_rmapbt_verify(bp)) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp);
}
} }
static void static void
...@@ -363,8 +361,7 @@ xfs_rmapbt_write_verify( ...@@ -363,8 +361,7 @@ xfs_rmapbt_write_verify(
{ {
if (!xfs_rmapbt_verify(bp)) { if (!xfs_rmapbt_verify(bp)) {
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -640,11 +640,10 @@ xfs_sb_read_verify( ...@@ -640,11 +640,10 @@ xfs_sb_read_verify(
error = xfs_sb_verify(bp, true); error = xfs_sb_verify(bp, true);
out_error: out_error:
if (error) { if (error == -EFSCORRUPTED || error == -EFSBADCRC)
xfs_verifier_error(bp, error);
else if (error)
xfs_buf_ioerror(bp, error); xfs_buf_ioerror(bp, error);
if (error == -EFSCORRUPTED || error == -EFSBADCRC)
xfs_verifier_error(bp);
}
} }
/* /*
...@@ -678,8 +677,7 @@ xfs_sb_write_verify( ...@@ -678,8 +677,7 @@ xfs_sb_write_verify(
error = xfs_sb_verify(bp, false); error = xfs_sb_verify(bp, false);
if (error) { if (error) {
xfs_buf_ioerror(bp, error); xfs_verifier_error(bp, error);
xfs_verifier_error(bp);
return; return;
} }
......
...@@ -135,12 +135,9 @@ xfs_symlink_read_verify( ...@@ -135,12 +135,9 @@ xfs_symlink_read_verify(
return; return;
if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF)) 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)) else if (!xfs_symlink_verify(bp))
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
if (bp->b_error)
xfs_verifier_error(bp);
} }
static void static void
...@@ -155,8 +152,7 @@ xfs_symlink_write_verify( ...@@ -155,8 +152,7 @@ xfs_symlink_write_verify(
return; return;
if (!xfs_symlink_verify(bp)) { if (!xfs_symlink_verify(bp)) {
xfs_buf_ioerror(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED);
xfs_verifier_error(bp);
return; return;
} }
......
...@@ -1180,13 +1180,14 @@ xfs_buf_ioend_async( ...@@ -1180,13 +1180,14 @@ xfs_buf_ioend_async(
} }
void void
xfs_buf_ioerror( __xfs_buf_ioerror(
xfs_buf_t *bp, xfs_buf_t *bp,
int error) int error,
xfs_failaddr_t failaddr)
{ {
ASSERT(error <= 0 && error >= -1000); ASSERT(error <= 0 && error >= -1000);
bp->b_error = error; bp->b_error = error;
trace_xfs_buf_ioerror(bp, error, _RET_IP_); trace_xfs_buf_ioerror(bp, error, failaddr);
} }
void void
......
...@@ -315,7 +315,9 @@ extern void xfs_buf_unlock(xfs_buf_t *); ...@@ -315,7 +315,9 @@ extern void xfs_buf_unlock(xfs_buf_t *);
/* Buffer Read and Write Routines */ /* Buffer Read and Write Routines */
extern int xfs_bwrite(struct xfs_buf *bp); extern int xfs_bwrite(struct xfs_buf *bp);
extern void xfs_buf_ioend(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_ioerror_alert(struct xfs_buf *, const char *func);
extern void xfs_buf_submit(struct xfs_buf *bp); extern void xfs_buf_submit(struct xfs_buf *bp);
extern int xfs_buf_submit_wait(struct xfs_buf *bp); extern int xfs_buf_submit_wait(struct xfs_buf *bp);
......
...@@ -347,10 +347,13 @@ xfs_corruption_error( ...@@ -347,10 +347,13 @@ xfs_corruption_error(
*/ */
void void
xfs_verifier_error( xfs_verifier_error(
struct xfs_buf *bp) struct xfs_buf *bp,
int error)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; 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", xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx",
bp->b_error == -EFSBADCRC ? "CRC error" : "corruption", bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
__return_address, bp->b_ops->name, bp->b_bn); __return_address, bp->b_ops->name, bp->b_bn);
......
...@@ -25,7 +25,7 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, ...@@ -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, extern void xfs_corruption_error(const char *tag, int level,
struct xfs_mount *mp, void *p, const char *filename, struct xfs_mount *mp, void *p, const char *filename,
int linenum, void *ra); 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) \ #define XFS_ERROR_REPORT(e, lvl, mp) \
xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
......
...@@ -390,7 +390,7 @@ DEFINE_BUF_FLAGS_EVENT(xfs_buf_get); ...@@ -390,7 +390,7 @@ DEFINE_BUF_FLAGS_EVENT(xfs_buf_get);
DEFINE_BUF_FLAGS_EVENT(xfs_buf_read); DEFINE_BUF_FLAGS_EVENT(xfs_buf_read);
TRACE_EVENT(xfs_buf_ioerror, 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_ARGS(bp, error, caller_ip),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(dev_t, dev) __field(dev_t, dev)
...@@ -401,7 +401,7 @@ TRACE_EVENT(xfs_buf_ioerror, ...@@ -401,7 +401,7 @@ TRACE_EVENT(xfs_buf_ioerror,
__field(int, pincount) __field(int, pincount)
__field(unsigned, lockval) __field(unsigned, lockval)
__field(int, error) __field(int, error)
__field(unsigned long, caller_ip) __field(xfs_failaddr_t, caller_ip)
), ),
TP_fast_assign( TP_fast_assign(
__entry->dev = bp->b_target->bt_dev; __entry->dev = bp->b_target->bt_dev;
...@@ -415,7 +415,7 @@ TRACE_EVENT(xfs_buf_ioerror, ...@@ -415,7 +415,7 @@ TRACE_EVENT(xfs_buf_ioerror,
__entry->caller_ip = caller_ip; __entry->caller_ip = caller_ip;
), ),
TP_printk("dev %d:%d bno 0x%llx len 0x%zx hold %d pincount %d " 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), MAJOR(__entry->dev), MINOR(__entry->dev),
(unsigned long long)__entry->bno, (unsigned long long)__entry->bno,
__entry->buffer_length, __entry->buffer_length,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment