diff options
author | Jinlong Chen <nickyc975@zju.edu.cn> | 2022-11-02 10:52:30 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-11-02 08:36:50 -0600 |
commit | 4046728253751adb41b05e85ebd686210efde1ad (patch) | |
tree | 53c14569fe85bc0a6015dae891925db1987ead0c /block/blk-mq.c | |
parent | 7edfd68165b8dab8cde231728ff092a625469eb7 (diff) | |
download | lwn-4046728253751adb41b05e85ebd686210efde1ad.tar.gz lwn-4046728253751adb41b05e85ebd686210efde1ad.zip |
blk-mq: use if-else instead of goto in blk_mq_alloc_cached_request()
if-else is more readable than goto here.
Signed-off-by: Jinlong Chen <nickyc975@zju.edu.cn>
Link: https://lore.kernel.org/r/d3306fa4e92dc9cc614edc8f1802686096bafef2.1667356813.git.nickyc975@zju.edu.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r-- | block/blk-mq.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index d4824b53f6b2..fc9c400adf92 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -575,25 +575,26 @@ static struct request *blk_mq_alloc_cached_request(struct request_queue *q, if (!plug) return NULL; + if (rq_list_empty(plug->cached_rq)) { if (plug->nr_ios == 1) return NULL; rq = blk_mq_rq_cache_fill(q, plug, opf, flags); - if (rq) - goto got_it; - return NULL; - } - rq = rq_list_peek(&plug->cached_rq); - if (!rq || rq->q != q) - return NULL; + if (!rq) + return NULL; + } else { + rq = rq_list_peek(&plug->cached_rq); + if (!rq || rq->q != q) + return NULL; - if (blk_mq_get_hctx_type(opf) != rq->mq_hctx->type) - return NULL; - if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) - return NULL; + if (blk_mq_get_hctx_type(opf) != rq->mq_hctx->type) + return NULL; + if (op_is_flush(rq->cmd_flags) != op_is_flush(opf)) + return NULL; + + plug->cached_rq = rq_list_next(rq); + } - plug->cached_rq = rq_list_next(rq); -got_it: rq->cmd_flags = opf; INIT_LIST_HEAD(&rq->queuelist); return rq; |