summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Eidelman <anton@lightbitslabs.com>2019-08-12 23:00:36 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-09-10 10:35:21 +0100
commite1031b6c8100dba0da0d672f98db3a03139a3f93 (patch)
treea3381a6a7247cef23fe5758495caeadd1bacd144
parent6950d5b64a15407f10959f8a2e634ee65c576aea (diff)
downloadlinux-stable-e1031b6c8100dba0da0d672f98db3a03139a3f93.tar.gz
linux-stable-e1031b6c8100dba0da0d672f98db3a03139a3f93.tar.bz2
linux-stable-e1031b6c8100dba0da0d672f98db3a03139a3f93.zip
nvme-multipath: fix possible I/O hang when paths are updated
[ Upstream commit 504db087aaccdb32af61539916409f7dca31ceb5 ] nvme_state_set_live() making a path available triggers requeue_work in order to resubmit requests that ended up on requeue_list when no paths were available. This requeue_work may race with concurrent nvme_ns_head_make_request() that do not observe the live path yet. Such concurrent requests may by made by either: - New IO submission. - Requeue_work triggered by nvme_failover_req() or another ana_work. A race may cause requeue_work capture the state of requeue_list before more requests get onto the list. These requests will stay on the list forever unless requeue_work is triggered again. In order to prevent such race, nvme_state_set_live() should synchronize_srcu(&head->srcu) before triggering the requeue_work and prevent nvme_ns_head_make_request referencing an old snapshot of the path list. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anton Eidelman <anton@lightbitslabs.com> Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/nvme/host/multipath.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 747c0d4f9ff5..304aa8a65f2f 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -420,6 +420,7 @@ static void nvme_mpath_set_live(struct nvme_ns *ns)
srcu_read_unlock(&head->srcu, srcu_idx);
}
+ synchronize_srcu(&ns->head->srcu);
kblockd_schedule_work(&ns->head->requeue_work);
}