block: factor out chained bio completion
authorChristoph Hellwig <hch@lst.de>
Fri, 11 Mar 2016 16:34:51 +0000 (17:34 +0100)
committerJens Axboe <axboe@fb.com>
Mon, 14 Mar 2016 14:55:22 +0000 (08:55 -0600)
Factor common code between bio_chain_endio and bio_endio into a common
helper.

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

index 282ca2e5aaf2d41c8e6b3337e307d230c48e96da..67e51ace1b7735af340edb387225e907f59f33f0 100644 (file)
@@ -296,14 +296,19 @@ void bio_reset(struct bio *bio)
 }
 EXPORT_SYMBOL(bio_reset);
 
-static void bio_chain_endio(struct bio *bio)
+static struct bio *__bio_chain_endio(struct bio *bio)
 {
        struct bio *parent = bio->bi_private;
 
        if (!parent->bi_error)
                parent->bi_error = bio->bi_error;
-       bio_endio(parent);
        bio_put(bio);
+       return parent;
+}
+
+static void bio_chain_endio(struct bio *bio)
+{
+       bio_endio(__bio_chain_endio(bio));
 }
 
 /*
@@ -1753,12 +1758,7 @@ void bio_endio(struct bio *bio)
                 * pointers also disables gcc's sibling call optimization.
                 */
                if (bio->bi_end_io == bio_chain_endio) {
-                       struct bio *parent = bio->bi_private;
-
-                       if (!parent->bi_error)
-                               parent->bi_error = bio->bi_error;
-                       bio_put(bio);
-                       bio = parent;
+                       bio = __bio_chain_endio(bio);
                } else {
                        if (bio->bi_end_io)
                                bio->bi_end_io(bio);
This page took 0.02707 seconds and 5 git commands to generate.