xfs: ensure we capture IO errors correctly
authorDave Chinner <dchinner@redhat.com>
Tue, 12 Mar 2013 12:30:34 +0000 (23:30 +1100)
committerBen Myers <bpm@sgi.com>
Thu, 14 Mar 2013 20:56:53 +0000 (15:56 -0500)
Failed buffer readahead can leave the buffer in the cache marked
with an error. Most callers that then issue a subsequent read on the
buffer do not zero the b_error field out, and so we may incorectly
detect an error during IO completion due to the stale error value
left on the buffer.

Avoid this problem by zeroing the error before IO submission. This
ensures that the only IO errors that are detected those captured
from are those captured from bio submission or completion.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
fs/xfs/xfs_buf.c

index 50eb603e0cc14477d8d81f3f48014eb02a11a416..82b70bda9f47a51eb3f31a50ae4fcd32f6c57047 100644 (file)
@@ -1336,6 +1336,12 @@ _xfs_buf_ioapply(
        int             size;
        int             i;
 
+       /*
+        * Make sure we capture only current IO errors rather than stale errors
+        * left over from previous use of the buffer (e.g. failed readahead).
+        */
+       bp->b_error = 0;
+
        if (bp->b_flags & XBF_WRITE) {
                if (bp->b_flags & XBF_SYNCIO)
                        rw = WRITE_SYNC;