Skip to contentSkip to conversation

nvme: add helper nvme_cleanup_cmd()

PATCH New Ming Lin 4 participants 5 messages Apr 17, 2016 – Apr 18, 2016 NVMe

lore
Share & tools
lore

Ming Lin

author
#0 lore raw

PATCH 1/1 nvme: add helper nvme_cleanup_cmd()

From: Ming Lin <[email protected]>

This hides command cleanup into core.c and fabrics drivers will also use it.

Signed-off-by Ming Lin <ming.l at ssi.samsung.com>
---
 drivers/nvme/host/core.c | 7 +++++++
 drivers/nvme/host/nvme.h | 1 +
 drivers/nvme/host/pci.c  | 3 +--
 3 files changed, 9 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +7 -0
index 4eb5759..7dd9905 100644
@@ -243,6 +243,13 @@ int nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
 }
 EXPORT_SYMBOL_GPL(nvme_setup_cmd);
 
+void nvme_cleanup_cmd(struct request *req)
+{
+	if (req->cmd_flags & REQ_DISCARD)
+		kfree(req->completion_data);
+}
+EXPORT_SYMBOL_GPL(nvme_cleanup_cmd);
+
 /*
  * Returns 0 on success.  If the result is negative, it's a Linux error code;
  * if the result is positive, it's an NVM Express status code
drivers/nvme/host/nvme.h +1 -0
index 8e8fae8..4f9ddbf 100644
@@ -220,6 +220,7 @@ struct request *nvme_alloc_request(struct request_queue *q,
 void nvme_requeue_req(struct request *req);
 int nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
 		struct nvme_command *cmd);
+void nvme_cleanup_cmd(struct request *req);
 int nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
 		void *buf, unsigned bufflen);
 int __nvme_submit_sync_cmd(struct request_queue *q, struct nvme_command *cmd,
drivers/nvme/host/pci.c +1 -2
index ff3c8d7..0569cbf 100644
@@ -363,8 +363,7 @@ static void nvme_free_iod(struct nvme_dev *dev, struct request *req)
 	__le64 **list = iod_list(req);
 	dma_addr_t prp_dma = iod->first_dma;
 
-	if (req->cmd_flags & REQ_DISCARD)
-		kfree(req->completion_data);
+	nvme_cleanup_cmd(req);
 
 	if (iod->npages == 0)
 		dma_pool_free(dev->prp_small_pool, list[0], prp_dma);
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 nvme: add helper nvme_cleanup_cmd()

Looks good,

Reviewed-by Christoph Hellwig <hch at lst.de>
#2 lore raw

PATCH 1/1 nvme: add helper nvme_cleanup_cmd()

In reply to Ming Lin
Quoted 4 lines · Ming Lin

From: Ming Lin <ming.l at ssi.samsung.com>

This hides command cleanup into core.c and fabrics drivers will also use it.

Can we just make this a static inline in nvme.h instead of adding a new export?

author
#3 lore raw

PATCH 1/1 nvme: add helper nvme_cleanup_cmd()

Quoted 8 lines · Keith Busch
Quoted 4 lines · Ming Lin

From: Ming Lin <ming.l at ssi.samsung.com>

This hides command cleanup into core.c and fabrics drivers will also use it.

Can we just make this a static inline in nvme.h instead of adding a new export?

OK to me. I'll send a new one if no objection.