diff options
Diffstat (limited to 'fs/xfs/xfs_alloc.c')
-rw-r--r-- | fs/xfs/xfs_alloc.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c index 9eab2dfdcbb5..c1cf6a336a72 100644 --- a/fs/xfs/xfs_alloc.c +++ b/fs/xfs/xfs_alloc.c | |||
@@ -474,7 +474,6 @@ xfs_agfl_read_verify( | |||
474 | struct xfs_buf *bp) | 474 | struct xfs_buf *bp) |
475 | { | 475 | { |
476 | struct xfs_mount *mp = bp->b_target->bt_mount; | 476 | struct xfs_mount *mp = bp->b_target->bt_mount; |
477 | int agfl_ok = 1; | ||
478 | 477 | ||
479 | /* | 478 | /* |
480 | * There is no verification of non-crc AGFLs because mkfs does not | 479 | * There is no verification of non-crc AGFLs because mkfs does not |
@@ -485,15 +484,13 @@ xfs_agfl_read_verify( | |||
485 | if (!xfs_sb_version_hascrc(&mp->m_sb)) | 484 | if (!xfs_sb_version_hascrc(&mp->m_sb)) |
486 | return; | 485 | return; |
487 | 486 | ||
488 | agfl_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | 487 | if (!xfs_buf_verify_cksum(bp, XFS_AGFL_CRC_OFF)) |
489 | offsetof(struct xfs_agfl, agfl_crc)); | 488 | xfs_buf_ioerror(bp, EFSBADCRC); |
490 | 489 | else if (!xfs_agfl_verify(bp)) | |
491 | agfl_ok = agfl_ok && xfs_agfl_verify(bp); | ||
492 | |||
493 | if (!agfl_ok) { | ||
494 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr); | ||
495 | xfs_buf_ioerror(bp, EFSCORRUPTED); | 490 | xfs_buf_ioerror(bp, EFSCORRUPTED); |
496 | } | 491 | |
492 | if (bp->b_error) | ||
493 | xfs_verifier_error(bp); | ||
497 | } | 494 | } |
498 | 495 | ||
499 | static void | 496 | static void |
@@ -508,16 +505,15 @@ xfs_agfl_write_verify( | |||
508 | return; | 505 | return; |
509 | 506 | ||
510 | if (!xfs_agfl_verify(bp)) { | 507 | if (!xfs_agfl_verify(bp)) { |
511 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr); | ||
512 | xfs_buf_ioerror(bp, EFSCORRUPTED); | 508 | xfs_buf_ioerror(bp, EFSCORRUPTED); |
509 | xfs_verifier_error(bp); | ||
513 | return; | 510 | return; |
514 | } | 511 | } |
515 | 512 | ||
516 | if (bip) | 513 | if (bip) |
517 | XFS_BUF_TO_AGFL(bp)->agfl_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 514 | XFS_BUF_TO_AGFL(bp)->agfl_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
518 | 515 | ||
519 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | 516 | xfs_buf_update_cksum(bp, XFS_AGFL_CRC_OFF); |
520 | offsetof(struct xfs_agfl, agfl_crc)); | ||
521 | } | 517 | } |
522 | 518 | ||
523 | const struct xfs_buf_ops xfs_agfl_buf_ops = { | 519 | const struct xfs_buf_ops xfs_agfl_buf_ops = { |
@@ -2238,19 +2234,17 @@ xfs_agf_read_verify( | |||
2238 | struct xfs_buf *bp) | 2234 | struct xfs_buf *bp) |
2239 | { | 2235 | { |
2240 | struct xfs_mount *mp = bp->b_target->bt_mount; | 2236 | struct xfs_mount *mp = bp->b_target->bt_mount; |
2241 | int agf_ok = 1; | ||
2242 | |||
2243 | if (xfs_sb_version_hascrc(&mp->m_sb)) | ||
2244 | agf_ok = xfs_verify_cksum(bp->b_addr, BBTOB(bp->b_length), | ||
2245 | offsetof(struct xfs_agf, agf_crc)); | ||
2246 | 2237 | ||
2247 | agf_ok = agf_ok && xfs_agf_verify(mp, bp); | 2238 | if (xfs_sb_version_hascrc(&mp->m_sb) && |
2248 | 2239 | !xfs_buf_verify_cksum(bp, XFS_AGF_CRC_OFF)) | |
2249 | if (unlikely(XFS_TEST_ERROR(!agf_ok, mp, XFS_ERRTAG_ALLOC_READ_AGF, | 2240 | xfs_buf_ioerror(bp, EFSBADCRC); |
2250 | XFS_RANDOM_ALLOC_READ_AGF))) { | 2241 | else if (XFS_TEST_ERROR(!xfs_agf_verify(mp, bp), mp, |
2251 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr); | 2242 | XFS_ERRTAG_ALLOC_READ_AGF, |
2243 | XFS_RANDOM_ALLOC_READ_AGF)) | ||
2252 | xfs_buf_ioerror(bp, EFSCORRUPTED); | 2244 | xfs_buf_ioerror(bp, EFSCORRUPTED); |
2253 | } | 2245 | |
2246 | if (bp->b_error) | ||
2247 | xfs_verifier_error(bp); | ||
2254 | } | 2248 | } |
2255 | 2249 | ||
2256 | static void | 2250 | static void |
@@ -2261,8 +2255,8 @@ xfs_agf_write_verify( | |||
2261 | struct xfs_buf_log_item *bip = bp->b_fspriv; | 2255 | struct xfs_buf_log_item *bip = bp->b_fspriv; |
2262 | 2256 | ||
2263 | if (!xfs_agf_verify(mp, bp)) { | 2257 | if (!xfs_agf_verify(mp, bp)) { |
2264 | XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, bp->b_addr); | ||
2265 | xfs_buf_ioerror(bp, EFSCORRUPTED); | 2258 | xfs_buf_ioerror(bp, EFSCORRUPTED); |
2259 | xfs_verifier_error(bp); | ||
2266 | return; | 2260 | return; |
2267 | } | 2261 | } |
2268 | 2262 | ||
@@ -2272,8 +2266,7 @@ xfs_agf_write_verify( | |||
2272 | if (bip) | 2266 | if (bip) |
2273 | XFS_BUF_TO_AGF(bp)->agf_lsn = cpu_to_be64(bip->bli_item.li_lsn); | 2267 | XFS_BUF_TO_AGF(bp)->agf_lsn = cpu_to_be64(bip->bli_item.li_lsn); |
2274 | 2268 | ||
2275 | xfs_update_cksum(bp->b_addr, BBTOB(bp->b_length), | 2269 | xfs_buf_update_cksum(bp, XFS_AGF_CRC_OFF); |
2276 | offsetof(struct xfs_agf, agf_crc)); | ||
2277 | } | 2270 | } |
2278 | 2271 | ||
2279 | const struct xfs_buf_ops xfs_agf_buf_ops = { | 2272 | const struct xfs_buf_ops xfs_agf_buf_ops = { |