xfs: make xfs_buf_read_map return an error code
Convert xfs_buf_read_map() to return numeric error codes like most everywhere else in xfs. This involves moving the open-coded logic that reports metadata IO read / corruption errors and stales the buffer into xfs_buf_read_map so that the logic is all in one place. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com>
This commit is contained in:
@@ -302,36 +302,16 @@ xfs_trans_read_buf_map(
|
||||
return 0;
|
||||
}
|
||||
|
||||
bp = xfs_buf_read_map(target, map, nmaps, flags, ops);
|
||||
if (!bp) {
|
||||
if (!(flags & XBF_TRYLOCK))
|
||||
return -ENOMEM;
|
||||
return tp ? 0 : -EAGAIN;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we've had a read error, then the contents of the buffer are
|
||||
* invalid and should not be used. To ensure that a followup read tries
|
||||
* to pull the buffer from disk again, we clear the XBF_DONE flag and
|
||||
* mark the buffer stale. This ensures that anyone who has a current
|
||||
* reference to the buffer will interpret it's contents correctly and
|
||||
* future cache lookups will also treat it as an empty, uninitialised
|
||||
* buffer.
|
||||
*/
|
||||
if (bp->b_error) {
|
||||
error = bp->b_error;
|
||||
if (!XFS_FORCED_SHUTDOWN(mp))
|
||||
xfs_buf_ioerror_alert(bp, __func__);
|
||||
bp->b_flags &= ~XBF_DONE;
|
||||
xfs_buf_stale(bp);
|
||||
|
||||
error = xfs_buf_read_map(target, map, nmaps, flags, &bp, ops);
|
||||
switch (error) {
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
if (tp && (tp->t_flags & XFS_TRANS_DIRTY))
|
||||
xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
|
||||
xfs_buf_relse(bp);
|
||||
|
||||
/* bad CRC means corrupted metadata */
|
||||
if (error == -EFSBADCRC)
|
||||
error = -EFSCORRUPTED;
|
||||
/* fall through */
|
||||
case -ENOMEM:
|
||||
case -EAGAIN:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user