Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 for-4.6 0/3] Provide better active I/O termination handlers
@ 2016-03-09 17:23 Sagi Grimberg
  2016-03-09 17:23 ` [PATCH v2 for-4.6 1/3] blk-mq: Export tagset iter function Sagi Grimberg
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sagi Grimberg @ 2016-03-09 17:23 UTC (permalink / raw)


This patchset adds helper to active IO termination to block layer
based on the pci nvme_clear_queues() functionality. This is needed
for live shutdowns and resets during live IO and it's not nvme/pci
specific and will be needed for other transports as well.

This patchset applies on top of "for-4.6-drivers" patchset.

Changes from v1:
- rebase on top of for-4.6-drivers (small fuzz)
- incorporate a fix from hch to carefully check for valid tagsets

Changes from v0:
- Removed the nvme core helpers for IO termination and have pci
  use blk-mq helper directly
- Rebased on top of Keith and Christoph's patches

Sagi Grimberg (3):
  blk-mq: Export tagset iter function
  nvme: Use blk-mq helper for IO termination
  blk-mq: Make blk_mq_all_tag_busy_iter static

 block/blk-mq-tag.c      | 17 ++++++++++++++---
 drivers/nvme/host/pci.c | 19 +++++--------------
 include/linux/blk-mq.h  |  4 ++--
 3 files changed, 21 insertions(+), 19 deletions(-)

-- 
1.8.4.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 1/3] blk-mq: Export tagset iter function
  2016-03-09 17:23 [PATCH v2 for-4.6 0/3] Provide better active I/O termination handlers Sagi Grimberg
@ 2016-03-09 17:23 ` Sagi Grimberg
  2016-03-10  8:33   ` Johannes Thumshirn
  2016-03-09 17:23 ` [PATCH v2 for-4.6 2/3] nvme: Use blk-mq helper for IO termination Sagi Grimberg
  2016-03-09 17:23 ` [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static Sagi Grimberg
  2 siblings, 1 reply; 9+ messages in thread
From: Sagi Grimberg @ 2016-03-09 17:23 UTC (permalink / raw)


Its useful to iterate on all the active tags in cases
where we will need to fail all the queues IO.

Signed-off-by: Sagi Grimberg <sagig at mellanox.com>
[hch: carefully check for valid tagsets]
Reviewed-by: Christoph Hellwig <hch at lst.de>
---
 block/blk-mq-tag.c     | 12 ++++++++++++
 include/linux/blk-mq.h |  2 ++
 2 files changed, 14 insertions(+)

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index abdbb47405cb..2fd04286f103 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -474,6 +474,18 @@ void blk_mq_all_tag_busy_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
 }
 EXPORT_SYMBOL(blk_mq_all_tag_busy_iter);
 
+void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+		busy_tag_iter_fn *fn, void *priv)
+{
+	int i;
+
+	for (i = 0; i < tagset->nr_hw_queues; i++) {
+		if (tagset->tags && tagset->tags[i])
+			blk_mq_all_tag_busy_iter(tagset->tags[i], fn, priv);
+	}
+}
+EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
+
 void blk_mq_queue_tag_busy_iter(struct request_queue *q, busy_iter_fn *fn,
 		void *priv)
 {
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 15a73d49fd1d..865ee7016b72 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -240,6 +240,8 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async);
 void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs);
 void blk_mq_all_tag_busy_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
 		void *priv);
+void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+		busy_tag_iter_fn *fn, void *priv);
 void blk_mq_freeze_queue(struct request_queue *q);
 void blk_mq_unfreeze_queue(struct request_queue *q);
 void blk_mq_freeze_queue_start(struct request_queue *q);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 2/3] nvme: Use blk-mq helper for IO termination
  2016-03-09 17:23 [PATCH v2 for-4.6 0/3] Provide better active I/O termination handlers Sagi Grimberg
  2016-03-09 17:23 ` [PATCH v2 for-4.6 1/3] blk-mq: Export tagset iter function Sagi Grimberg
@ 2016-03-09 17:23 ` Sagi Grimberg
  2016-03-10  8:33   ` Johannes Thumshirn
  2016-03-09 17:23 ` [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static Sagi Grimberg
  2 siblings, 1 reply; 9+ messages in thread
From: Sagi Grimberg @ 2016-03-09 17:23 UTC (permalink / raw)


blk-mq offers a tagset iterator so let's use that
instead of using nvme_clear_queues.

Note, we changed nvme_queue_cancel_ios name to nvme_cancel_io
as there is no concept of a queue now in this function (we
also lost the print).

Signed-off-by: Sagi Grimberg <sagig at mellanox.com>
Reviewed-by: Christoph Hellwig <hch at lst.de>
Acked-by: Keith Busch <keith.busch at intel.com>
---
 drivers/nvme/host/pci.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index e9f18e1d73e5..b713b390aa4f 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -982,16 +982,15 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
 	return BLK_EH_RESET_TIMER;
 }
 
-static void nvme_cancel_queue_ios(struct request *req, void *data, bool reserved)
+static void nvme_cancel_io(struct request *req, void *data, bool reserved)
 {
-	struct nvme_queue *nvmeq = data;
+	struct nvme_dev *dev = data;
 	int status;
 
 	if (!blk_mq_request_started(req))
 		return;
 
-	dev_warn(nvmeq->dev->ctrl.device,
-		 "Cancelling I/O %d QID %d\n", req->tag, nvmeq->qid);
+	dev_warn(dev->ctrl.device, "Cancelling I/O %d\n", req->tag);
 
 	status = NVME_SC_ABORT_REQ;
 	if (blk_queue_dying(req->q))
@@ -1048,14 +1047,6 @@ static int nvme_suspend_queue(struct nvme_queue *nvmeq)
 	return 0;
 }
 
-static void nvme_clear_queue(struct nvme_queue *nvmeq)
-{
-	spin_lock_irq(&nvmeq->q_lock);
-	if (nvmeq->tags && *nvmeq->tags)
-		blk_mq_all_tag_busy_iter(*nvmeq->tags, nvme_cancel_queue_ios, nvmeq);
-	spin_unlock_irq(&nvmeq->q_lock);
-}
-
 static void nvme_disable_admin_queue(struct nvme_dev *dev, bool shutdown)
 {
 	struct nvme_queue *nvmeq = dev->queues[0];
@@ -1779,8 +1770,8 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
 	}
 	nvme_dev_unmap(dev);
 
-	for (i = dev->queue_count - 1; i >= 0; i--)
-		nvme_clear_queue(dev->queues[i]);
+	blk_mq_tagset_busy_iter(&dev->tagset, nvme_cancel_io, dev);
+	blk_mq_tagset_busy_iter(&dev->admin_tagset, nvme_cancel_io, dev);
 	mutex_unlock(&dev->shutdown_lock);
 }
 
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static
  2016-03-09 17:23 [PATCH v2 for-4.6 0/3] Provide better active I/O termination handlers Sagi Grimberg
  2016-03-09 17:23 ` [PATCH v2 for-4.6 1/3] blk-mq: Export tagset iter function Sagi Grimberg
  2016-03-09 17:23 ` [PATCH v2 for-4.6 2/3] nvme: Use blk-mq helper for IO termination Sagi Grimberg
@ 2016-03-09 17:23 ` Sagi Grimberg
  2016-03-09 20:54   ` Keith Busch
  2016-03-10  8:38   ` Johannes Thumshirn
  2 siblings, 2 replies; 9+ messages in thread
From: Sagi Grimberg @ 2016-03-09 17:23 UTC (permalink / raw)


No caller outside the blk-mq code so we can settle
with it static.

Signed-off-by: Sagi Grimberg <sagig at mellanox.com>
Reviewed-by: Christoph Hellwig <hch at lst.de>
---
 block/blk-mq-tag.c     | 5 ++---
 include/linux/blk-mq.h | 2 --
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 2fd04286f103..56a0c37a3d06 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -464,15 +464,14 @@ static void bt_tags_for_each(struct blk_mq_tags *tags,
 	}
 }
 
-void blk_mq_all_tag_busy_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
-		void *priv)
+static void blk_mq_all_tag_busy_iter(struct blk_mq_tags *tags,
+		busy_tag_iter_fn *fn, void *priv)
 {
 	if (tags->nr_reserved_tags)
 		bt_tags_for_each(tags, &tags->breserved_tags, 0, fn, priv, true);
 	bt_tags_for_each(tags, &tags->bitmap_tags, tags->nr_reserved_tags, fn, priv,
 			false);
 }
-EXPORT_SYMBOL(blk_mq_all_tag_busy_iter);
 
 void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
 		busy_tag_iter_fn *fn, void *priv)
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 865ee7016b72..ecd7ea33a99f 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -238,8 +238,6 @@ void blk_mq_start_hw_queues(struct request_queue *q);
 void blk_mq_start_stopped_hw_queues(struct request_queue *q, bool async);
 void blk_mq_run_hw_queues(struct request_queue *q, bool async);
 void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs);
-void blk_mq_all_tag_busy_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
-		void *priv);
 void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
 		busy_tag_iter_fn *fn, void *priv);
 void blk_mq_freeze_queue(struct request_queue *q);
-- 
1.8.4.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static
  2016-03-09 17:23 ` [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static Sagi Grimberg
@ 2016-03-09 20:54   ` Keith Busch
  2016-03-10 10:18     ` Sagi Grimberg
  2016-03-10  8:38   ` Johannes Thumshirn
  1 sibling, 1 reply; 9+ messages in thread
From: Keith Busch @ 2016-03-09 20:54 UTC (permalink / raw)


On Wed, Mar 09, 2016@07:23:04PM +0200, Sagi Grimberg wrote:
> No caller outside the blk-mq code so we can settle
> with it static.

Hi Sagi,

The mtip32xx driver in linux-block/for-next is using
blk_mq_all_tag_busy_iter. This looks like the equivalent change for
that driver:

---
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 1c330b6..71bb370 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3000,14 +3000,14 @@ restart_eh:
 					"Completion workers still active!");
 
 			spin_lock(dd->queue->queue_lock);
-			blk_mq_all_tag_busy_iter(*dd->tags.tags,
+			blk_mq_tagset_busy_iter(&dd->tags,
 							mtip_queue_cmd, dd);
 			spin_unlock(dd->queue->queue_lock);
 
 			set_bit(MTIP_PF_ISSUE_CMDS_BIT, &dd->port->flags);
 
 			if (mtip_device_reset(dd))
-				blk_mq_all_tag_busy_iter(*dd->tags.tags,
+				blk_mq_tagset_busy_iter(&dd->tags,
 							mtip_abort_cmd, dd);
 
 			clear_bit(MTIP_PF_TO_ACTIVE_BIT, &dd->port->flags);
@@ -4175,7 +4175,7 @@ static int mtip_block_remove(struct driver_data *dd)
 
 	blk_mq_freeze_queue_start(dd->queue);
 	blk_mq_stop_hw_queues(dd->queue);
-	blk_mq_all_tag_busy_iter(dd->tags.tags[0], mtip_no_dev_cleanup, dd);
+	blk_mq_tagset_busy_iter(&dd->tags, mtip_no_dev_cleanup, dd);
 
 	/*
 	 * Delete our gendisk structure. This also removes the device
--

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 1/3] blk-mq: Export tagset iter function
  2016-03-09 17:23 ` [PATCH v2 for-4.6 1/3] blk-mq: Export tagset iter function Sagi Grimberg
@ 2016-03-10  8:33   ` Johannes Thumshirn
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Thumshirn @ 2016-03-10  8:33 UTC (permalink / raw)


On Wed, Mar 09, 2016@07:23:02PM +0200, Sagi Grimberg wrote:
> Its useful to iterate on all the active tags in cases
> where we will need to fail all the queues IO.
> 
> Signed-off-by: Sagi Grimberg <sagig at mellanox.com>

Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 2/3] nvme: Use blk-mq helper for IO termination
  2016-03-09 17:23 ` [PATCH v2 for-4.6 2/3] nvme: Use blk-mq helper for IO termination Sagi Grimberg
@ 2016-03-10  8:33   ` Johannes Thumshirn
  0 siblings, 0 replies; 9+ messages in thread
From: Johannes Thumshirn @ 2016-03-10  8:33 UTC (permalink / raw)


On Wed, Mar 09, 2016@07:23:03PM +0200, Sagi Grimberg wrote:
> blk-mq offers a tagset iterator so let's use that
> instead of using nvme_clear_queues.
> 
> Note, we changed nvme_queue_cancel_ios name to nvme_cancel_io
> as there is no concept of a queue now in this function (we
> also lost the print).
> 
> Signed-off-by: Sagi Grimberg <sagig at mellanox.com>

Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static
  2016-03-09 17:23 ` [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static Sagi Grimberg
  2016-03-09 20:54   ` Keith Busch
@ 2016-03-10  8:38   ` Johannes Thumshirn
  1 sibling, 0 replies; 9+ messages in thread
From: Johannes Thumshirn @ 2016-03-10  8:38 UTC (permalink / raw)


On Wed, Mar 09, 2016@07:23:04PM +0200, Sagi Grimberg wrote:
> No caller outside the blk-mq code so we can settle
> with it static.
> 
> Signed-off-by: Sagi Grimberg <sagig at mellanox.com>

With the mtip32xx changes
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>

-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: Felix Imend?rffer, Jane Smithard, Graham Norton
HRB 21284 (AG N?rnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static
  2016-03-09 20:54   ` Keith Busch
@ 2016-03-10 10:18     ` Sagi Grimberg
  0 siblings, 0 replies; 9+ messages in thread
From: Sagi Grimberg @ 2016-03-10 10:18 UTC (permalink / raw)


Thanks!

This should go in before patch #3, so maybe I
should resend a v3 with this incorporated.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-03-10 10:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-09 17:23 [PATCH v2 for-4.6 0/3] Provide better active I/O termination handlers Sagi Grimberg
2016-03-09 17:23 ` [PATCH v2 for-4.6 1/3] blk-mq: Export tagset iter function Sagi Grimberg
2016-03-10  8:33   ` Johannes Thumshirn
2016-03-09 17:23 ` [PATCH v2 for-4.6 2/3] nvme: Use blk-mq helper for IO termination Sagi Grimberg
2016-03-10  8:33   ` Johannes Thumshirn
2016-03-09 17:23 ` [PATCH v2 for-4.6 3/3] blk-mq: Make blk_mq_all_tag_busy_iter static Sagi Grimberg
2016-03-09 20:54   ` Keith Busch
2016-03-10 10:18     ` Sagi Grimberg
2016-03-10  8:38   ` Johannes Thumshirn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox