mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
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: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
parent
9101d3707b
commit
31ca03c92c
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 = {
|
||||
|
@ -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 = {
|
||||
|
@ -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);
|
||||
|
@ -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 = {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)",
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user