summaryrefslogtreecommitdiffstats
path: root/drivers/nvme
diff options
context:
space:
mode:
authorBalbir Singh <sblbir@amzn.com>2019-09-18 00:27:20 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-29 09:19:29 +0100
commitdb783e05df551f48580b2b08965716a1368ac53a (patch)
treebb0b3dce3dfbd15f5e64a565419f311f94e73072 /drivers/nvme
parentc3038e718a19fc596f7b1baba0f83d5146dc7784 (diff)
downloadlinux-stable-db783e05df551f48580b2b08965716a1368ac53a.tar.gz
linux-stable-db783e05df551f48580b2b08965716a1368ac53a.tar.bz2
linux-stable-db783e05df551f48580b2b08965716a1368ac53a.zip
nvme-pci: Fix a race in controller removal
[ Upstream commit b224726de5e496dbf78147a66755c3d81e28bdd2 ] 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: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/nvme')
-rw-r--r--drivers/nvme/host/core.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index ae0b01059fc6..5d0f99bcc987 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -111,10 +111,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)