block: don't unecessarily clobber bi_error for chained bios
authorChristoph Hellwig <hch@lst.de>
Fri, 11 Mar 2016 16:34:50 +0000 (17:34 +0100)
committerJens Axboe <axboe@fb.com>
Mon, 14 Mar 2016 14:55:21 +0000 (08:55 -0600)
Only overwrite the parents bi_error if it was zero. That way a successful
bio completion doesn't reset the error pointer.

Reported-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/bio.c

index dbabd48b1934739bba125827e2019414cf34adee..282ca2e5aaf2d41c8e6b3337e307d230c48e96da 100644 (file)
@@ -300,7 +300,8 @@ static void bio_chain_endio(struct bio *bio)
 {
        struct bio *parent = bio->bi_private;
 
-       parent->bi_error = bio->bi_error;
+       if (!parent->bi_error)
+               parent->bi_error = bio->bi_error;
        bio_endio(parent);
        bio_put(bio);
 }
@@ -1753,7 +1754,9 @@ void bio_endio(struct bio *bio)
                 */
                if (bio->bi_end_io == bio_chain_endio) {
                        struct bio *parent = bio->bi_private;
-                       parent->bi_error = bio->bi_error;
+
+                       if (!parent->bi_error)
+                               parent->bi_error = bio->bi_error;
                        bio_put(bio);
                        bio = parent;
                } else {