提交 ba8c6967 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

block: cleanup bio_endio

Replace the while loop that unecessarily checks for a NULL bio in the fast
path with a simple goto loop.
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NJens Axboe <axboe@fb.com>
上级 38f8baae
...@@ -1745,26 +1745,25 @@ static inline bool bio_remaining_done(struct bio *bio) ...@@ -1745,26 +1745,25 @@ static inline bool bio_remaining_done(struct bio *bio)
**/ **/
void bio_endio(struct bio *bio) void bio_endio(struct bio *bio)
{ {
while (bio) { again:
if (unlikely(!bio_remaining_done(bio))) if (unlikely(!bio_remaining_done(bio)))
break; return;
/* /*
* Need to have a real endio function for chained bios, * Need to have a real endio function for chained bios, otherwise
* otherwise various corner cases will break (like stacking * various corner cases will break (like stacking block devices that
* block devices that save/restore bi_end_io) - however, we want * save/restore bi_end_io) - however, we want to avoid unbounded
* to avoid unbounded recursion and blowing the stack. Tail call * recursion and blowing the stack. Tail call optimization would
* optimization would handle this, but compiling with frame * handle this, but compiling with frame pointers also disables
* pointers also disables gcc's sibling call optimization. * gcc's sibling call optimization.
*/ */
if (bio->bi_end_io == bio_chain_endio) { if (bio->bi_end_io == bio_chain_endio) {
bio = __bio_chain_endio(bio); bio = __bio_chain_endio(bio);
} else { goto again;
if (bio->bi_end_io)
bio->bi_end_io(bio);
bio = NULL;
}
} }
if (bio->bi_end_io)
bio->bi_end_io(bio);
} }
EXPORT_SYMBOL(bio_endio); EXPORT_SYMBOL(bio_endio);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册