From: Keith Busch <keith.busch@intel.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Jens Axboe <axboe@fb.com>, Christoph Hellwig <hch@lst.de>,
James Bottomley <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Mike Snitzer <snitzer@redhat.com>,
Doug Ledford <dledford@redhat.com>,
Ming Lei <tom.leiming@gmail.com>,
Laurence Oberman <loberman@redhat.com>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"linux-nvme@lists.infradead.org" <linux-nvme@lists.infradead.org>
Subject: Re: [PATCH 11/12] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code
Date: Fri, 28 Oct 2016 17:06:28 -0400 [thread overview]
Message-ID: <20161028210628.GE5621@localhost.localdomain> (raw)
In-Reply-To: <655c62ca-5da8-3c8f-9e56-016b7d518267@sandisk.com>
On Fri, Oct 28, 2016 at 11:51:35AM -0700, Bart Van Assche wrote:
> I think it is wrong that kicking the requeue list starts stopped queues
> because this makes it impossible to stop request processing without setting
> an additional flag next to BLK_MQ_S_STOPPED. Can you have a look at the
> attached two patches? These patches survive my dm-multipath and SCSI tests.
Hi Bart,
These look good to me, and succesful on my NVMe tests.
Thanks,
Keith
> From e93799f726485a3eeee98837c992c5c0068d7180 Mon Sep 17 00:00:00 2001
> From: Bart Van Assche <bart.vanassche@sandisk.com>
> Date: Fri, 28 Oct 2016 10:48:58 -0700
> Subject: [PATCH 1/2] block: Avoid that requeueing starts stopped queues
>
> Since blk_mq_requeue_work() starts stopped queues and since
> execution of this function can be scheduled after a queue has
> been stopped it is not possible to stop queues without using
> an additional state variable to track whether or not the queue
> has been stopped. Hence modify blk_mq_requeue_work() such that it
> does not start stopped queues. My conclusion after a review of
> the blk_mq_stop_hw_queues() and blk_mq_{delay_,}kick_requeue_list()
> callers is as follows:
> * In the dm driver starting and stopping queues should only happen
> if __dm_suspend() or __dm_resume() is called and not if the
> requeue list is processed.
> * In the SCSI core queue stopping and starting should only be
> performed by the scsi_internal_device_block() and
> scsi_internal_device_unblock() functions but not by any other
> function.
> * In the NVMe core only the functions that call
> blk_mq_start_stopped_hw_queues() explicitly should start stopped
> queues.
> * A blk_mq_start_stopped_hwqueues() call must be added in the
> xen-blkfront driver in its blkif_recover() function.
> ---
> block/blk-mq.c | 6 +-----
> drivers/block/xen-blkfront.c | 1 +
> drivers/md/dm-rq.c | 7 +------
> drivers/scsi/scsi_lib.c | 1 -
> 4 files changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index a49b8af..24dfd0d 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -528,11 +528,7 @@ static void blk_mq_requeue_work(struct work_struct *work)
> blk_mq_insert_request(rq, false, false, false);
> }
>
> - /*
> - * Use the start variant of queue running here, so that running
> - * the requeue work will kick stopped queues.
> - */
> - blk_mq_start_hw_queues(q);
> + blk_mq_run_hw_queues(q, false);
> }
>
> void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,
> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
> index 1ca702d..a3e1727 100644
> --- a/drivers/block/xen-blkfront.c
> +++ b/drivers/block/xen-blkfront.c
> @@ -2045,6 +2045,7 @@ static int blkif_recover(struct blkfront_info *info)
> BUG_ON(req->nr_phys_segments > segs);
> blk_mq_requeue_request(req, false);
> }
> + blk_mq_start_stopped_hwqueues(info->rq);
> blk_mq_kick_requeue_list(info->rq);
>
> while ((bio = bio_list_pop(&info->bio_list)) != NULL) {
> diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
> index 107ed19..b951ae83 100644
> --- a/drivers/md/dm-rq.c
> +++ b/drivers/md/dm-rq.c
> @@ -326,12 +326,7 @@ static void dm_old_requeue_request(struct request *rq)
>
> static void __dm_mq_kick_requeue_list(struct request_queue *q, unsigned long msecs)
> {
> - unsigned long flags;
> -
> - spin_lock_irqsave(q->queue_lock, flags);
> - if (!blk_mq_queue_stopped(q))
> - blk_mq_delay_kick_requeue_list(q, msecs);
> - spin_unlock_irqrestore(q->queue_lock, flags);
> + blk_mq_delay_kick_requeue_list(q, msecs);
> }
>
> void dm_mq_kick_requeue_list(struct mapped_device *md)
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 4cddaff..94f54ac 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1939,7 +1939,6 @@ static int scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
> out:
> switch (ret) {
> case BLK_MQ_RQ_QUEUE_BUSY:
> - blk_mq_stop_hw_queue(hctx);
> if (atomic_read(&sdev->device_busy) == 0 &&
> !scsi_device_blocked(sdev))
> blk_mq_delay_queue(hctx, SCSI_QUEUE_DELAY);
> --
> 2.10.1
>
> From 47eec3bdcf4b673e3ab606543cb3acdf7f4de593 Mon Sep 17 00:00:00 2001
> From: Bart Van Assche <bart.vanassche@sandisk.com>
> Date: Fri, 28 Oct 2016 10:50:04 -0700
> Subject: [PATCH 2/2] blk-mq: Remove blk_mq_cancel_requeue_work()
>
> Since blk_mq_requeue_work() no longer restarts stopped queues
> canceling requeue work is no longer needed to prevent that a
> stopped queue would be restarted. Hence remove this function.
> ---
> block/blk-mq.c | 6 ------
> drivers/md/dm-rq.c | 2 --
> drivers/nvme/host/core.c | 1 -
> include/linux/blk-mq.h | 1 -
> 4 files changed, 10 deletions(-)
>
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 24dfd0d..1aa79e5 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -557,12 +557,6 @@ void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,
> }
> EXPORT_SYMBOL(blk_mq_add_to_requeue_list);
>
> -void blk_mq_cancel_requeue_work(struct request_queue *q)
> -{
> - cancel_delayed_work_sync(&q->requeue_work);
> -}
> -EXPORT_SYMBOL_GPL(blk_mq_cancel_requeue_work);
> -
> void blk_mq_kick_requeue_list(struct request_queue *q)
> {
> kblockd_schedule_delayed_work(&q->requeue_work, 0);
> diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
> index b951ae83..7f426ab 100644
> --- a/drivers/md/dm-rq.c
> +++ b/drivers/md/dm-rq.c
> @@ -102,8 +102,6 @@ static void dm_mq_stop_queue(struct request_queue *q)
> if (blk_mq_queue_stopped(q))
> return;
>
> - /* Avoid that requeuing could restart the queue. */
> - blk_mq_cancel_requeue_work(q);
> blk_mq_stop_hw_queues(q);
> /* Wait until dm_mq_queue_rq() has finished. */
> blk_mq_quiesce_queue(q);
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index d6ab9a0..a67e815 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2075,7 +2075,6 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl)
> list_for_each_entry(ns, &ctrl->namespaces, list) {
> struct request_queue *q = ns->queue;
>
> - blk_mq_cancel_requeue_work(q);
> blk_mq_stop_hw_queues(q);
> blk_mq_quiesce_queue(q);
> }
> diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
> index 76f6319..35a0af5 100644
> --- a/include/linux/blk-mq.h
> +++ b/include/linux/blk-mq.h
> @@ -221,7 +221,6 @@ void __blk_mq_end_request(struct request *rq, int error);
> void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list);
> void blk_mq_add_to_requeue_list(struct request *rq, bool at_head,
> bool kick_requeue_list);
> -void blk_mq_cancel_requeue_work(struct request_queue *q);
> void blk_mq_kick_requeue_list(struct request_queue *q);
> void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs);
> void blk_mq_abort_requeue_list(struct request_queue *q);
> --
> 2.10.1
next prev parent reply other threads:[~2016-10-28 20:55 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 22:49 [PATCH v4 0/12] Fix race conditions related to stopping block layer queues Bart Van Assche
2016-10-26 22:50 ` [PATCH 01/12] blk-mq: Do not invoke .queue_rq() for a stopped queue Bart Van Assche
2016-10-27 5:47 ` Hannes Reinecke
[not found] ` <1debcf7f-c950-308b-d297-3e48a77e08d7-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 8:14 ` Johannes Thumshirn
2016-10-27 12:14 ` Sagi Grimberg
[not found] ` <b22edafc-725f-0419-d074-34d35d57d126-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-26 22:51 ` [PATCH 02/12] blk-mq: Introduce blk_mq_hctx_stopped() Bart Van Assche
2016-10-27 1:33 ` Ming Lei
2016-10-27 8:15 ` Johannes Thumshirn
[not found] ` <0de50789-e3b7-0a07-73c1-4fb87b1f957e-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 12:15 ` Sagi Grimberg
2016-10-27 12:40 ` Christoph Hellwig
2016-10-26 22:52 ` [PATCH 03/12] blk-mq: Introduce blk_mq_queue_stopped() Bart Van Assche
2016-10-27 5:49 ` Hannes Reinecke
[not found] ` <f68b2997-8b0d-7aea-2859-5fbda4f6bf71-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 8:16 ` Johannes Thumshirn
2016-10-26 22:53 ` [PATCH 06/12] blk-mq: Add a kick_requeue_list argument to blk_mq_requeue_request() Bart Van Assche
2016-10-27 7:26 ` Hannes Reinecke
2016-10-27 8:28 ` Johannes Thumshirn
2016-10-27 12:44 ` Christoph Hellwig
2016-10-26 22:56 ` [PATCH 11/12] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
2016-10-27 12:19 ` Sagi Grimberg
2016-10-28 16:01 ` Keith Busch
2016-10-28 18:51 ` Bart Van Assche
2016-10-28 21:06 ` Keith Busch [this message]
2016-10-26 22:56 ` [PATCH 12/12] nvme: Fix a race condition related to stopping queues Bart Van Assche
2016-10-26 22:52 ` [PATCH 04/12] blk-mq: Move more code into blk_mq_direct_issue_request() Bart Van Assche
2016-10-27 8:17 ` Johannes Thumshirn
2016-10-27 8:18 ` Johannes Thumshirn
[not found] ` <32b0bd88-cb8e-754a-89fc-b1825778b05a-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 5:50 ` Hannes Reinecke
2016-10-27 12:16 ` Sagi Grimberg
2016-10-27 12:40 ` Christoph Hellwig
2016-10-26 22:53 ` [PATCH 05/12] blk-mq: Introduce blk_mq_quiesce_queue() Bart Van Assche
[not found] ` <5143c240-39af-9fe2-d3e6-ed69f9c20531-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 1:30 ` Ming Lei
[not found] ` <CACVXFVPWL=izFmUPtpi-+RLrhNX0LFfw2m6eurgMC5GvfDWsxQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-27 2:04 ` Bart Van Assche
2016-10-27 2:31 ` Ming Lei
[not found] ` <CACVXFVNvdNXm4JXsXo2p1_pZLqDpCos0MTTR+svR98p_vw5PCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-27 2:40 ` Bart Van Assche
2016-10-27 2:48 ` Ming Lei
[not found] ` <CACVXFVNyRnJFnsSO9TNksE5GNy7TJKL=iZnqrv38=u0XCrW7jA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-10-27 3:05 ` Bart Van Assche
2016-10-27 12:42 ` Christoph Hellwig
2016-10-27 13:16 ` Ming Lei
2016-10-27 5:52 ` Hannes Reinecke
[not found] ` <f1661bd2-12ca-20d1-ece2-5c7fe5987035-l3A5Bk7waGM@public.gmane.org>
2016-10-27 15:56 ` Bart Van Assche
2016-10-27 12:41 ` Christoph Hellwig
2016-10-26 22:54 ` [PATCH 07/12] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
2016-10-27 7:27 ` Hannes Reinecke
[not found] ` <a0733adf-065e-2099-3850-cb1c55df1e35-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 8:28 ` Johannes Thumshirn
2016-10-27 14:01 ` Mike Snitzer
2016-10-26 22:54 ` [PATCH 08/12] dm: Fix a race condition related to stopping and starting queues Bart Van Assche
[not found] ` <28b3e91c-018a-0dbd-8ca9-0a7994a97a5d-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 14:01 ` Mike Snitzer
2016-10-26 22:55 ` [PATCH 09/12] SRP transport: Move queuecommand() wait code to SCSI core Bart Van Assche
[not found] ` <e86cdaf9-6305-d2cb-6068-0a050c023d73-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 8:27 ` Johannes Thumshirn
2016-10-27 12:20 ` Sagi Grimberg
2016-10-26 22:55 ` [PATCH 10/12] SRP transport, scsi-mq: Wait for .queue_rq() if necessary Bart Van Assche
[not found] ` <0cd77719-1f11-d5c3-3186-1c7c3cfd6886-XdAiOPVOjttBDgjK7y7TUQ@public.gmane.org>
2016-10-27 8:27 ` Johannes Thumshirn
2016-10-27 12:19 ` Sagi Grimberg
2016-10-26 23:28 ` [PATCH v4 0/12] Fix race conditions related to stopping block layer queues 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=20161028210628.GE5621@localhost.localdomain \
--to=keith.busch@intel.com \
--cc=axboe@fb.com \
--cc=bart.vanassche@sandisk.com \
--cc=dledford@redhat.com \
--cc=hch@lst.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=loberman@redhat.com \
--cc=martin.petersen@oracle.com \
--cc=snitzer@redhat.com \
--cc=tom.leiming@gmail.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 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).