blk-mq: introduce a blk_mq_peek_cached_request helper
authorChristoph Hellwig <hch@lst.de>
Wed, 24 Jan 2024 09:26:57 +0000 (10:26 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 5 Feb 2024 17:05:16 +0000 (10:05 -0700)
commit337e89feb7c29043dacd851b6ac28542a9a8aacf
tree78e31cd2cc06866ff9cbe5fa1b251d92b658d686
parent0f299da55ac3d28bc9de23a84fae01a85c4e253a
blk-mq: introduce a blk_mq_peek_cached_request helper

Add a new helper to check if there is suitable cached request in
blk_mq_submit_bio.  This removes open coded logic in blk_mq_submit_bio
and moves some checks that so far are in blk_mq_use_cached_rq to
be performed earlier.  This avoids the case where we first do check
with the cached request but then later end up allocating a new one
anyway and need to grab a queue reference.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Tested-by: Damien Le Moal <dlemoal@kernel.org>
Link: https://lore.kernel.org/r/20240124092658.2258309-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c