Commit 72c5c5f6 authored by Eric Sandeen's avatar Eric Sandeen Committed by Darrick J. Wong

xfs: print specific dqblk that failed verifiers

Rather than printing the top of the buffer that held a corrupted dqblk,
restructure things to print out the specific one that failed by pushing
the calls to the verifier_error function down into the verifier which
iterates over the buffer and detects the error.
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 7224fa48
...@@ -152,7 +152,8 @@ xfs_dqblk_repair( ...@@ -152,7 +152,8 @@ xfs_dqblk_repair(
STATIC bool STATIC bool
xfs_dquot_buf_verify_crc( xfs_dquot_buf_verify_crc(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_buf *bp) struct xfs_buf *bp,
bool readahead)
{ {
struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr; struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr;
int ndquots; int ndquots;
...@@ -173,8 +174,12 @@ xfs_dquot_buf_verify_crc( ...@@ -173,8 +174,12 @@ xfs_dquot_buf_verify_crc(
for (i = 0; i < ndquots; i++, d++) { for (i = 0; i < ndquots; i++, d++) {
if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk), if (!xfs_verify_cksum((char *)d, sizeof(struct xfs_dqblk),
XFS_DQUOT_CRC_OFF)) XFS_DQUOT_CRC_OFF)) {
if (!readahead)
xfs_buf_verifier_error(bp, -EFSBADCRC, __func__,
d, sizeof(*d), __this_address);
return false; return false;
}
} }
return true; return true;
} }
...@@ -182,7 +187,8 @@ xfs_dquot_buf_verify_crc( ...@@ -182,7 +187,8 @@ xfs_dquot_buf_verify_crc(
STATIC xfs_failaddr_t STATIC xfs_failaddr_t
xfs_dquot_buf_verify( xfs_dquot_buf_verify(
struct xfs_mount *mp, struct xfs_mount *mp,
struct xfs_buf *bp) struct xfs_buf *bp,
bool readahead)
{ {
struct xfs_dqblk *dqb = bp->b_addr; struct xfs_dqblk *dqb = bp->b_addr;
xfs_failaddr_t fa; xfs_failaddr_t fa;
...@@ -216,8 +222,13 @@ xfs_dquot_buf_verify( ...@@ -216,8 +222,13 @@ xfs_dquot_buf_verify(
id = be32_to_cpu(ddq->d_id); id = be32_to_cpu(ddq->d_id);
fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0); fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0);
if (fa) if (fa) {
if (!readahead)
xfs_buf_verifier_error(bp, -EFSCORRUPTED,
__func__, &dqb[i],
sizeof(struct xfs_dqblk), fa);
return fa; return fa;
}
} }
return NULL; return NULL;
...@@ -229,7 +240,7 @@ xfs_dquot_buf_verify_struct( ...@@ -229,7 +240,7 @@ xfs_dquot_buf_verify_struct(
{ {
struct xfs_mount *mp = bp->b_target->bt_mount; struct xfs_mount *mp = bp->b_target->bt_mount;
return xfs_dquot_buf_verify(mp, bp); return xfs_dquot_buf_verify(mp, bp, false);
} }
static void static void
...@@ -237,15 +248,10 @@ xfs_dquot_buf_read_verify( ...@@ -237,15 +248,10 @@ xfs_dquot_buf_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_dquot_buf_verify_crc(mp, bp)) if (!xfs_dquot_buf_verify_crc(mp, bp, false))
xfs_verifier_error(bp, -EFSBADCRC, __this_address); return;
else { xfs_dquot_buf_verify(mp, bp, false);
fa = xfs_dquot_buf_verify(mp, bp);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
}
} }
/* /*
...@@ -260,8 +266,8 @@ xfs_dquot_buf_readahead_verify( ...@@ -260,8 +266,8 @@ xfs_dquot_buf_readahead_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, true) ||
xfs_dquot_buf_verify(mp, bp) != NULL) { xfs_dquot_buf_verify(mp, bp, true) != NULL) {
xfs_buf_ioerror(bp, -EIO); xfs_buf_ioerror(bp, -EIO);
bp->b_flags &= ~XBF_DONE; bp->b_flags &= ~XBF_DONE;
} }
...@@ -277,11 +283,8 @@ xfs_dquot_buf_write_verify( ...@@ -277,11 +283,8 @@ xfs_dquot_buf_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;
fa = xfs_dquot_buf_verify(mp, bp); xfs_dquot_buf_verify(mp, bp, false);
if (fa)
xfs_verifier_error(bp, -EFSCORRUPTED, __this_address);
} }
const struct xfs_buf_ops xfs_dquot_buf_ops = { const struct xfs_buf_ops xfs_dquot_buf_ops = {
......
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