From: Mike Christie <michaelc@cs.wisc.edu>

A couple of drivers can sometimes fail the first segments in a bio then
requeue the rest of the request.  In this situation, if the last part of
the bio completes successfully bio_pair_end_* will miss that the beginging
of the bio had failed becuase they just return one when bi_size is not yet
zero.  The attached patch moves the error value test before the bi_size to
catch the above case.


---

 25-akpm/fs/bio.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff -puN fs/bio.c~bio_pair_end-fix fs/bio.c
--- 25/fs/bio.c~bio_pair_end-fix	Tue Mar 23 15:05:19 2004
+++ 25-akpm/fs/bio.c	Tue Mar 23 15:05:19 2004
@@ -701,11 +701,12 @@ static int bio_pair_end_1(struct bio * b
 {
 	struct bio_pair *bp = container_of(bi, struct bio_pair, bio1);
 
-	if (bi->bi_size)
-		return 1;
 	if (err)
 		bp->error = err;
 
+	if (bi->bi_size)
+		return 1;
+
 	bio_pair_release(bp);
 	return 0;
 }
@@ -714,11 +715,12 @@ static int bio_pair_end_2(struct bio * b
 {
 	struct bio_pair *bp = container_of(bi, struct bio_pair, bio2);
 
-	if (bi->bi_size)
-		return 1;
 	if (err)
 		bp->error = err;
 
+	if (bi->bi_size)
+		return 1;
+
 	bio_pair_release(bp);
 	return 0;
 }

_