From: Jeff Mahoney <jeffm@suse.com>
Subject: xfs: Fix re-use of EWOULDBLOCK during read on dm-mirror
References: bnc#736255
Patch-mainline: Submitted differently to linux-fs 6 Dec 2012

When using lvconvert to convert a linear mapping to a dm-raid1 mirror,
we encountered issues where the log would be flooded with messages like:
[490.452144] XFS (dm-0): I/O error occurred: meta-data dev dm-0 block 0x94d0caf8       ("xfs_trans_read_buf") error 11 buf count 4096

The cause is that dm-mirror (and striping, and others) will return
-EWOULDBLOCK for readahead requests while the mirror is rebuilding. XFS's
end_io routine caches the errno and then _xfs_buf_read bails out early
when it encounters it after issuing the i/o request. The I/O eventually
succeeds and the endio routine resets bp->b_error, but the original read
request has already returned -EWOULDBLOCK to the user and added the log
message above to the kernel log, freaking everyone out.

This patch ignores EWOULDBLOCK when deciding whether to wait for the I/O
to complete and tries again, allowing the read to succeed as expected.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
[mcgrof: modified after inclusion of commit 0e95f19ad983]
Reviewed-by: Rich Johnston <rjohnston@sgi.com>
---
 fs/xfs/linux-2.6/xfs_buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index d7c781d58709..f4af805055dc 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1433,7 +1433,7 @@ xfs_buf_iowait(
 {
 	trace_xfs_buf_iowait(bp, _RET_IP_);
 
-	if (!bp->b_error)
+	if (!bp->b_error || bp->b_error == EWOULDBLOCK)
 		wait_for_completion(&bp->b_iowait);
 
 	trace_xfs_buf_iowait_done(bp, _RET_IP_);
