* [PATCH] nvmet: protect discovery change log event
@ 2019-03-11 22:11 Sagi Grimberg
2019-03-12 14:36 ` Christoph Hellwig
0 siblings, 1 reply; 2+ messages in thread
From: Sagi Grimberg @ 2019-03-11 22:11 UTC (permalink / raw)
When we iterate on the discovery subsystem controllers
we need to protect against concurrent mutations to it.
Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
drivers/nvme/target/discovery.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/target/discovery.c b/drivers/nvme/target/discovery.c
index a34cf4986a49..dd6e8248e643 100644
--- a/drivers/nvme/target/discovery.c
+++ b/drivers/nvme/target/discovery.c
@@ -38,14 +38,15 @@ void nvmet_port_disc_changed(struct nvmet_port *port,
{
struct nvmet_ctrl *ctrl;
+ mutex_lock(&nvmet_disc_subsys->lock);
nvmet_genctr++;
-
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,
@@ -54,12 +55,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,
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] nvmet: protect discovery change log event
2019-03-11 22:11 [PATCH] nvmet: protect discovery change log event Sagi Grimberg
@ 2019-03-12 14:36 ` Christoph Hellwig
0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2019-03-12 14:36 UTC (permalink / raw)
> struct nvmet_ctrl *ctrl;
>
> + mutex_lock(&nvmet_disc_subsys->lock);
> nvmet_genctr++;
> -
But there should be no need to takes this over the nvmet_genctr
increment, that is supposed to be protected using nvmet_config_sem.
That being said a lockdep_assert_held for that would be nice.
Also I think the subject line could use a tweak - we are not really
protecting the event, but the list iteration (as explained in the
commit log)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-12 14:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11 22:11 [PATCH] nvmet: protect discovery change log event Sagi Grimberg
2019-03-12 14:36 ` Christoph Hellwig
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.