Commit bc1a09b8 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: refactor verifier callers to print address of failing check

Refactor the callers of verifiers to print the instruction address of a
failing check.
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent a6a781a5
...@@ -557,6 +557,7 @@ xfs_agfl_read_verify( ...@@ -557,6 +557,7 @@ xfs_agfl_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; 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 * There is no verification of non-crc AGFLs because mkfs does not
...@@ -568,9 +569,12 @@ xfs_agfl_read_verify( ...@@ -568,9 +569,12 @@ 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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_agfl_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_agfl_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -579,13 +583,15 @@ xfs_agfl_write_verify( ...@@ -579,13 +583,15 @@ xfs_agfl_write_verify(
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
xfs_failaddr_t fa;
/* no verification of non-crc AGFLs */ /* no verification of non-crc AGFLs */
if (!xfs_sb_version_hascrc(&mp->m_sb)) if (!xfs_sb_version_hascrc(&mp->m_sb))
return; return;
if (xfs_agfl_verify(bp)) { fa = xfs_agfl_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
...@@ -2455,13 +2461,16 @@ xfs_agf_read_verify( ...@@ -2455,13 +2461,16 @@ xfs_agf_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (XFS_TEST_ERROR(xfs_agf_verify(mp, bp), mp, else {
XFS_ERRTAG_ALLOC_READ_AGF)) fa = xfs_agf_verify(mp, bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_ALLOC_READ_AGF))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -2470,9 +2479,11 @@ xfs_agf_write_verify( ...@@ -2470,9 +2479,11 @@ xfs_agf_write_verify(
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
xfs_failaddr_t fa;
if (xfs_agf_verify(mp, bp)) { fa = xfs_agf_verify(mp, bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
......
...@@ -366,10 +366,15 @@ static void ...@@ -366,10 +366,15 @@ static void
xfs_allocbt_read_verify( xfs_allocbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
xfs_failaddr_t fa;
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_allocbt_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_allocbt_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
if (bp->b_error) if (bp->b_error)
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -379,9 +384,12 @@ static void ...@@ -379,9 +384,12 @@ static void
xfs_allocbt_write_verify( xfs_allocbt_write_verify(
struct xfs_buf *bp) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -295,9 +295,11 @@ xfs_attr3_leaf_write_verify( ...@@ -295,9 +295,11 @@ xfs_attr3_leaf_write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr; struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
xfs_failaddr_t fa;
if (xfs_attr3_leaf_verify(bp)) { fa = xfs_attr3_leaf_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
...@@ -321,12 +323,16 @@ xfs_attr3_leaf_read_verify( ...@@ -321,12 +323,16 @@ xfs_attr3_leaf_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_attr3_leaf_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_attr3_leaf_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = { const struct xfs_buf_ops xfs_attr3_leaf_buf_ops = {
......
...@@ -122,6 +122,7 @@ xfs_attr3_rmt_read_verify( ...@@ -122,6 +122,7 @@ xfs_attr3_rmt_read_verify(
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
char *ptr; char *ptr;
xfs_failaddr_t fa;
int len; int len;
xfs_daddr_t bno; xfs_daddr_t bno;
int blksize = mp->m_attr_geo->blksize; int blksize = mp->m_attr_geo->blksize;
...@@ -137,12 +138,13 @@ xfs_attr3_rmt_read_verify( ...@@ -137,12 +138,13 @@ 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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
return; return;
} }
if (xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) { fa = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
return; xfs_verifier_error(bp, -EFSCORRUPTED, fa);
break;
} }
len -= blksize; len -= blksize;
ptr += blksize; ptr += blksize;
...@@ -150,7 +152,7 @@ xfs_attr3_rmt_read_verify( ...@@ -150,7 +152,7 @@ xfs_attr3_rmt_read_verify(
} }
if (len != 0) if (len != 0)
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
} }
static void static void
...@@ -158,6 +160,7 @@ xfs_attr3_rmt_write_verify( ...@@ -158,6 +160,7 @@ xfs_attr3_rmt_write_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
int blksize = mp->m_attr_geo->blksize; int blksize = mp->m_attr_geo->blksize;
char *ptr; char *ptr;
int len; int len;
...@@ -175,8 +178,9 @@ xfs_attr3_rmt_write_verify( ...@@ -175,8 +178,9 @@ xfs_attr3_rmt_write_verify(
while (len > 0) { while (len > 0) {
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)) { fa = xfs_attr3_rmt_verify(mp, ptr, blksize, bno);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
...@@ -185,7 +189,7 @@ xfs_attr3_rmt_write_verify( ...@@ -185,7 +189,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_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
return; return;
} }
xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF); xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
...@@ -196,7 +200,7 @@ xfs_attr3_rmt_write_verify( ...@@ -196,7 +200,7 @@ xfs_attr3_rmt_write_verify(
} }
if (len != 0) 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 = { const struct xfs_buf_ops xfs_attr3_rmt_buf_ops = {
......
...@@ -468,10 +468,15 @@ static void ...@@ -468,10 +468,15 @@ static void
xfs_bmbt_read_verify( xfs_bmbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
xfs_failaddr_t fa;
if (!xfs_btree_lblock_verify_crc(bp)) if (!xfs_btree_lblock_verify_crc(bp))
xfs_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_bmbt_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_bmbt_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
if (bp->b_error) if (bp->b_error)
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -481,9 +486,12 @@ static void ...@@ -481,9 +486,12 @@ static void
xfs_bmbt_write_verify( xfs_bmbt_write_verify(
struct xfs_buf *bp) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
xfs_btree_lblock_calc_crc(bp); xfs_btree_lblock_calc_crc(bp);
......
...@@ -184,9 +184,11 @@ xfs_da3_node_write_verify( ...@@ -184,9 +184,11 @@ xfs_da3_node_write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
struct xfs_da3_node_hdr *hdr3 = bp->b_addr; struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
xfs_failaddr_t fa;
if (xfs_da3_node_verify(bp)) { fa = xfs_da3_node_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
...@@ -210,17 +212,20 @@ xfs_da3_node_read_verify( ...@@ -210,17 +212,20 @@ xfs_da3_node_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_da_blkinfo *info = bp->b_addr; struct xfs_da_blkinfo *info = bp->b_addr;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC,
__this_address);
break; break;
} }
/* fall through */ /* fall through */
case XFS_DA_NODE_MAGIC: case XFS_DA_NODE_MAGIC:
if (xfs_da3_node_verify(bp)) fa = xfs_da3_node_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
case XFS_ATTR_LEAF_MAGIC: case XFS_ATTR_LEAF_MAGIC:
case XFS_ATTR3_LEAF_MAGIC: case XFS_ATTR3_LEAF_MAGIC:
...@@ -233,7 +238,7 @@ xfs_da3_node_read_verify( ...@@ -233,7 +238,7 @@ xfs_da3_node_read_verify(
bp->b_ops->verify_read(bp); bp->b_ops->verify_read(bp);
return; return;
default: default:
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
break; break;
} }
} }
......
...@@ -86,12 +86,16 @@ xfs_dir3_block_read_verify( ...@@ -86,12 +86,16 @@ xfs_dir3_block_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_dir3_block_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_dir3_block_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -101,9 +105,11 @@ xfs_dir3_block_write_verify( ...@@ -101,9 +105,11 @@ xfs_dir3_block_write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
xfs_failaddr_t fa;
if (xfs_dir3_block_verify(bp)) { fa = xfs_dir3_block_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
......
...@@ -284,7 +284,7 @@ xfs_dir3_data_reada_verify( ...@@ -284,7 +284,7 @@ xfs_dir3_data_reada_verify(
bp->b_ops->verify_read(bp); bp->b_ops->verify_read(bp);
return; return;
default: default:
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
break; break;
} }
} }
...@@ -294,12 +294,16 @@ xfs_dir3_data_read_verify( ...@@ -294,12 +294,16 @@ xfs_dir3_data_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_dir3_data_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_dir3_data_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -309,9 +313,11 @@ xfs_dir3_data_write_verify( ...@@ -309,9 +313,11 @@ xfs_dir3_data_write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
xfs_failaddr_t fa;
if (xfs_dir3_data_verify(bp)) { fa = xfs_dir3_data_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
......
...@@ -190,12 +190,16 @@ __read_verify( ...@@ -190,12 +190,16 @@ __read_verify(
uint16_t magic) uint16_t magic)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_dir3_leaf_verify(bp, magic)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_dir3_leaf_verify(bp, magic);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -206,9 +210,11 @@ __write_verify( ...@@ -206,9 +210,11 @@ __write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr; struct xfs_dir3_leaf_hdr *hdr3 = bp->b_addr;
xfs_failaddr_t fa;
if (xfs_dir3_leaf_verify(bp, magic)) { fa = xfs_dir3_leaf_verify(bp, magic);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
......
...@@ -124,12 +124,16 @@ xfs_dir3_free_read_verify( ...@@ -124,12 +124,16 @@ xfs_dir3_free_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_dir3_free_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_dir3_free_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -139,9 +143,11 @@ xfs_dir3_free_write_verify( ...@@ -139,9 +143,11 @@ xfs_dir3_free_write_verify(
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr; struct xfs_dir3_blk_hdr *hdr3 = bp->b_addr;
xfs_failaddr_t fa;
if (xfs_dir3_free_verify(bp)) { fa = xfs_dir3_free_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
...@@ -161,7 +167,7 @@ const struct xfs_buf_ops xfs_dir3_free_buf_ops = { ...@@ -161,7 +167,7 @@ const struct xfs_buf_ops xfs_dir3_free_buf_ops = {
}; };
/* Everything ok in the free block header? */ /* Everything ok in the free block header? */
static bool static xfs_failaddr_t
xfs_dir3_free_header_check( xfs_dir3_free_header_check(
struct xfs_inode *dp, struct xfs_inode *dp,
xfs_dablk_t fbno, xfs_dablk_t fbno,
...@@ -205,6 +211,7 @@ __xfs_dir3_free_read( ...@@ -205,6 +211,7 @@ __xfs_dir3_free_read(
xfs_daddr_t mappedbno, xfs_daddr_t mappedbno,
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
xfs_failaddr_t fa;
int err; int err;
err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp, err = xfs_da_read_buf(tp, dp, fbno, mappedbno, bpp,
...@@ -213,8 +220,9 @@ __xfs_dir3_free_read( ...@@ -213,8 +220,9 @@ __xfs_dir3_free_read(
return err; return err;
/* 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)) { fa = xfs_dir3_free_header_check(dp, fbno, *bpp);
xfs_verifier_error(*bpp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(*bpp, -EFSCORRUPTED, fa);
xfs_trans_brelse(tp, *bpp); xfs_trans_brelse(tp, *bpp);
return -EFSCORRUPTED; return -EFSCORRUPTED;
} }
......
...@@ -249,9 +249,9 @@ xfs_dquot_buf_read_verify( ...@@ -249,9 +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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (!xfs_dquot_buf_verify(mp, bp, XFS_QMOPT_DOWARN)) 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( ...@@ -285,7 +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_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
return; return;
} }
} }
......
...@@ -2541,13 +2541,16 @@ xfs_agi_read_verify( ...@@ -2541,13 +2541,16 @@ xfs_agi_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
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_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (XFS_TEST_ERROR(xfs_agi_verify(bp), mp, else {
XFS_ERRTAG_IALLOC_READ_AGI)) fa = xfs_agi_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (XFS_TEST_ERROR(fa, mp, XFS_ERRTAG_IALLOC_READ_AGI))
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -2556,9 +2559,11 @@ xfs_agi_write_verify( ...@@ -2556,9 +2559,11 @@ xfs_agi_write_verify(
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
xfs_failaddr_t fa;
if (xfs_agi_verify(bp)) { fa = xfs_agi_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
......
...@@ -295,10 +295,15 @@ static void ...@@ -295,10 +295,15 @@ static void
xfs_inobt_read_verify( xfs_inobt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
xfs_failaddr_t fa;
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_inobt_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_inobt_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
if (bp->b_error) if (bp->b_error)
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -308,9 +313,12 @@ static void ...@@ -308,9 +313,12 @@ static void
xfs_inobt_write_verify( xfs_inobt_write_verify(
struct xfs_buf *bp) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -113,7 +113,7 @@ xfs_inode_buf_verify( ...@@ -113,7 +113,7 @@ xfs_inode_buf_verify(
return; return;
} }
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
#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)",
......
...@@ -256,10 +256,15 @@ STATIC void ...@@ -256,10 +256,15 @@ STATIC void
xfs_refcountbt_read_verify( xfs_refcountbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
xfs_failaddr_t fa;
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_refcountbt_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_refcountbt_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
if (bp->b_error) if (bp->b_error)
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -269,9 +274,12 @@ STATIC void ...@@ -269,9 +274,12 @@ STATIC void
xfs_refcountbt_write_verify( xfs_refcountbt_write_verify(
struct xfs_buf *bp) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -348,10 +348,15 @@ static void ...@@ -348,10 +348,15 @@ static void
xfs_rmapbt_read_verify( xfs_rmapbt_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
xfs_failaddr_t fa;
if (!xfs_btree_sblock_verify_crc(bp)) if (!xfs_btree_sblock_verify_crc(bp))
xfs_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_rmapbt_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_rmapbt_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
if (bp->b_error) if (bp->b_error)
trace_xfs_btree_corrupt(bp, _RET_IP_); trace_xfs_btree_corrupt(bp, _RET_IP_);
...@@ -361,9 +366,12 @@ static void ...@@ -361,9 +366,12 @@ static void
xfs_rmapbt_write_verify( xfs_rmapbt_write_verify(
struct xfs_buf *bp) 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_); trace_xfs_btree_corrupt(bp, _RET_IP_);
xfs_verifier_error(bp, -EFSCORRUPTED); xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
xfs_btree_sblock_calc_crc(bp); xfs_btree_sblock_calc_crc(bp);
......
...@@ -641,7 +641,7 @@ xfs_sb_read_verify( ...@@ -641,7 +641,7 @@ xfs_sb_read_verify(
out_error: out_error:
if (error == -EFSCORRUPTED || error == -EFSBADCRC) if (error == -EFSCORRUPTED || error == -EFSBADCRC)
xfs_verifier_error(bp, error); xfs_verifier_error(bp, error, __this_address);
else if (error) else if (error)
xfs_buf_ioerror(bp, error); xfs_buf_ioerror(bp, error);
} }
...@@ -677,7 +677,7 @@ xfs_sb_write_verify( ...@@ -677,7 +677,7 @@ xfs_sb_write_verify(
error = xfs_sb_verify(bp, false); error = xfs_sb_verify(bp, false);
if (error) { if (error) {
xfs_verifier_error(bp, error); xfs_verifier_error(bp, error, __this_address);
return; return;
} }
......
...@@ -129,15 +129,19 @@ xfs_symlink_read_verify( ...@@ -129,15 +129,19 @@ xfs_symlink_read_verify(
struct xfs_buf *bp) struct xfs_buf *bp)
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
xfs_failaddr_t fa;
/* no verification of non-crc buffers */ /* no verification of non-crc buffers */
if (!xfs_sb_version_hascrc(&mp->m_sb)) if (!xfs_sb_version_hascrc(&mp->m_sb))
return; return;
if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF)) if (!xfs_buf_verify_cksum(bp, XFS_SYMLINK_CRC_OFF))
xfs_verifier_error(bp, -EFSBADCRC); xfs_verifier_error(bp, -EFSBADCRC, __this_address);
else if (xfs_symlink_verify(bp)) else {
xfs_verifier_error(bp, -EFSCORRUPTED); fa = xfs_symlink_verify(bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
}
} }
static void static void
...@@ -146,13 +150,15 @@ xfs_symlink_write_verify( ...@@ -146,13 +150,15 @@ xfs_symlink_write_verify(
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
struct xfs_buf_log_item *bip = bp->b_fspriv; struct xfs_buf_log_item *bip = bp->b_fspriv;
xfs_failaddr_t fa;
/* no verification of non-crc buffers */ /* no verification of non-crc buffers */
if (!xfs_sb_version_hascrc(&mp->m_sb)) if (!xfs_sb_version_hascrc(&mp->m_sb))
return; return;
if (xfs_symlink_verify(bp)) { fa = xfs_symlink_verify(bp);
xfs_verifier_error(bp, -EFSCORRUPTED); if (fa) {
xfs_verifier_error(bp, -EFSCORRUPTED, fa);
return; return;
} }
......
...@@ -348,15 +348,18 @@ xfs_corruption_error( ...@@ -348,15 +348,18 @@ xfs_corruption_error(
void void
xfs_verifier_error( xfs_verifier_error(
struct xfs_buf *bp, 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", 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); fa, bp->b_ops->name, bp->b_bn);
xfs_alert(mp, "Unmount and run xfs_repair"); xfs_alert(mp, "Unmount and run xfs_repair");
......
...@@ -25,7 +25,8 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, ...@@ -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, 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, int error); extern void xfs_verifier_error(struct xfs_buf *bp, int error,
xfs_failaddr_t failaddr);
#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)
......
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