Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ec53d1db authored by Dave Chinner's avatar Dave Chinner Committed by Alex Elder
Browse files

xfs: don't block on buffer read errors



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: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent a4190f90
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -578,9 +578,9 @@ _xfs_buf_read(
			XBF_READ_AHEAD | _XBF_RUN_QUEUES);
			XBF_READ_AHEAD | _XBF_RUN_QUEUES);


	status = xfs_buf_iorequest(bp);
	status = xfs_buf_iorequest(bp);
	if (!status && !(flags & XBF_ASYNC))
	if (status || XFS_BUF_ISERROR(bp) || (flags & XBF_ASYNC))
		status = xfs_buf_iowait(bp);
		return status;
		return status;
	return xfs_buf_iowait(bp);
}
}


xfs_buf_t *
xfs_buf_t *
@@ -1280,8 +1280,19 @@ _xfs_buf_ioapply(
		if (size)
		if (size)
			goto next_chunk;
			goto next_chunk;
	} else {
	} 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);
		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);
	}
	}
}
}