* [PATCH v4] nvme/host/pci: Fix a race in controller removal
@ 2019-09-18 0:27 Balbir Singh
2019-09-18 2:15 ` Keith Busch
0 siblings, 1 reply; 2+ messages in thread
From: Balbir Singh @ 2019-09-18 0:27 UTC (permalink / raw)
To: linux-nvme; +Cc: kbusch, axboe, Balbir Singh, hch, sagi
User space programs like udevd may try to read to partitions at the
same time the driver detects a namespace is unusable, and may deadlock
if revalidate_disk() is called while such a process is waiting to
enter the frozen queue. On detecting a dead namespace, move the disk
revalidate after unblocking dispatchers that may be holding bd_butex.
changelog Suggested-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Balbir Singh <sblbir@amzn.com>
---
Changelov v4
- Simplify the changelog
Changelog v3
- Simplify the comment about moving revalidate_disk
Changelog v2
- Rely on blk_set_queue_dying to do the wake_all()
drivers/nvme/host/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b45f82d58be8..6ad1f1df9e44 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -103,10 +103,13 @@ static void nvme_set_queue_dying(struct nvme_ns *ns)
*/
if (!ns->disk || test_and_set_bit(NVME_NS_DEAD, &ns->flags))
return;
- revalidate_disk(ns->disk);
blk_set_queue_dying(ns->queue);
/* Forcibly unquiesce queues to avoid blocking dispatch */
blk_mq_unquiesce_queue(ns->queue);
+ /*
+ * Revalidate after unblocking dispatchers that may be holding bd_butex
+ */
+ revalidate_disk(ns->disk);
}
static void nvme_queue_scan(struct nvme_ctrl *ctrl)
--
2.16.5
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v4] nvme/host/pci: Fix a race in controller removal
2019-09-18 0:27 [PATCH v4] nvme/host/pci: Fix a race in controller removal Balbir Singh
@ 2019-09-18 2:15 ` Keith Busch
0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2019-09-18 2:15 UTC (permalink / raw)
To: Balbir Singh; +Cc: axboe, hch, linux-nvme, sagi
On Wed, Sep 18, 2019 at 12:27:20AM +0000, Balbir Singh wrote:
> User space programs like udevd may try to read to partitions at the
> same time the driver detects a namespace is unusable, and may deadlock
> if revalidate_disk() is called while such a process is waiting to
> enter the frozen queue. On detecting a dead namespace, move the disk
> revalidate after unblocking dispatchers that may be holding bd_butex.
Patch looks fine.
Reviewed-by: Keith Busch <kbusch@kernel.org>
_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-09-18 2:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 0:27 [PATCH v4] nvme/host/pci: Fix a race in controller removal Balbir Singh
2019-09-18 2:15 ` Keith Busch
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).