All of lore.kernel.org
 help / color / mirror / Atom feed
From: sagig@dev.mellanox.co.il (Sagi Grimberg)
Subject: [PATCH for-4.5 10/13] NVMe: Move error handling to failed reset handler
Date: Thu, 11 Feb 2016 14:50:54 +0200	[thread overview]
Message-ID: <56BC83AE.8080702@dev.mellanox.co.il> (raw)
In-Reply-To: <1455128250-5984-11-git-send-email-keith.busch@intel.com>



On 10/02/2016 20:17, Keith Busch wrote:
> This moves the dead queue handling out of the namespace removal path
> and into the reset failure path. It fixes a deadlock condition if the
> controller fails or link down during del_gendisk.

How does it fix the deadlock?

>
> Signed-off-by: Keith Busch <keith.busch at intel.com>
> ---
>   drivers/nvme/host/core.c | 19 ++-----------------
>   drivers/nvme/host/nvme.h |  1 +
>   drivers/nvme/host/pci.c  | 22 ++++++++++++++++++++++
>   3 files changed, 25 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index be27f9f..41b595c 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -64,7 +64,7 @@ static void nvme_free_ns(struct kref *kref)
>   	kfree(ns);
>   }
>
> -static void nvme_put_ns(struct nvme_ns *ns)
> +void nvme_put_ns(struct nvme_ns *ns)
>   {
>   	kref_put(&ns->kref, nvme_free_ns);
>   }
> @@ -1113,28 +1113,13 @@ static struct nvme_ns *nvme_find_ns(struct nvme_ctrl *ctrl, unsigned nsid)
>   static void nvme_ns_remove_work(struct work_struct *work)
>   {
>   	struct nvme_ns *ns = container_of(work, struct nvme_ns, remove_work);
> -	bool kill = nvme_io_incapable(ns->ctrl) &&
> -			!blk_queue_dying(ns->queue);
> -
> -	if (kill) {
> -		blk_set_queue_dying(ns->queue);
> -
> -		/*
> -		 * The controller was shutdown first if we got here through
> -		 * device removal. The shutdown may requeue outstanding
> -		 * requests. These need to be aborted immediately so
> -		 * del_gendisk doesn't block indefinitely for their completion.
> -		 */
> -		blk_mq_abort_requeue_list(ns->queue);
> -	}
> +
>   	if (ns->disk->flags & GENHD_FL_UP) {
>   		if (blk_get_integrity(ns->disk))
>   			blk_integrity_unregister(ns->disk);
>   		sysfs_remove_group(&disk_to_dev(ns->disk)->kobj,
>   					&nvme_ns_attr_group);
>   		del_gendisk(ns->disk);
> -	}
> -	if (kill || !blk_queue_dying(ns->queue)) {
>   		blk_mq_abort_requeue_list(ns->queue);
>   		blk_cleanup_queue(ns->queue);
>   	}
> diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
> index d330512..19a64b2 100644
> --- a/drivers/nvme/host/nvme.h
> +++ b/drivers/nvme/host/nvme.h
> @@ -270,6 +270,7 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned fid, unsigned nsid,
>   int nvme_set_features(struct nvme_ctrl *dev, unsigned fid, unsigned dword11,
>   			dma_addr_t dma_addr, u32 *result);
>   int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
> +void nvme_put_ns(struct nvme_ns *ns);
>
>   extern spinlock_t dev_list_lock;
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 3381bac..a18e4ab 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -1898,11 +1898,33 @@ static void nvme_pci_free_ctrl(struct nvme_ctrl *ctrl)
>   	kfree(dev);
>   }
>
> +static void nvme_kill_ns_queues(struct nvme_dev *dev)
> +{
> +	struct nvme_ns *ns;
> +	struct nvme_ctrl *ctrl = &dev->ctrl;
> +
> +	nvme_dev_disable(dev, false);
> +
> +	mutex_lock(&ctrl->namespaces_mutex);
> +	list_for_each_entry(ns, &ctrl->namespaces, list) {
> +		if (!kref_get_unless_zero(&ns->kref))
> +			continue;
> +
> +		blk_set_queue_dying(ns->queue);
> +		blk_mq_abort_requeue_list(ns->queue);
> +		blk_mq_start_stopped_hw_queues(ns->queue, true);
> +
> +		nvme_put_ns(ns);
> +	}
> +	mutex_unlock(&ctrl->namespaces_mutex);
> +}
> +

Why on earth is this pci specific? This should be in the
core. Aside from that, I'd really prefer if the core can handle this
without having the pci (or other) triggering it explicitly, but if
this must move out of the ns remove then we need documentation on
what are the rules of when the driver needs to call it.

  parent reply	other threads:[~2016-02-11 12:50 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-10 18:17 [PATCH for-4.5 00/13] NVMe fixups for 4.5 Keith Busch
2016-02-10 18:17 ` [PATCH for-4.5 01/13] blk-mq: End unstarted requests on dying queue Keith Busch
2016-02-11 12:13   ` Johannes Thumshirn
2016-02-11 12:30   ` Sagi Grimberg
2016-02-10 18:17 ` [PATCH for-4.5 02/13] NVMe: Fix io incapable return values Keith Busch
2016-02-11 12:14   ` Johannes Thumshirn
2016-02-10 18:17 ` [PATCH for-4.5 03/13] NVMe: Allow request merges Keith Busch
2016-02-10 18:36   ` Christoph Hellwig
2016-02-10 18:37     ` Jens Axboe
2016-02-10 21:01       ` Keith Busch
2016-02-10 21:19         ` Jens Axboe
2016-02-11 12:15   ` Johannes Thumshirn
2016-02-11 12:33   ` Sagi Grimberg
2016-02-10 18:17 ` [PATCH for-4.5 04/13] NVMe: Set queue limits max_dev_sectors Keith Busch
2016-02-10 18:20   ` Christoph Hellwig
2016-02-10 18:24     ` Keith Busch
2016-02-10 18:40       ` Christoph Hellwig
2016-02-10 19:49         ` Keith Busch
2016-02-10 22:53           ` Martin K. Petersen
2016-02-10 18:17 ` [PATCH for-4.5 05/13] NVMe: Fix namespace removal deadlock Keith Busch
2016-02-11 12:19   ` Johannes Thumshirn
2016-02-11 16:38   ` Wenbo Wang
2016-02-10 18:17 ` [PATCH for-4.5 06/13] NVMe: Remove WQ_MEM_RECLAIM from nvme work queue Keith Busch
2016-02-10 18:46   ` Christoph Hellwig
2016-02-10 23:37     ` Keith Busch
2016-02-11 14:52     ` Keith Busch
2016-02-10 18:17 ` [PATCH for-4.5 07/13] NVMe: Requeue requests on suspended queues Keith Busch
2016-02-10 18:47   ` Christoph Hellwig
2016-02-11 12:22   ` Johannes Thumshirn
2016-02-11 12:41   ` Sagi Grimberg
2016-02-11 16:47   ` Wenbo Wang
2016-02-11 17:00     ` Keith Busch
2016-02-11 17:21       ` Wenbo Wang
2016-02-10 18:17 ` [PATCH for-4.5 08/13] NVMe: Poll device while still active during remove Keith Busch
2016-02-10 18:48   ` Christoph Hellwig
2016-02-11 12:26   ` Johannes Thumshirn
2016-02-11 12:42   ` Sagi Grimberg
2016-02-10 18:17 ` [PATCH for-4.5 09/13] NVMe: Simplify device reset failure Keith Busch
2016-02-10 18:53   ` Christoph Hellwig
2016-02-11 12:28   ` Johannes Thumshirn
2016-02-10 18:17 ` [PATCH for-4.5 10/13] NVMe: Move error handling to failed reset handler Keith Busch
2016-02-11 12:34   ` Johannes Thumshirn
2016-02-11 12:50   ` Sagi Grimberg [this message]
2016-02-11 15:11     ` Keith Busch
2016-02-10 18:17 ` [PATCH for-4.5 11/13] NVMe: Dead namespace handling Keith Busch
2016-02-11 12:43   ` Johannes Thumshirn
2016-02-11 12:59   ` Sagi Grimberg
2016-02-11 15:07     ` Keith Busch
2016-02-10 18:17 ` [PATCH for-4.5 12/13] NVMe: Mark queues as dead on degraded controller Keith Busch
2016-02-11 12:44   ` Johannes Thumshirn
2016-02-11 13:00   ` Sagi Grimberg
2016-02-10 18:17 ` [PATCH for-4.5 13/13] NVMe: Rate limit nvme IO warnings Keith Busch
2016-02-10 18:54   ` Christoph Hellwig
2016-02-10 21:10     ` Keith Busch
2016-02-11 12:29       ` Sagi Grimberg
2016-02-11 15:12         ` Keith Busch
2016-02-11 15:18           ` Christoph Hellwig

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=56BC83AE.8080702@dev.mellanox.co.il \
    --to=sagig@dev.mellanox.co.il \
    /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.