xfs: have buffer verifier functions report failing address

Modify each function that checks the contents of a metadata buffer to
return the instruction address of the failing test so that we can report
more precise failure errors to the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
Darrick J. Wong
2018-01-08 10:51:03 -08:00
parent 31ca03c92c
commit a6a781a58b
21 changed files with 323 additions and 275 deletions

View File

@@ -247,7 +247,7 @@ xfs_attr3_leaf_hdr_to_disk(
}
}
static bool
static xfs_failaddr_t
xfs_attr3_leaf_verify(
struct xfs_buf *bp)
{
@@ -262,17 +262,17 @@ xfs_attr3_leaf_verify(
struct xfs_da3_node_hdr *hdr3 = bp->b_addr;
if (ichdr.magic != XFS_ATTR3_LEAF_MAGIC)
return false;
return __this_address;
if (!uuid_equal(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid))
return false;
return __this_address;
if (be64_to_cpu(hdr3->info.blkno) != bp->b_bn)
return false;
return __this_address;
if (!xfs_log_check_lsn(mp, be64_to_cpu(hdr3->info.lsn)))
return false;
return __this_address;
} else {
if (ichdr.magic != XFS_ATTR_LEAF_MAGIC)
return false;
return __this_address;
}
/*
* In recovery there is a transient state where count == 0 is valid
@@ -280,12 +280,12 @@ xfs_attr3_leaf_verify(
* if the attr didn't fit in shortform.
*/
if (pag && pag->pagf_init && ichdr.count == 0)
return false;
return __this_address;
/* XXX: need to range check rest of attr header values */
/* XXX: hash order check? */
return true;
return NULL;
}
static void
@@ -296,7 +296,7 @@ xfs_attr3_leaf_write_verify(
struct xfs_buf_log_item *bip = bp->b_fspriv;
struct xfs_attr3_leaf_hdr *hdr3 = bp->b_addr;
if (!xfs_attr3_leaf_verify(bp)) {
if (xfs_attr3_leaf_verify(bp)) {
xfs_verifier_error(bp, -EFSCORRUPTED);
return;
}
@@ -325,7 +325,7 @@ xfs_attr3_leaf_read_verify(
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))
else if (xfs_attr3_leaf_verify(bp))
xfs_verifier_error(bp, -EFSCORRUPTED);
}