Skip to contentSkip to conversation

move nvme_cancel_io() to common code

PATCH Superseded Ming Lin 2 participants 5 messages May 18, 2016 NVMe

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Ming Lin

author
#0 lore raw

cover move nvme_cancel_io() to common code

From: Ming Lin <[email protected]>

So it can be used by fabrics driver also.

Ming Lin (2):
nvme: update nvme_cancel_io() a bit
nvme: move nvme_cancel_io() to core.c

 drivers/nvme/host/core.c | 17 +++++++++++++++++
 drivers/nvme/host/nvme.h |  1 +
 drivers/nvme/host/pci.c  | 20 ++------------------
 3 files changed, 20 insertions(+), 18 deletions(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 1/2 nvme: update nvme_cancel_io() a bit

From: Ming Lin <[email protected]>

Pass in nvme_ctrl, so it can be used by Fabrics driver also.

Signed-off-by Ming Lin <ming.l at samsung.com>
Reviewed-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/pci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/nvme/host/pci.c +4 -4
index a62c9c5..a2481ff 100644
@@ -927,13 +927,13 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
 
 static void nvme_cancel_io(struct request *req, void *data, bool reserved)
 {
+	struct nvme_ctrl *ctrl = data;
 	int status;
 
 	if (!blk_mq_request_started(req))
 		return;
 
-	dev_dbg_ratelimited(((struct nvme_dev *) data)->ctrl.device,
-				"Cancelling I/O %d", req->tag);
+	dev_dbg_ratelimited(ctrl->device, "Cancelling I/O %d", req->tag);
 
 	status = NVME_SC_ABORT_REQ;
 	if (blk_queue_dying(req->q))
@@ -1720,8 +1720,8 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
 	}
 	nvme_pci_disable(dev);
 
-	blk_mq_tagset_busy_iter(&dev->tagset, nvme_cancel_io, dev);
-	blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_io, dev);
+	blk_mq_tagset_busy_iter(&dev->tagset, nvme_cancel_io, &dev->ctrl);
+	blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_io, &dev->ctrl);
 	mutex_unlock(&dev->shutdown_lock);
 }
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 1/2 nvme: update nvme_cancel_io() a bit

drivers/nvme/host/pci.c static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) · line 936

Quoted 11 lines · Ming Lin

static void nvme_cancel_io(struct request *req, void *data, bool reserved) {

drivers/nvme/host/pci.c +2 -2
+	struct nvme_ctrl *ctrl = data;
 	int status;
 
 	if (!blk_mq_request_started(req))
 		return;
 
-	dev_dbg_ratelimited(((struct nvme_dev *) data)->ctrl.device,
-				"Cancelling I/O %d", req->tag);
+	dev_dbg_ratelimited(ctrl->device, "Cancelling I/O %d", req->tag);

Since you're not using ctrl for anything but the debug print, you should remove declaring it and instead do like what's currently there. This way the driver doesn't produce an unused variable warning in some kernel configurations. See commit 7e197930 that fixed this before.

Otherwise, looks fine.

author
#3 lore raw

PATCH 1/2 nvme: update nvme_cancel_io() a bit

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

static void nvme_cancel_io(struct request *req, void *data, bool reserved) {

+     struct nvme_ctrl *ctrl = data;
      int status;

      if (!blk_mq_request_started(req))
              return;
Quoted 8 lines

drivers/nvme/host/pci.c static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved) · line 936

Quoted 3 lines
drivers/nvme/host/pci.c +1 -2
-     dev_dbg_ratelimited(((struct nvme_dev *) data)->ctrl.device,
-                             "Cancelling I/O %d", req->tag);
+     dev_dbg_ratelimited(ctrl->device, "Cancelling I/O %d", req->tag);

Since you're not using ctrl for anything but the debug print, you should remove declaring it and instead do like what's currently there. This way the driver doesn't produce an unused variable warning in some kernel configurations. See commit 7e197930 that fixed this before.

Will update. Thanks.

Quoted 2 lines

Otherwise, looks fine.

author
#4 lore raw

PATCH 2/2 nvme: move nvme_cancel_io() to core.c

In reply to Ming Lin

From: Ming Lin <[email protected]>

So it can be used by Fabrics driver also.

Signed-off-by Ming Lin <ming.l at samsung.com>
Reviewed-by Christoph Hellwig <hch at lst.de>
---
 drivers/nvme/host/core.c | 17 +++++++++++++++++
 drivers/nvme/host/nvme.h |  1 +
 drivers/nvme/host/pci.c  | 16 ----------------
 3 files changed, 18 insertions(+), 16 deletions(-)
drivers/nvme/host/core.c +17 -0
index ac950d1..4f971ed 100644
@@ -59,6 +59,23 @@ static DEFINE_SPINLOCK(dev_list_lock);
 
 static struct class *nvme_class;
 
+void nvme_cancel_io(struct request *req, void *data, bool reserved)
+{
+	struct nvme_ctrl *ctrl = data;
+	int status;
+
+	if (!blk_mq_request_started(req))
+		return;
+
+	dev_dbg_ratelimited(ctrl->device, "Cancelling I/O %d", req->tag);
+
+	status = NVME_SC_ABORT_REQ;
+	if (blk_queue_dying(req->q))
+		status |= NVME_SC_DNR;
+	blk_mq_complete_request(req, status);
+}
+EXPORT_SYMBOL_GPL(nvme_cancel_io);
+
 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
 		enum nvme_ctrl_state new_state)
 {
drivers/nvme/host/nvme.h +1 -0
index fab6507..ff234bd 100644
@@ -229,6 +229,7 @@ static inline bool nvme_req_needs_retry(struct request *req, u16 status)
 		(jiffies - req->start_time) < req->timeout;
 }
 
+void nvme_cancel_io(struct request *req, void *data, bool reserved);
 bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
 		enum nvme_ctrl_state new_state);
 int nvme_disable_ctrl(struct nvme_ctrl *ctrl, u64 cap);
drivers/nvme/host/pci.c +0 -16
index a2481ff..d3471e4 100644
@@ -925,22 +925,6 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
 	return BLK_EH_RESET_TIMER;
 }
 
-static void nvme_cancel_io(struct request *req, void *data, bool reserved)
-{
-	struct nvme_ctrl *ctrl = data;
-	int status;
-
-	if (!blk_mq_request_started(req))
-		return;
-
-	dev_dbg_ratelimited(ctrl->device, "Cancelling I/O %d", req->tag);
-
-	status = NVME_SC_ABORT_REQ;
-	if (blk_queue_dying(req->q))
-		status |= NVME_SC_DNR;
-	blk_mq_complete_request(req, status);
-}
-
 static void nvme_free_queue(struct nvme_queue *nvmeq)
 {
 	dma_free_coherent(nvmeq->q_dmadev, CQ_SIZE(nvmeq->q_depth),
Signature · 1 line
1.9.1