aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_buf.c18
-rw-r--r--fs/xfs/xfs_buf.h1
2 files changed, 17 insertions, 2 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index a046149e6099..170d6c0afe71 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1008,6 +1008,13 @@ xfs_buf_ioend(
1008 1008
1009 bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD); 1009 bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD);
1010 1010
1011 /*
1012 * Pull in IO completion errors now. We are guaranteed to be running
1013 * single threaded, so we don't need the lock to read b_io_error.
1014 */
1015 if (!bp->b_error && bp->b_io_error)
1016 xfs_buf_ioerror(bp, bp->b_io_error);
1017
1011 /* Only validate buffers that were read without errors */ 1018 /* Only validate buffers that were read without errors */
1012 if (read && !bp->b_error && bp->b_ops) { 1019 if (read && !bp->b_error && bp->b_ops) {
1013 ASSERT(!bp->b_iodone); 1020 ASSERT(!bp->b_iodone);
@@ -1192,8 +1199,12 @@ xfs_buf_bio_end_io(
1192 * don't overwrite existing errors - otherwise we can lose errors on 1199 * don't overwrite existing errors - otherwise we can lose errors on
1193 * buffers that require multiple bios to complete. 1200 * buffers that require multiple bios to complete.
1194 */ 1201 */
1195 if (!bp->b_error) 1202 if (error) {
1196 xfs_buf_ioerror(bp, error); 1203 spin_lock(&bp->b_lock);
1204 if (!bp->b_io_error)
1205 bp->b_io_error = error;
1206 spin_unlock(&bp->b_lock);
1207 }
1197 1208
1198 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) 1209 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ))
1199 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); 1210 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp));
@@ -1379,6 +1390,9 @@ xfs_buf_iorequest(
1379 if (bp->b_flags & XBF_WRITE) 1390 if (bp->b_flags & XBF_WRITE)
1380 xfs_buf_wait_unpin(bp); 1391 xfs_buf_wait_unpin(bp);
1381 1392
1393 /* clear the internal error state to avoid spurious errors */
1394 bp->b_io_error = 0;
1395
1382 /* 1396 /*
1383 * Take references to the buffer. For XBF_ASYNC buffers, holding a 1397 * Take references to the buffer. For XBF_ASYNC buffers, holding a
1384 * reference for as long as submission takes is all that is necessary 1398 * reference for as long as submission takes is all that is necessary
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 4585c1595a98..44db8cd67bda 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -158,6 +158,7 @@ typedef struct xfs_buf {
158 struct list_head b_lru; /* lru list */ 158 struct list_head b_lru; /* lru list */
159 spinlock_t b_lock; /* internal state lock */ 159 spinlock_t b_lock; /* internal state lock */
160 unsigned int b_state; /* internal state flags */ 160 unsigned int b_state; /* internal state flags */
161 int b_io_error; /* internal IO error state */
161 wait_queue_head_t b_waiters; /* unpin waiters */ 162 wait_queue_head_t b_waiters; /* unpin waiters */
162 struct list_head b_list; 163 struct list_head b_list;
163 struct xfs_perag *b_pag; /* contains rbtree root */ 164 struct xfs_perag *b_pag; /* contains rbtree root */