summaryrefslogtreecommitdiff
path: root/block/blk-mq.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2021-10-20 00:24:12 +0300
committerJens Axboe <axboe@kernel.dk>2021-10-20 17:08:05 +0300
commit478eb72b815f33734723867ff236d96afa418d69 (patch)
treedc81054f6f79d225ae7afcbab10996ca42b3cc09 /block/blk-mq.c
parent859897c3fb9ad12fef429b026154e11350d0ceac (diff)
downloadlinux-478eb72b815f33734723867ff236d96afa418d69.tar.xz
block: optimise req_bio_endio()
First, get rid of an extra branch and chain error checks. Also reshuffle it with bio_advance(), so it goes closer to the final check, with that the compiler loads rq->rq_flags only once, and also doesn't reload bio->bi_iter.bi_size if bio_advance() didn't actually advanced the iter. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r--block/blk-mq.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 31d9e612d236..8b05a8f9bb33 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -633,25 +633,23 @@ void blk_mq_free_plug_rqs(struct blk_plug *plug)
static void req_bio_endio(struct request *rq, struct bio *bio,
unsigned int nbytes, blk_status_t error)
{
- if (error)
+ if (unlikely(error)) {
bio->bi_status = error;
-
- if (unlikely(rq->rq_flags & RQF_QUIET))
- bio_set_flag(bio, BIO_QUIET);
-
- bio_advance(bio, nbytes);
-
- if (req_op(rq) == REQ_OP_ZONE_APPEND && error == BLK_STS_OK) {
+ } else if (req_op(rq) == REQ_OP_ZONE_APPEND) {
/*
* Partial zone append completions cannot be supported as the
* BIO fragments may end up not being written sequentially.
*/
- if (bio->bi_iter.bi_size)
+ if (bio->bi_iter.bi_size == nbytes)
bio->bi_status = BLK_STS_IOERR;
else
bio->bi_iter.bi_sector = rq->__sector;
}
+ bio_advance(bio, nbytes);
+
+ if (unlikely(rq->rq_flags & RQF_QUIET))
+ bio_set_flag(bio, BIO_QUIET);
/* don't actually finish bio if it's part of flush sequence */
if (bio->bi_iter.bi_size == 0 && !(rq->rq_flags & RQF_FLUSH_SEQ))
bio_endio(bio);