From: Bart Van Assche Date: Wed, 18 Dec 2024 21:22:46 +0000 (-0800) Subject: blk-mq: Move more error handling into blk_mq_submit_bio() X-Git-Tag: v6.14-rc1~202^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=659381520a3b13403c3051516317adc02e48259b;p=thirdparty%2Flinux.git blk-mq: Move more error handling into blk_mq_submit_bio() The error handling code in blk_mq_get_new_requests() cannot be understood without knowing that this function is only called by blk_mq_submit_bio(). Hence move the code for handling blk_mq_get_new_requests() failures into blk_mq_submit_bio(). Cc: Damien Le Moal Cc: Christoph Hellwig Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Link: https://lore.kernel.org/r/20241218212246.1073149-3-bvanassche@acm.org Signed-off-by: Jens Axboe --- diff --git a/block/blk-mq.c b/block/blk-mq.c index b815ac4872b7d..da39a1cac7022 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2984,12 +2984,9 @@ static struct request *blk_mq_get_new_requests(struct request_queue *q, } rq = __blk_mq_alloc_requests(&data); - if (rq) - return rq; - rq_qos_cleanup(q, bio); - if (bio->bi_opf & REQ_NOWAIT) - bio_wouldblock_error(bio); - return NULL; + if (unlikely(!rq)) + rq_qos_cleanup(q, bio); + return rq; } /* @@ -3129,8 +3126,11 @@ new_request: blk_mq_use_cached_rq(rq, plug, bio); } else { rq = blk_mq_get_new_requests(q, plug, bio, nr_segs); - if (unlikely(!rq)) + if (unlikely(!rq)) { + if (bio->bi_opf & REQ_NOWAIT) + bio_wouldblock_error(bio); goto queue_exit; + } } trace_block_getrq(bio);