]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
xfs: don't block on buffer read errors
authorDave Chinner <dchinner@redhat.com>
Tue, 20 Jul 2010 07:52:59 +0000 (17:52 +1000)
committerAlex Elder <aelder@sgi.com>
Mon, 26 Jul 2010 18:16:48 +0000 (13:16 -0500)
xfs_buf_read() fails to detect dispatch errors before attempting to
wait on sychronous IO. If there was an error, it will get stuck
forever, waiting for an I/O that was never started. Make sure the
error is detected correctly.

Further, such a failure can leave locked pages in the page cache
which will cause a later operation to hang on the page. Ensure that
we correctly process pages in the buffers when we get a dispatch
error.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/linux-2.6/xfs_buf.c

index efce8abb375c41142f661e5364abe02fd2ade986..f4d4e708a8d63d4fc794a693fef3fd6e79af5f96 100644 (file)
@@ -578,9 +578,9 @@ _xfs_buf_read(
                        XBF_READ_AHEAD | _XBF_RUN_QUEUES);
 
        status = xfs_buf_iorequest(bp);
-       if (!status && !(flags & XBF_ASYNC))
-               status = xfs_buf_iowait(bp);
-       return status;
+       if (status || XFS_BUF_ISERROR(bp) || (flags & XBF_ASYNC))
+               return status;
+       return xfs_buf_iowait(bp);
 }
 
 xfs_buf_t *
@@ -1280,8 +1280,19 @@ submit_io:
                if (size)
                        goto next_chunk;
        } else {
-               bio_put(bio);
+               /*
+                * if we get here, no pages were added to the bio. However,
+                * we can't just error out here - if the pages are locked then
+                * we have to unlock them otherwise we can hang on a later
+                * access to the page.
+                */
                xfs_buf_ioerror(bp, EIO);
+               if (bp->b_flags & _XBF_PAGE_LOCKED) {
+                       int i;
+                       for (i = 0; i < bp->b_page_count; i++)
+                               unlock_page(bp->b_pages[i]);
+               }
+               bio_put(bio);
        }
 }