diff options
author | Dave Chinner <dchinner@redhat.com> | 2014-10-01 19:04:56 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-10-01 19:04:56 -0400 |
commit | 2718775469a521c8b35442db5d665ac0c8c3c8ac (patch) | |
tree | 0d8392adf53361e73d76e40ed51a5e03cf6b057b /fs/xfs | |
parent | 8dac39219827113f14e97507646a610ca426b69e (diff) |
xfs: xfs_bioerror can die.
Internal buffer write error handling is a mess due to the unnatural
split between xfs_bioerror and xfs_bioerror_relse().
xfs_bwrite() only does sync IO and determines the handler to
call based on b_iodone, so for this caller the only difference
between xfs_bioerror() and xfs_bioerror_release() is the XBF_DONE
flag. We don't care what the XBF_DONE flag state is because we stale
the buffer in both paths - the next buffer lookup will clear
XBF_DONE because XBF_STALE is set. Hence we can use common
error handling for xfs_bwrite().
__xfs_buf_delwri_submit() is a similar - it's only ever called
on writes - all sync or async - and again there's no reason to
handle them any differently at all.
Clean up the nasty error handling and remove xfs_bioerror().
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_buf.c | 58 |
1 files changed, 12 insertions, 46 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 0eee0f1f099e..409a8a06642a 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -1075,39 +1075,6 @@ xfs_buf_ioerror_alert( | |||
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | /* | 1077 | /* |
1078 | * Called when we want to stop a buffer from getting written or read. | ||
1079 | * We attach the EIO error, muck with its flags, and call xfs_buf_ioend | ||
1080 | * so that the proper iodone callbacks get called. | ||
1081 | */ | ||
1082 | STATIC int | ||
1083 | xfs_bioerror( | ||
1084 | xfs_buf_t *bp) | ||
1085 | { | ||
1086 | #ifdef XFSERRORDEBUG | ||
1087 | ASSERT(XFS_BUF_ISREAD(bp) || bp->b_iodone); | ||
1088 | #endif | ||
1089 | |||
1090 | /* | ||
1091 | * No need to wait until the buffer is unpinned, we aren't flushing it. | ||
1092 | */ | ||
1093 | xfs_buf_ioerror(bp, -EIO); | ||
1094 | |||
1095 | /* | ||
1096 | * We're calling xfs_buf_ioend, so delete XBF_DONE flag. For | ||
1097 | * sync IO, xfs_buf_ioend is going to remove a ref here. | ||
1098 | */ | ||
1099 | if (!(bp->b_flags & XBF_ASYNC)) | ||
1100 | xfs_buf_hold(bp); | ||
1101 | XFS_BUF_UNREAD(bp); | ||
1102 | XFS_BUF_UNDONE(bp); | ||
1103 | xfs_buf_stale(bp); | ||
1104 | |||
1105 | xfs_buf_ioend(bp); | ||
1106 | |||
1107 | return -EIO; | ||
1108 | } | ||
1109 | |||
1110 | /* | ||
1111 | * Same as xfs_bioerror, except that we are releasing the buffer | 1078 | * Same as xfs_bioerror, except that we are releasing the buffer |
1112 | * here ourselves, and avoiding the xfs_buf_ioend call. | 1079 | * here ourselves, and avoiding the xfs_buf_ioend call. |
1113 | * This is meant for userdata errors; metadata bufs come with | 1080 | * This is meant for userdata errors; metadata bufs come with |
@@ -1155,19 +1122,19 @@ xfs_bwrite( | |||
1155 | ASSERT(xfs_buf_islocked(bp)); | 1122 | ASSERT(xfs_buf_islocked(bp)); |
1156 | 1123 | ||
1157 | bp->b_flags |= XBF_WRITE; | 1124 | bp->b_flags |= XBF_WRITE; |
1158 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q | XBF_WRITE_FAIL); | 1125 | bp->b_flags &= ~(XBF_ASYNC | XBF_READ | _XBF_DELWRI_Q | |
1126 | XBF_WRITE_FAIL | XBF_DONE); | ||
1159 | 1127 | ||
1160 | if (XFS_FORCED_SHUTDOWN(bp->b_target->bt_mount)) { | 1128 | if (XFS_FORCED_SHUTDOWN(bp->b_target->bt_mount)) { |
1161 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | 1129 | trace_xfs_bdstrat_shut(bp, _RET_IP_); |
1162 | 1130 | ||
1163 | /* | 1131 | xfs_buf_ioerror(bp, -EIO); |
1164 | * Metadata write that didn't get logged but written anyway. | 1132 | xfs_buf_stale(bp); |
1165 | * These aren't associated with a transaction, and can be | 1133 | |
1166 | * ignored. | 1134 | /* sync IO, xfs_buf_ioend is going to remove a ref here */ |
1167 | */ | 1135 | xfs_buf_hold(bp); |
1168 | if (!bp->b_iodone) | 1136 | xfs_buf_ioend(bp); |
1169 | return xfs_bioerror_relse(bp); | 1137 | return -EIO; |
1170 | return xfs_bioerror(bp); | ||
1171 | } | 1138 | } |
1172 | 1139 | ||
1173 | xfs_buf_iorequest(bp); | 1140 | xfs_buf_iorequest(bp); |
@@ -1857,10 +1824,9 @@ __xfs_buf_delwri_submit( | |||
1857 | if (XFS_FORCED_SHUTDOWN(bp->b_target->bt_mount)) { | 1824 | if (XFS_FORCED_SHUTDOWN(bp->b_target->bt_mount)) { |
1858 | trace_xfs_bdstrat_shut(bp, _RET_IP_); | 1825 | trace_xfs_bdstrat_shut(bp, _RET_IP_); |
1859 | 1826 | ||
1860 | if (!bp->b_iodone) | 1827 | xfs_buf_ioerror(bp, -EIO); |
1861 | xfs_bioerror_relse(bp); | 1828 | xfs_buf_stale(bp); |
1862 | else | 1829 | xfs_buf_ioend(bp); |
1863 | xfs_bioerror(bp); | ||
1864 | continue; | 1830 | continue; |
1865 | } | 1831 | } |
1866 | xfs_buf_iorequest(bp); | 1832 | xfs_buf_iorequest(bp); |