All of lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH v2 1/2] nvme: switch to RCU freeing the namespace
Date: Tue, 17 May 2016 11:23:59 -0400	[thread overview]
Message-ID: <20160517152359.GC14260@localhost.localdomain> (raw)
In-Reply-To: <20160517150511.GB14260@localhost.localdomain>

On Tue, May 17, 2016@11:05:11AM -0400, Keith Busch wrote:
> Today, though, the driver has newer checks so it doesn't crash when
> blk-mq submits a command the driver can't handle. If we change the nvme
> pci driver's nvme_queue_rq to stop hw queues before returning
> BLK_MQ_RQ_QUEUE_BUSY (scsi_queue_rq() in scsi_lib.c might be a good
> example), we could skip cancelling requeue work in "nvme_stop_queues()"
> if we're sure it won't race with the reset work's nvme_start_queues().

Untested patch below:

---
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 643f457..13d3cf9 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1552,7 +1552,6 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl)
 		queue_flag_set(QUEUE_FLAG_STOPPED, ns->queue);
 		spin_unlock_irq(ns->queue->queue_lock);
 
-		blk_mq_cancel_requeue_work(ns->queue);
 		blk_mq_stop_hw_queues(ns->queue);
 	}
 	mutex_unlock(&ctrl->namespaces_mutex);
@@ -1565,7 +1564,10 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
 
 	mutex_lock(&ctrl->namespaces_mutex);
 	list_for_each_entry(ns, &ctrl->namespaces, list) {
-		queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, ns->queue);
+		spin_lock_irq(ns->queue->queue_lock);
+		queue_flag_clear(QUEUE_FLAG_STOPPED, ns->queue);
+		spin_unlock_irq(ns->queue->queue_lock);
+
 		blk_mq_start_stopped_hw_queues(ns->queue, true);
 		blk_mq_kick_requeue_list(ns->queue);
 	}
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4fd733f..b65d7d6 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -690,6 +690,12 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 	spin_unlock_irq(&nvmeq->q_lock);
 	return BLK_MQ_RQ_QUEUE_OK;
 out:
+	if (ret == BLK_MQ_RQ_QUEUE_BUSY) {
+		spin_lock_irq(ns->queue->queue_lock);
+		if (!blk_queue_stopped(req->q))
+			blk_mq_stop_hw_queues(ns->queue);
+		spin_unlock_irq(ns->queue->queue_lock);
+	}
 	nvme_free_iod(dev, req);
 	return ret;
 }
--

  reply	other threads:[~2016-05-17 15:23 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-25 21:20 [PATCH v2 0/2] nvme_ns_remove() deadlock fix Ming Lin
2016-04-25 21:20 ` [PATCH v2 1/2] nvme: switch to RCU freeing the namespace Ming Lin
2016-04-26  8:41   ` Christoph Hellwig
2016-04-26 21:17   ` Sagi Grimberg
2016-05-15  6:58   ` Ming Lin
2016-05-16 22:38     ` Ming Lin
2016-05-17 15:05       ` Keith Busch
2016-05-17 15:23         ` Keith Busch [this message]
2016-05-17 15:30           ` Keith Busch
2016-05-17 20:48             ` Ming Lin
2016-05-17 21:07               ` Keith Busch
2016-05-17 21:09                 ` Ming Lin
2016-05-17 21:25                   ` Keith Busch
2016-05-19  5:52                     ` Ming Lin
2016-05-19 20:48                       ` Keith Busch
2016-05-20 14:16                         ` Keith Busch
2016-05-20 17:57                           ` Ming Lin
2016-05-23 10:38                           ` Christoph Hellwig
2016-05-23 15:22                             ` Keith Busch
2016-04-25 21:20 ` [PATCH v2 2/2] nvme: fix nvme_ns_remove() deadlock Ming Lin
2016-04-26  8:42   ` Christoph Hellwig
2016-04-26 21:17   ` Sagi Grimberg
2016-04-26 15:39 ` [PATCH v2 0/2] nvme_ns_remove() deadlock fix Keith Busch
2016-05-02 15:16 ` Jens Axboe

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=20160517152359.GC14260@localhost.localdomain \
    --to=keith.busch@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.