| From bbd940b05d7be43a63aca9896b5014c4341b4ba8 Mon Sep 17 00:00:00 2001 |
| From: Balbir Singh <sblbir@amzn.com> |
| Date: Wed, 18 Sep 2019 00:27:20 +0000 |
| Subject: [PATCH] nvme-pci: Fix a race in controller removal |
| |
| commit b224726de5e496dbf78147a66755c3d81e28bdd2 upstream. |
| |
| 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> |
| Reviewed-by: Keith Busch <kbusch@kernel.org> |
| Signed-off-by: Sagi Grimberg <sagi@grimberg.me> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c |
| index 963b4c6309b9..b174949d1fd2 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.7.4 |
| |