From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH 1/5] nvme-rdma: Fix device removal handling
Date: Fri, 29 Jul 2016 22:57:18 +0300 [thread overview]
Message-ID: <1469822242-3477-2-git-send-email-sagi@grimberg.me> (raw)
In-Reply-To: <1469822242-3477-1-git-send-email-sagi@grimberg.me>
Device removal sequence may have crashed because the
controller (and admin queue space) was freed before
we destroyed the admin queue resources. Thus we
want to destroy the admin queue and only then queue
controller deletion and wait for it to complete.
More specifically we:
1. own the controller deletion (make sure we are not
competing with another deletion).
2. get rid of inflight reconnects if exists (which
also destroy and create queues).
3. destroy the queue.
4. safely queue controller deletion (and wait for it
to complete).
Reported-by: Steve Wise <swise at opengridcomputing.com>
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
drivers/nvme/host/rdma.c | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 21ecbf3f3603..f391d67e4ee0 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -169,7 +169,6 @@ MODULE_PARM_DESC(register_always,
static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,
struct rdma_cm_event *event);
static void nvme_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc);
-static int __nvme_rdma_del_ctrl(struct nvme_rdma_ctrl *ctrl);
/* XXX: really should move to a generic header sooner or later.. */
static inline void put_unaligned_le24(u32 val, u8 *p)
@@ -1318,37 +1317,39 @@ out_destroy_queue_ib:
* that caught the event. Since we hold the callout until the controller
* deletion is completed, we'll deadlock if the controller deletion will
* call rdma_destroy_id on this queue's cm_id. Thus, we claim ownership
- * of destroying this queue before-hand, destroy the queue resources
- * after the controller deletion completed with the exception of destroying
- * the cm_id implicitely by returning a non-zero rc to the callout.
+ * of destroying this queue before-hand, destroy the queue resources,
+ * then queue the controller deletion which won't destroy this queue and
+ * we destroy the cm_id implicitely by returning a non-zero rc to the callout.
*/
static int nvme_rdma_device_unplug(struct nvme_rdma_queue *queue)
{
struct nvme_rdma_ctrl *ctrl = queue->ctrl;
- int ret, ctrl_deleted = 0;
+ int ret;
- /* First disable the queue so ctrl delete won't free it */
- if (!test_and_clear_bit(NVME_RDMA_Q_CONNECTED, &queue->flags))
- goto out;
+ /* Own the controller deletion */
+ if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING))
+ return 0;
- /* delete the controller */
- ret = __nvme_rdma_del_ctrl(ctrl);
- if (!ret) {
- dev_warn(ctrl->ctrl.device,
- "Got rdma device removal event, deleting ctrl\n");
- flush_work(&ctrl->delete_work);
+ dev_warn(ctrl->ctrl.device,
+ "Got rdma device removal event, deleting ctrl\n");
- /* Return non-zero so the cm_id will destroy implicitly */
- ctrl_deleted = 1;
+ /* Get rid of reconnect work if its running */
+ cancel_delayed_work_sync(&ctrl->reconnect_work);
+ /* Disable the queue so ctrl delete won't free it */
+ if (test_and_clear_bit(NVME_RDMA_Q_CONNECTED, &queue->flags)) {
/* Free this queue ourselves */
- rdma_disconnect(queue->cm_id);
- ib_drain_qp(queue->qp);
+ nvme_rdma_stop_queue(queue);
nvme_rdma_destroy_queue_ib(queue);
+
+ /* Return non-zero so the cm_id will destroy implicitly */
+ ret = 1;
}
-out:
- return ctrl_deleted;
+ /* Queue controller deletion */
+ queue_work(nvme_rdma_wq, &ctrl->delete_work);
+ flush_work(&ctrl->delete_work);
+ return ret;
}
static int nvme_rdma_cm_handler(struct rdma_cm_id *cm_id,
--
1.9.1
next prev parent reply other threads:[~2016-07-29 19:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-29 19:57 [PATCH 0/5] Some fabrics fixes Sagi Grimberg
2016-07-29 19:57 ` Sagi Grimberg [this message]
2016-08-01 11:00 ` [PATCH 1/5] nvme-rdma: Fix device removal handling Christoph Hellwig
2016-07-29 19:57 ` [PATCH 2/5] nvme-rdma: Free the I/O tags when we delete the controller Sagi Grimberg
2016-08-01 11:03 ` Christoph Hellwig
2016-08-01 11:15 ` Sagi Grimberg
2016-08-01 15:47 ` Christoph Hellwig
2016-08-02 6:14 ` Sagi Grimberg
2016-07-29 19:57 ` [PATCH 3/5] nvme-rdma: Make sure to shutdown the controller if we can Sagi Grimberg
2016-08-01 11:04 ` Christoph Hellwig
2016-08-01 11:17 ` Sagi Grimberg
2016-08-01 15:48 ` Christoph Hellwig
2016-08-02 6:19 ` Sagi Grimberg
2016-08-02 12:52 ` Christoph Hellwig
2016-08-02 13:26 ` Sagi Grimberg
2016-07-29 19:57 ` [PATCH 4/5] nvme-rdma: Remove duplicate call to nvme_remove_namespaces Sagi Grimberg
2016-08-01 11:06 ` Christoph Hellwig
2016-08-01 11:21 ` Sagi Grimberg
2016-07-29 19:57 ` [PATCH 5/5] nvme-loop: " Sagi Grimberg
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=1469822242-3477-2-git-send-email-sagi@grimberg.me \
--to=sagi@grimberg.me \
/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).