linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hch@infradead.org (Christoph Hellwig)
Subject: [PATCH 3/4] NVMe: Surprise removal fixes
Date: Mon, 8 Feb 2016 10:16:40 -0800	[thread overview]
Message-ID: <20160208181640.GD13126@infradead.org> (raw)
In-Reply-To: <1454515543-21683-4-git-send-email-keith.busch@intel.com>

On Wed, Feb 03, 2016@09:05:42AM -0700, Keith Busch wrote:
> Temporarily halts IO queues on surprise removal prior to flushing
> pending requests to an error completion.
> 
> Signed-off-by: Keith Busch <keith.busch at intel.com>
> ---
>  drivers/nvme/host/core.c | 13 +++++++------
>  drivers/nvme/host/pci.c  | 14 ++++++++++++++
>  2 files changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 9d415489..f11cb5a 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1186,15 +1186,16 @@ static void nvme_ns_remove(struct nvme_ns *ns)
>  	lockdep_assert_held(&ns->ctrl->namespaces_mutex);
>  
>  	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.
> +		 * The request queue is currently stoppped if we got here.
> +		 * Prevent new requests from entering before flushing the rest.
> +		 * New requests will fail to enter a dying frozen queue, which
> +		 * allows blk_cleanup_queue to complete.
>  		 */
> +		blk_mq_freeze_queue_start(ns->queue);
> +		blk_set_queue_dying(ns->queue);
>  		blk_mq_abort_requeue_list(ns->queue);
> +		blk_mq_start_hw_queues(ns->queue);
>  	}

Do we really still need all this magic if ->queue_rq returns a failure
if the queue is dying?

> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 72ef832..4cc7398 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -640,6 +640,11 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
>  	struct nvme_command cmnd;
>  	int ret = BLK_MQ_RQ_QUEUE_OK;
>  
> +	if (unlikely(blk_queue_dying(req->q))) {
> +		blk_mq_end_request(req, -EFAULT);
> +		return BLK_MQ_RQ_QUEUE_OK;
> +	}

"Bad address" is a really odd error for a dying block device.

  reply	other threads:[~2016-02-08 18:16 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-03 16:05 [PATCH 0/4] NVMe: Surprise removal fixes Keith Busch
2016-02-03 16:05 ` [PATCH 1/4] NVMe: Fix io incapable return values Keith Busch
2016-02-04 15:55   ` Sagi Grimberg
2016-02-08 18:10   ` Christoph Hellwig
2016-02-03 16:05 ` [PATCH 2/4] NVMe: Sync stopped queues with block layer Keith Busch
2016-02-04 15:57   ` Sagi Grimberg
2016-02-04 16:00     ` Keith Busch
2016-02-08 18:11   ` Christoph Hellwig
2016-02-03 16:05 ` [PATCH 3/4] NVMe: Surprise removal fixes Keith Busch
2016-02-08 18:16   ` Christoph Hellwig [this message]
2016-02-08 18:38     ` Keith Busch
2016-02-08 23:48       ` Keith Busch
2016-02-03 16:05 ` [PATCH 4/4] blk-mq: End unstarted requests on dying queue Keith Busch
2016-02-04 15:59   ` Sagi Grimberg
2016-02-08 18:13   ` Christoph Hellwig
2016-02-04  3:25 ` [PATCH 0/4] NVMe: Surprise removal fixes Wenbo Wang
2016-02-04 15:52   ` Keith Busch
2016-02-04 15:55 ` 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=20160208181640.GD13126@infradead.org \
    --to=hch@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).