Skip to content

Commit

Permalink
nvme: avoid memset for passthrough requests
Browse files Browse the repository at this point in the history
nvme_clear_nvme_request() clears the nvme_command, which is unncessary
for passthrough requests as nvme_command is overwritten immediately.
Move clearing part from this helper to the caller, so that double memset
for passthrough requests is avoided.

Signed-off-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Kanchan Joshi authored and Christoph Hellwig committed May 4, 2021
1 parent 4c74d1f commit 51ad06c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/nvme/host/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,6 @@ EXPORT_SYMBOL_NS_GPL(nvme_put_ns, NVME_TARGET_PASSTHRU);

static inline void nvme_clear_nvme_request(struct request *req)
{
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;
Expand Down Expand Up @@ -903,8 +900,10 @@ blk_status_t nvme_setup_cmd(struct nvme_ns *ns, struct request *req)
struct nvme_command *cmd = nvme_req(req)->cmd;
blk_status_t ret = BLK_STS_OK;

if (!(req->rq_flags & RQF_DONTPREP))
if (!(req->rq_flags & RQF_DONTPREP)) {
nvme_clear_nvme_request(req);
memset(cmd, 0, sizeof(*cmd));
}

switch (req_op(req)) {
case REQ_OP_DRV_IN:
Expand Down

0 comments on commit 51ad06c

Please sign in to comment.