Commit c797b40c authored by Ming Lei's avatar Ming Lei Committed by Jens Axboe

blk-mq: don't grab rq's refcount in blk_mq_check_expired()

Inside blk_mq_queue_tag_busy_iter() we already grabbed request's
refcount before calling ->fn(), so needn't to grab it one more time
in blk_mq_check_expired().

Meantime remove extra request expire check in blk_mq_check_expired().

Cc: Keith Busch <kbusch@kernel.org>
Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarJohn Garry <john.garry@huawei.com>
Link: https://lore.kernel.org/r/20210811155202.629575-1-ming.lei@redhat.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent cddce011
...@@ -923,34 +923,14 @@ static bool blk_mq_check_expired(struct blk_mq_hw_ctx *hctx, ...@@ -923,34 +923,14 @@ static bool blk_mq_check_expired(struct blk_mq_hw_ctx *hctx,
unsigned long *next = priv; unsigned long *next = priv;
/* /*
* Just do a quick check if it is expired before locking the request in * blk_mq_queue_tag_busy_iter() has locked the request, so it cannot
* so we're not unnecessarilly synchronizing across CPUs. * be reallocated underneath the timeout handler's processing, then
*/ * the expire check is reliable. If the request is not expired, then
if (!blk_mq_req_expired(rq, next)) * it was completed and reallocated as a new request after returning
return true; * from blk_mq_check_expired().
/*
* We have reason to believe the request may be expired. Take a
* reference on the request to lock this request lifetime into its
* currently allocated context to prevent it from being reallocated in
* the event the completion by-passes this timeout handler.
*
* If the reference was already released, then the driver beat the
* timeout handler to posting a natural completion.
*/
if (!refcount_inc_not_zero(&rq->ref))
return true;
/*
* The request is now locked and cannot be reallocated underneath the
* timeout handler's processing. Re-verify this exact request is truly
* expired; if it is not expired, then the request was completed and
* reallocated as a new request.
*/ */
if (blk_mq_req_expired(rq, next)) if (blk_mq_req_expired(rq, next))
blk_mq_rq_timed_out(rq, reserved); blk_mq_rq_timed_out(rq, reserved);
blk_mq_put_rq_ref(rq);
return true; return true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment