All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: linux-nvme@lists.infradead.org
Cc: kbusch@kernel.org, hch@lst.de,
	Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	sagi@grimberg.me
Subject: [PATCH 12/14] nvme-core: don't check nvme_req flags for new req
Date: Tue, 16 Feb 2021 16:10:30 -0800	[thread overview]
Message-ID: <20210217001032.25741-13-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20210217001032.25741-1-chaitanya.kulkarni@wdc.com>

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>
---
 drivers/nvme/host/core.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index a0d0c3a5abff..608462df2c39 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -637,11 +637,9 @@ EXPORT_SYMBOL_NS_GPL(nvme_put_ns, NVME_TARGET_PASSTHRU);
 
 static inline void nvme_clear_nvme_request(struct request *req)
 {
-	if (!(req->rq_flags & RQF_DONTPREP)) {
-		nvme_req(req)->retries = 0;
-		nvme_req(req)->flags = 0;
-		req->rq_flags |= RQF_DONTPREP;
-	}
+	nvme_req(req)->retries = 0;
+	nvme_req(req)->flags = 0;
+	req->rq_flags |= RQF_DONTPREP;
 }
 
 static inline unsigned int nvme_req_op(struct nvme_command *cmd)
@@ -943,7 +941,8 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
 {
 	blk_status_t ret = BLK_STS_OK;
 
-	nvme_clear_nvme_request(req);
+	if (!(req->rq_flags & RQF_DONTPREP))
+		nvme_clear_nvme_request(req);
 
 	memset(cmd, 0, sizeof(*cmd));
 	switch (req_op(req)) {
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2021-02-17  0:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-17  0:10 [PATCH 00/14] nvme: few cleanups and small improvements Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 01/14] nvme-core: remove duplicate kfree in init identify Chaitanya Kulkarni
2021-02-24 16:35   ` Christoph Hellwig
2021-02-24 22:35     ` Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 02/14] nvme-core: don't use switch for only one case use Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 03/14] nvme-core: use right type for ARRAY_SIZE check Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 04/14] nvme-core: fix the type for shutdown_timeout Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 05/14] nvme-core: add helper to init ctrl transport attr Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 06/14] nvme-core: add helper to init shutdown timeout Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 07/14] nvme-core: add helper to init ctrl subsys quirk Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 08/14] nvme-core: move util quirk at the top of the file Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 09/14] nvme-core: mark nvme_setup_passsthru() inline Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 10/14] nvme-core: remove one liner wrappers for streams Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 11/14] nvme-core: use likely in nvme_init_request() Chaitanya Kulkarni
2021-02-17  0:10 ` Chaitanya Kulkarni [this message]
2021-02-17  0:10 ` [PATCH 13/14] nvme-fc: fix the function documentation comment Chaitanya Kulkarni
2021-02-17  0:10 ` [PATCH 14/14] nvmet-fc: update function documentation Chaitanya Kulkarni
2021-02-24 15:42 ` [PATCH 00/14] nvme: few cleanups and small improvements Keith Busch
2021-02-24 21:52   ` Chaitanya Kulkarni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210217001032.25741-13-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.