Skip to contentSkip to conversation

catch error when completing bio pairs

PATCH In review Mike Christie 2 participants 2 messages Mar 23, 2004 – Mar 24, 2004 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 catch error when completing bio pairs

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.

Mike Christie

fs/bio.c +6 -4
@@ -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;
 }
#1 lore raw
Quoted 7 lines · Mike Christie

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.

Yup that's a bug, patch is correct.

Signature · 1 line
Jens Axboe