Skip to content

Commit

Permalink
block: cleanup bio_endio
Browse files Browse the repository at this point in the history
Replace the while loop that unecessarily checks for a NULL bio in the fast
path with a simple goto loop.

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 38f8baa commit ba8c696
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1745,26 +1745,25 @@ static inline bool bio_remaining_done(struct bio *bio)
**/
void bio_endio(struct bio *bio)
{
while (bio) {
if (unlikely(!bio_remaining_done(bio)))
break;
again:
if (unlikely(!bio_remaining_done(bio)))
return;

/*
* Need to have a real endio function for chained bios,
* otherwise various corner cases will break (like stacking
* block devices that save/restore bi_end_io) - however, we want
* to avoid unbounded recursion and blowing the stack. Tail call
* optimization would handle this, but compiling with frame
* pointers also disables gcc's sibling call optimization.
*/
if (bio->bi_end_io == bio_chain_endio) {
bio = __bio_chain_endio(bio);
} else {
if (bio->bi_end_io)
bio->bi_end_io(bio);
bio = NULL;
}
/*
* Need to have a real endio function for chained bios, otherwise
* various corner cases will break (like stacking block devices that
* save/restore bi_end_io) - however, we want to avoid unbounded
* recursion and blowing the stack. Tail call optimization would
* handle this, but compiling with frame pointers also disables
* gcc's sibling call optimization.
*/
if (bio->bi_end_io == bio_chain_endio) {
bio = __bio_chain_endio(bio);
goto again;
}

if (bio->bi_end_io)
bio->bi_end_io(bio);
}
EXPORT_SYMBOL(bio_endio);

Expand Down

0 comments on commit ba8c696

Please sign in to comment.