From: Bart Van Assche <bart.vanassche@sandisk.com> To: Jens Axboe <axboe@fb.com> Cc: 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>, Keith Busch <keith.busch@intel.com>, Ming Lin <ming.l@ssi.samsung.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: [PATCH v3 10/11] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Date: Tue, 18 Oct 2016 14:53:11 -0700 [thread overview] Message-ID: <39c07429-2508-4123-8fe1-ecf407f8571d@sandisk.com> (raw) In-Reply-To: <b39eb0e7-1007-eb63-8e7f-9a7f08508379@sandisk.com> Make nvme_requeue_req() check BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED. Remove the QUEUE_FLAG_STOPPED manipulations that became superfluous because of this change. This patch fixes a race condition: using queue_flag_clear_unlocked() is not safe if any other function that manipulates the queue flags can be called concurrently, e.g. blk_cleanup_queue(). Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Cc: Keith Busch <keith.busch@intel.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Sagi Grimberg <sagi@grimberg.me> --- drivers/nvme/host/core.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e4a6f2d..18a265d 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -205,7 +205,7 @@ void nvme_requeue_req(struct request *req) blk_mq_requeue_request(req, false); spin_lock_irqsave(req->q->queue_lock, flags); - if (!blk_queue_stopped(req->q)) + if (!blk_mq_queue_stopped(req->q)) blk_mq_kick_requeue_list(req->q); spin_unlock_irqrestore(req->q->queue_lock, flags); } @@ -2077,10 +2077,6 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl) mutex_lock(&ctrl->namespaces_mutex); list_for_each_entry(ns, &ctrl->namespaces, list) { - spin_lock_irq(ns->queue->queue_lock); - 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); } @@ -2094,7 +2090,6 @@ 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); blk_mq_start_stopped_hw_queues(ns->queue, true); blk_mq_kick_requeue_list(ns->queue); } -- 2.10.1
WARNING: multiple messages have this Message-ID (diff)
From: bart.vanassche@sandisk.com (Bart Van Assche) Subject: [PATCH v3 10/11] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Date: Tue, 18 Oct 2016 14:53:11 -0700 [thread overview] Message-ID: <39c07429-2508-4123-8fe1-ecf407f8571d@sandisk.com> (raw) In-Reply-To: <b39eb0e7-1007-eb63-8e7f-9a7f08508379@sandisk.com> Make nvme_requeue_req() check BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED. Remove the QUEUE_FLAG_STOPPED manipulations that became superfluous because of this change. This patch fixes a race condition: using queue_flag_clear_unlocked() is not safe if any other function that manipulates the queue flags can be called concurrently, e.g. blk_cleanup_queue(). Signed-off-by: Bart Van Assche <bart.vanassche at sandisk.com> Cc: Keith Busch <keith.busch at intel.com> Cc: Christoph Hellwig <hch at lst.de> Cc: Sagi Grimberg <sagi at grimberg.me> --- drivers/nvme/host/core.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index e4a6f2d..18a265d 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -205,7 +205,7 @@ void nvme_requeue_req(struct request *req) blk_mq_requeue_request(req, false); spin_lock_irqsave(req->q->queue_lock, flags); - if (!blk_queue_stopped(req->q)) + if (!blk_mq_queue_stopped(req->q)) blk_mq_kick_requeue_list(req->q); spin_unlock_irqrestore(req->q->queue_lock, flags); } @@ -2077,10 +2077,6 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl) mutex_lock(&ctrl->namespaces_mutex); list_for_each_entry(ns, &ctrl->namespaces, list) { - spin_lock_irq(ns->queue->queue_lock); - 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); } @@ -2094,7 +2090,6 @@ 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); blk_mq_start_stopped_hw_queues(ns->queue, true); blk_mq_kick_requeue_list(ns->queue); } -- 2.10.1
next prev parent reply other threads:[~2016-10-18 21:53 UTC|newest] Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-10-18 21:48 [PATCH v3 0/11] Fix race conditions related to stopping block layer queues Bart Van Assche 2016-10-18 21:48 ` Bart Van Assche 2016-10-18 21:48 ` [PATCH v3 01/11] blk-mq: Do not invoke .queue_rq() for a stopped queue Bart Van Assche 2016-10-18 21:48 ` Bart Van Assche 2016-10-19 13:17 ` Christoph Hellwig 2016-10-19 13:17 ` Christoph Hellwig 2016-10-19 13:17 ` Christoph Hellwig 2016-10-19 23:48 ` Ming Lei 2016-10-19 23:48 ` Ming Lei 2016-10-19 23:48 ` Ming Lei 2016-10-18 21:49 ` [PATCH v3 02/11] blk-mq: Introduce blk_mq_hctx_stopped() Bart Van Assche 2016-10-18 21:49 ` Bart Van Assche 2016-10-19 13:19 ` Christoph Hellwig 2016-10-19 13:19 ` Christoph Hellwig 2016-10-19 13:19 ` Christoph Hellwig 2016-10-19 15:58 ` Bart Van Assche 2016-10-19 15:58 ` Bart Van Assche 2016-10-18 21:49 ` [PATCH v3 03/11] blk-mq: Introduce blk_mq_queue_stopped() Bart Van Assche 2016-10-18 21:49 ` Bart Van Assche 2016-10-19 13:19 ` Christoph Hellwig 2016-10-19 13:19 ` Christoph Hellwig 2016-10-19 13:19 ` Christoph Hellwig 2016-10-18 21:50 ` [PATCH v3 04/11] blk-mq: Introduce blk_mq_quiesce_queue() Bart Van Assche 2016-10-18 21:50 ` Bart Van Assche 2016-10-19 13:23 ` Christoph Hellwig 2016-10-19 13:23 ` Christoph Hellwig 2016-10-19 13:23 ` Christoph Hellwig 2016-10-19 16:13 ` Bart Van Assche 2016-10-19 16:13 ` Bart Van Assche 2016-10-19 21:04 ` Bart Van Assche 2016-10-19 21:04 ` Bart Van Assche 2016-10-19 23:47 ` Ming Lei 2016-10-19 23:47 ` Ming Lei 2016-10-18 21:51 ` [PATCH v3 05/11] blk-mq: Add a kick_requeue_list argument to blk_mq_requeue_request() Bart Van Assche 2016-10-18 21:51 ` Bart Van Assche 2016-10-18 21:51 ` Bart Van Assche 2016-10-19 13:23 ` Christoph Hellwig 2016-10-19 13:23 ` Christoph Hellwig 2016-10-19 13:23 ` Christoph Hellwig 2016-10-18 21:51 ` [PATCH v3 06/11] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche 2016-10-18 21:51 ` Bart Van Assche 2016-10-19 13:28 ` Christoph Hellwig 2016-10-19 13:28 ` Christoph Hellwig 2016-10-19 13:28 ` Christoph Hellwig 2016-10-18 21:52 ` [PATCH v3 07/11] dm: Fix a race condition related to stopping and starting queues Bart Van Assche 2016-10-18 21:52 ` Bart Van Assche 2016-10-19 13:30 ` Christoph Hellwig 2016-10-19 13:30 ` Christoph Hellwig 2016-10-19 13:30 ` Christoph Hellwig 2016-10-18 21:52 ` [PATCH v3 08/11] SRP transport: Move queuecommand() wait code to SCSI core Bart Van Assche 2016-10-18 21:52 ` Bart Van Assche 2016-10-19 13:38 ` Christoph Hellwig 2016-10-19 13:38 ` Christoph Hellwig 2016-10-19 13:38 ` Christoph Hellwig 2016-10-18 21:52 ` [PATCH v3 09/11] SRP transport, scsi-mq: Wait for .queue_rq() if necessary Bart Van Assche 2016-10-18 21:52 ` Bart Van Assche 2016-10-19 13:39 ` Christoph Hellwig 2016-10-19 13:39 ` Christoph Hellwig 2016-10-19 13:39 ` Christoph Hellwig 2016-10-18 21:53 ` Bart Van Assche [this message] 2016-10-18 21:53 ` [PATCH v3 10/11] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche 2016-10-19 13:39 ` Christoph Hellwig 2016-10-19 13:39 ` Christoph Hellwig 2016-10-19 13:39 ` Christoph Hellwig 2016-10-18 21:53 ` [PATCH v3 11/11] nvme: Fix a race condition Bart Van Assche 2016-10-18 21:53 ` Bart Van Assche 2016-10-19 13:41 ` Christoph Hellwig 2016-10-19 13:41 ` Christoph Hellwig 2016-10-19 13:41 ` Christoph Hellwig 2016-10-18 21:56 ` [PATCH v3 0/11] Fix race conditions related to stopping block layer queues Bart Van Assche 2016-10-18 21:56 ` Bart Van Assche 2016-10-18 21:56 ` Bart Van Assche 2016-10-19 22:24 ` Keith Busch 2016-10-19 22:24 ` Keith Busch 2016-10-19 23:51 ` Bart Van Assche 2016-10-19 23:51 ` Bart Van Assche 2016-10-20 14:52 ` Keith Busch 2016-10-20 14:52 ` Keith Busch 2016-10-20 15:35 ` Bart Van Assche 2016-10-20 15:35 ` Bart Van Assche
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=39c07429-2508-4123-8fe1-ecf407f8571d@sandisk.com \ --to=bart.vanassche@sandisk.com \ --cc=axboe@fb.com \ --cc=dledford@redhat.com \ --cc=hch@lst.de \ --cc=jejb@linux.vnet.ibm.com \ --cc=keith.busch@intel.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=ming.l@ssi.samsung.com \ --cc=snitzer@redhat.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: linkBe 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.