Skip to content

Commit

Permalink
block: factor out chained bio completion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Mar 14, 2016
1 parent af3e3a5 commit 38f8baa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/*
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 38f8baa

Please sign in to comment.