linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
To: kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, willy@infradead.org
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>,
	linux-nvme@lists.infradead.org
Subject: [PATCH V3 08/10] nvme: centralize queue action nvme_start_queues()
Date: Tue, 14 Jul 2020 16:30:55 -0700	[thread overview]
Message-ID: <20200714233057.10915-9-chaitanya.kulkarni@wdc.com> (raw)
In-Reply-To: <20200714233057.10915-1-chaitanya.kulkarni@wdc.com>

There is no point in having 7 different functions which are differing
with just one line.

The helper functions for ctrl queue management can be centralized with
the help of the descriptive enums for action. This avoids code
duplication which spans across the 7 functions as compare to one
function and exporting 7 symbols as compare to one symbol.

This patch merges nvme_start_queues() into newly introduced
nvme_queue_act() which handles the queue management.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/core.c | 17 +++++------------
 drivers/nvme/host/fc.c   |  2 +-
 drivers/nvme/host/nvme.h |  2 +-
 drivers/nvme/host/pci.c  |  4 ++--
 drivers/nvme/host/rdma.c |  4 ++--
 drivers/nvme/host/tcp.c  |  4 ++--
 6 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e237339616af..6504e713c0fb 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -4233,7 +4233,7 @@ static void nvme_fw_act_work(struct work_struct *work)
 	if (!nvme_change_ctrl_state(ctrl, NVME_CTRL_LIVE))
 		return;
 
-	nvme_start_queues(ctrl);
+	nvme_queue_act(ctrl, NVME_START_QUEUES);
 	/* read FW slot information to clear the AER */
 	nvme_get_fw_slot_info(ctrl);
 }
@@ -4318,7 +4318,7 @@ void nvme_start_ctrl(struct nvme_ctrl *ctrl)
 
 	if (ctrl->queue_count > 1) {
 		nvme_queue_scan(ctrl);
-		nvme_start_queues(ctrl);
+		nvme_queue_act(ctrl, NVME_START_QUEUES);
 	}
 	ctrl->created = true;
 }
@@ -4484,6 +4484,9 @@ void nvme_queue_act(struct nvme_ctrl *ctrl, enum nvme_queue_act op)
 		case NVME_STOP_QUEUES:
 			blk_mq_quiesce_queue(ns->queue);
 			break;
+		case NVME_START_QUEUES:
+			blk_mq_unquiesce_queue(ns->queue);
+			break;
 		default:
 			pr_warn("invalid %s op 0x%x\n", __func__, op);
 			break;
@@ -4505,16 +4508,6 @@ void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout)
 }
 EXPORT_SYMBOL_GPL(nvme_wait_freeze_timeout);
 
-void nvme_start_queues(struct nvme_ctrl *ctrl)
-{
-	struct nvme_ns *ns;
-	unsigned long idx;
-
-	xa_for_each(&ctrl->namespaces, idx, ns)
-		blk_mq_unquiesce_queue(ns->queue);
-}
-EXPORT_SYMBOL_GPL(nvme_start_queues);
-
 void nvme_sync_queues(struct nvme_ctrl *ctrl)
 {
 	struct nvme_ns *ns;
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 683b6d1a8e1c..900aece3cb7c 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -3192,7 +3192,7 @@ nvme_fc_delete_association(struct nvme_fc_ctrl *ctrl)
 	blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
 
 	/* resume the io queues so that things will fast fail */
-	nvme_start_queues(&ctrl->ctrl);
+	nvme_queue_act(&ctrl->ctrl, NVME_START_QUEUES);
 
 	nvme_fc_ctlr_inactive_on_rport(ctrl);
 }
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 59cbd890e38b..419070d0c442 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -551,10 +551,10 @@ enum nvme_queue_act {
 	NVME_WAIT_FREEZE_QUEUES,
 	NVME_START_FREEZE_QUEUES,
 	NVME_STOP_QUEUES,
+	NVME_START_QUEUES,
 };
 
 void nvme_queue_act(struct nvme_ctrl *ctrl, enum nvme_queue_act op);
-void nvme_start_queues(struct nvme_ctrl *ctrl);
 void nvme_sync_queues(struct nvme_ctrl *ctrl);
 void nvme_wait_freeze_timeout(struct nvme_ctrl *ctrl, long timeout);
 
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 1112e6ec5ab1..b7e14b86e00a 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2440,7 +2440,7 @@ static void nvme_dev_disable(struct nvme_dev *dev, bool shutdown)
 	 * deadlocking blk-mq hot-cpu notifier.
 	 */
 	if (shutdown) {
-		nvme_start_queues(&dev->ctrl);
+		nvme_queue_act(&dev->ctrl, NVME_START_QUEUES);
 		if (dev->ctrl.admin_q && !blk_queue_dying(dev->ctrl.admin_q))
 			blk_mq_unquiesce_queue(dev->ctrl.admin_q);
 	}
@@ -2621,7 +2621,7 @@ static void nvme_reset_work(struct work_struct *work)
 		nvme_remove_namespaces(&dev->ctrl);
 		nvme_free_tagset(dev);
 	} else {
-		nvme_start_queues(&dev->ctrl);
+		nvme_queue_act(&dev->ctrl, NVME_START_QUEUES);
 		nvme_queue_act(&dev->ctrl, NVME_WAIT_FREEZE_QUEUES);
 		nvme_dev_add(dev);
 		nvme_queue_act(&dev->ctrl, NVME_UNFREEZE_QUEUES);
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index e2a7608548e5..9218d3e3f065 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -991,7 +991,7 @@ static void nvme_rdma_teardown_io_queues(struct nvme_rdma_ctrl *ctrl,
 			blk_mq_tagset_wait_completed_request(ctrl->ctrl.tagset);
 		}
 		if (remove)
-			nvme_start_queues(&ctrl->ctrl);
+			nvme_queue_act(&ctrl->ctrl, NVME_START_QUEUES);
 		nvme_rdma_destroy_io_queues(ctrl, remove);
 	}
 }
@@ -1129,7 +1129,7 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work)
 
 	nvme_stop_keep_alive(&ctrl->ctrl);
 	nvme_rdma_teardown_io_queues(ctrl, false);
-	nvme_start_queues(&ctrl->ctrl);
+	nvme_queue_act(&ctrl->ctrl, NVME_START_QUEUES);
 	nvme_rdma_teardown_admin_queue(ctrl, false);
 	blk_mq_unquiesce_queue(ctrl->ctrl.admin_q);
 
diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
index cf3db9025df3..1ea0dc89f677 100644
--- a/drivers/nvme/host/tcp.c
+++ b/drivers/nvme/host/tcp.c
@@ -1892,7 +1892,7 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl,
 		blk_mq_tagset_wait_completed_request(ctrl->tagset);
 	}
 	if (remove)
-		nvme_start_queues(ctrl);
+		nvme_queue_act(ctrl, NVME_START_QUEUES);
 	nvme_tcp_destroy_io_queues(ctrl, remove);
 }
 
@@ -2005,7 +2005,7 @@ static void nvme_tcp_error_recovery_work(struct work_struct *work)
 	nvme_stop_keep_alive(ctrl);
 	nvme_tcp_teardown_io_queues(ctrl, false);
 	/* unquiesce to fail fast pending requests */
-	nvme_start_queues(ctrl);
+	nvme_queue_act(ctrl, NVME_START_QUEUES);
 	nvme_tcp_teardown_admin_queue(ctrl, false);
 	blk_mq_unquiesce_queue(ctrl->admin_q);
 
-- 
2.26.0


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

  parent reply	other threads:[~2020-07-14 23:32 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 23:30 [PATCH V3 00/10] nvme: use xarray for ns tracking Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 01/10] xarray: add __xa_load() version Chaitanya Kulkarni
2020-07-15  0:46   ` Keith Busch
2020-07-15  0:47     ` Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 02/10] nvme-core: use xarray for ctrl ns tracking Chaitanya Kulkarni
2020-07-15  0:55   ` Keith Busch
2020-07-15  1:33     ` Matthew Wilcox
2020-07-15  1:41       ` Keith Busch
2020-07-15  5:12         ` Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 03/10] nvme: centralize queue action nvme_kill_queues() Chaitanya Kulkarni
2020-07-15  1:36   ` Keith Busch
2020-07-15  1:39     ` Matthew Wilcox
2020-07-15  7:11   ` Christoph Hellwig
2020-07-14 23:30 ` [PATCH V3 04/10] nvme: centralize queue action nvme_unfreeze() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 05/10] nvme: centralize queue action nvme_wait_freeze() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 06/10] nvme: centralize queue action nvme_start_freeze() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 07/10] nvme: centralize queue action nvme_stop_queues() Chaitanya Kulkarni
2020-07-14 23:30 ` Chaitanya Kulkarni [this message]
2020-07-14 23:30 ` [PATCH V3 09/10] nvme: centralize queue action nvme_sync_queues() Chaitanya Kulkarni
2020-07-14 23:30 ` [PATCH V3 10/10] nvmet: use xarray for ctrl ns storing Chaitanya Kulkarni
2020-07-15  7:10   ` Christoph Hellwig
2020-07-17  1:52     ` Chaitanya Kulkarni
2020-07-15  7:03 ` [PATCH V3 00/10] nvme: use xarray for ns tracking Christoph Hellwig
2020-07-16  1:48   ` Chaitanya Kulkarni
2020-07-17  2:02   ` Chaitanya Kulkarni

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=20200714233057.10915-9-chaitanya.kulkarni@wdc.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=willy@infradead.org \
    /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).