From: Kanchan Joshi <joshi.k@samsung.com>
To: hch@lst.de, kbusch@kernel.org, axboe@kernel.dk, sagi@grimberg.me,
chaitanya.kulkarni@wdc.com
Cc: linux-nvme@lists.infradead.org, Kanchan Joshi <joshi.k@samsung.com>
Subject: [PATCH 2/2] nvme: avoid memset for passthrough requests
Date: Wed, 14 Apr 2021 10:46:29 +0530 [thread overview]
Message-ID: <20210414051629.103383-3-joshi.k@samsung.com> (raw)
In-Reply-To: <20210414051629.103383-1-joshi.k@samsung.com>
nvme_clear_nvme_request() clears the nvme_command, which is unncessary for
passthrough requests as nvme_command is overwritten immediately.
Change nvme_clear_nvme_request() so that double memset for passthrough
requests is avoided.
Signed-off-by: Kanchan Joshi <joshi.k@samsung.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 ea5b40e469d6..5f6b742aa32c 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -583,14 +583,13 @@ void nvme_put_ns(struct nvme_ns *ns)
}
EXPORT_SYMBOL_NS_GPL(nvme_put_ns, NVME_TARGET_PASSTHRU);
-static inline void nvme_clear_nvme_request(struct request *req)
+static inline void nvme_clear_nvme_request(struct request *req, bool clear_cmd)
{
- struct nvme_command *cmd = nvme_req(req)->cmd;
-
- memset(cmd, 0, sizeof(*cmd));
nvme_req(req)->retries = 0;
nvme_req(req)->flags = 0;
req->rq_flags |= RQF_DONTPREP;
+ if (clear_cmd)
+ memset(nvme_req(req)->cmd, 0, sizeof(struct nvme_command));
}
static inline unsigned int nvme_req_op(struct nvme_command *cmd)
@@ -610,7 +609,7 @@ static inline void nvme_init_request(struct request *req,
cmd->common.flags &= ~NVME_CMD_SGL_ALL;
req->cmd_flags |= REQ_FAILFAST_DRIVER;
- nvme_clear_nvme_request(req);
+ nvme_clear_nvme_request(req, false);
memcpy(nvme_req(req)->cmd, cmd, sizeof(*cmd));
}
@@ -900,7 +899,7 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
blk_status_t ret = BLK_STS_OK;
if (!(req->rq_flags & RQF_DONTPREP))
- nvme_clear_nvme_request(req);
+ nvme_clear_nvme_request(req, true);
switch (req_op(req)) {
case REQ_OP_DRV_IN:
--
2.25.1
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
next prev parent reply other threads:[~2021-04-14 5:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20210414051733epcas5p31d0a4727a2c05b76bcf7ee75c290aaef@epcas5p3.samsung.com>
2021-04-14 5:16 ` [PATCH 0/2] kref and paasthrough cleanup Kanchan Joshi
[not found] ` <CGME20210414051743epcas5p3f5371b68b066e5093d91f598b0803e9c@epcas5p3.samsung.com>
2021-04-14 5:16 ` [PATCH 1/2] nvme: add nvme_get_ns helper Kanchan Joshi
[not found] ` <CGME20210414051747epcas5p265826317a971aaa3337efb6472a9df7c@epcas5p2.samsung.com>
2021-04-14 5:16 ` Kanchan Joshi [this message]
2021-04-14 6:08 ` [PATCH 2/2] nvme: avoid memset for passthrough requests Christoph Hellwig
2021-04-14 16:27 ` Kanchan Joshi
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=20210414051629.103383-3-joshi.k@samsung.com \
--to=joshi.k@samsung.com \
--cc=axboe@kernel.dk \
--cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).