]> www.infradead.org Git - users/dwmw2/linux.git/commit
nvme: don't check nvme_req flags for new req
authorChaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Mon, 1 Mar 2021 02:06:08 +0000 (18:06 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jun 2022 06:59:50 +0000 (08:59 +0200)
commitba388d4e9a684fc7a84b7cbdf9887efe11f4fde5
treef1c52ba669d3e159a21699f8148473f5c8a289c5
parente7ccaa1abacf6f8b4fe4e0a06cbb9e2051a4d79e
nvme: don't check nvme_req flags for new req

[ Upstream commit c03fd85de293a4f65fcb94a795bf4c12a432bb6c ]

nvme_clear_request() has a check for flag REQ_DONTPREP and it is called
from nvme_init_request() and nvme_setuo_cmd().

The function nvme_init_request() is called from nvme_alloc_request()
and nvme_alloc_request_qid(). From these two callers new request is
allocated everytime. For newly allocated request RQF_DONTPREP is never
set. Since after getting a tag, block layer sets the req->rq_flags == 0
and never sets the REQ_DONTPREP when returning the request :-

nvme_alloc_request()
blk_mq_alloc_request()
blk_mq_rq_ctx_init()
rq->rq_flags = 0 <----

nvme_alloc_request_qid()
blk_mq_alloc_request_hctx()
blk_mq_rq_ctx_init()
rq->rq_flags = 0 <----

The block layer does set req->rq_flags but REQ_DONTPREP is not one of
them and that is set by the driver.

That means we can unconditinally set the REQ_DONTPREP value to the
rq->rq_flags when nvme_init_request()->nvme_clear_request() is called
from above two callers.

Move the check for REQ_DONTPREP from nvme_clear_nvme_request() into
nvme_setup_cmd().

This is needed since nvme_alloc_request() now gets called from fast
path when NVMeOF target isĀ configured with passthru backend to avoid
unnecessary checks in the fast path.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nvme/host/core.c