diff options
author | Sagi Grimberg | 2019-04-30 01:28:19 +0200 |
---|---|---|
committer | Christoph Hellwig | 2019-05-01 15:18:47 +0200 |
commit | 6f53e73b9ec5b3cd097077c5ffcb76df708ce3f8 (patch) | |
tree | fe468819f20d961cbfec7da32f37f5108ed11055 /drivers/nvme/target/discovery.c | |
parent | nvme: mark nvme_core_init and nvme_core_exit static (diff) | |
download | kernel-qcow2-linux-6f53e73b9ec5b3cd097077c5ffcb76df708ce3f8.tar.gz kernel-qcow2-linux-6f53e73b9ec5b3cd097077c5ffcb76df708ce3f8.tar.xz kernel-qcow2-linux-6f53e73b9ec5b3cd097077c5ffcb76df708ce3f8.zip |
nvmet: protect discovery change log event list iteration
When we iterate on the discovery subsystem controllers
we need to protect against concurrent mutations to it.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Minwoo Im <minwoo.im@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme/target/discovery.c')
-rw-r--r-- | drivers/nvme/target/discovery.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c index e8e09266bfa5..5baf269f3f8a 100644 --- a/drivers/nvme/target/discovery.c +++ b/drivers/nvme/target/discovery.c @@ -30,14 +30,17 @@ void nvmet_port_disc_changed(struct nvmet_port *port, { struct nvmet_ctrl *ctrl; + lockdep_assert_held(&nvmet_config_sem); nvmet_genctr++; + mutex_lock(&nvmet_disc_subsys->lock); list_for_each_entry(ctrl, &nvmet_disc_subsys->ctrls, subsys_entry) { if (subsys && !nvmet_host_allowed(subsys, ctrl->hostnqn)) continue; __nvmet_disc_changed(port, ctrl); } + mutex_unlock(&nvmet_disc_subsys->lock); } static void __nvmet_subsys_disc_changed(struct nvmet_port *port, @@ -46,12 +49,14 @@ static void __nvmet_subsys_disc_changed(struct nvmet_port *port, { struct nvmet_ctrl *ctrl; + mutex_lock(&nvmet_disc_subsys->lock); list_for_each_entry(ctrl, &nvmet_disc_subsys->ctrls, subsys_entry) { if (host && strcmp(nvmet_host_name(host), ctrl->hostnqn)) continue; __nvmet_disc_changed(port, ctrl); } + mutex_unlock(&nvmet_disc_subsys->lock); } void nvmet_subsys_disc_changed(struct nvmet_subsys *subsys, |