[PATCH 25/35] monitor: read existing connections on startup
mwilck at suse.com
mwilck at suse.com
Tue Jan 26 15:33:14 EST 2021
From: Martin Wilck <mwilck at suse.com>
Add discovery_ctrl_existed flag to the connection, to determine
whether a given (discovery) controller should be shut down on exit.
Signed-off-by: Martin Wilck <mwilck at suse.com>
---
conn-db.c | 1 +
conn-db.h | 1 +
monitor.c | 2 ++
3 files changed, 4 insertions(+)
diff --git a/conn-db.c b/conn-db.c
index 99d88da..07e4dde 100644
--- a/conn-db.c
+++ b/conn-db.c
@@ -301,6 +301,7 @@ int conndb_init_from_sysfs(void)
if (instance >= 0) {
ci->c.discovery_instance = instance;
+ ci->c.discovery_ctrl_existed = 1;
log(LOG_DEBUG, "found discovery controller %s\n",
devices[i]->d_name);
}
diff --git a/conn-db.h b/conn-db.h
index c599c15..11c3502 100644
--- a/conn-db.h
+++ b/conn-db.h
@@ -11,6 +11,7 @@ struct nvme_connection {
int discovery_pending:1;
int did_discovery:1;
int successful_discovery:1;
+ int discovery_ctrl_existed:1;
union {
pid_t discovery_task;
int discovery_result;
diff --git a/monitor.c b/monitor.c
index ce772f3..5bd900b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -603,9 +603,11 @@ int aen_monitor(const char *desc, int argc, char **argv)
}
ret = create_udev_monitor(&monitor);
if (ret == 0) {
+ conndb_init_from_sysfs();
ret = monitor_main_loop(monitor);
udev_monitor_unref(monitor);
}
+ conndb_free();
udev = udev_unref(udev);
if (mon_cfg.autoconnect && !mon_cfg.skip_udev_on_exit)
monitor_enable_udev_rules();
--
2.29.2
More information about the Linux-nvme
mailing list