Page MenuHomeFreeBSD

D56532.id175919.diff
No OneTemporary

D56532.id175919.diff

diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh
--- a/usr.sbin/ctld/ctld.hh
+++ b/usr.sbin/ctld/ctld.hh
@@ -511,6 +511,7 @@
int apply(struct conf *oldconf);
void delete_target_luns(struct lun *lun);
bool reuse_portal_group_socket(struct portal &newp);
+ void shutdown();
bool verify();
private:
diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc
--- a/usr.sbin/ctld/ctld.cc
+++ b/usr.sbin/ctld/ctld.cc
@@ -1965,11 +1965,9 @@
/*
* Rename the pidfile if the pathname changes. On startup,
* oldconf created via conf_new_from_kernel will not contain a
- * valid pidfile_path. On shutdown, the temporary newconf
- * will not contain a valid pidfile_path.
+ * valid pidfile_path.
*/
- if (!oldconf->conf_pidfile_path.empty() &&
- !conf_pidfile_path.empty()) {
+ if (!oldconf->conf_pidfile_path.empty()) {
if (oldconf->conf_pidfile_path != conf_pidfile_path) {
/* pidfile has changed. rename it */
log_debugx("moving pidfile to %s",
@@ -2199,6 +2197,41 @@
return (cumulated_error);
}
+void
+conf::shutdown()
+{
+ /* Deregister from iSNS servers. */
+ for (auto &kv : conf_isns)
+ isns_deregister_targets(&kv.second);
+
+ /* First, remove all ports. */
+ for (const auto &kv : conf_ports) {
+ const std::string &name = kv.first;
+ port *port = kv.second.get();
+
+ if (port->is_dummy())
+ continue;
+ log_debugx("removing port \"%s\"", name.c_str());
+ if (!port->kernel_remove())
+ log_warnx("failed to remove port %s", name.c_str());
+ }
+
+ /* Second, remove all LUNs. */
+ for (const auto &kv : conf_luns) {
+ struct lun *lun = kv.second.get();
+
+ if (!lun->kernel_remove())
+ log_warnx("failed to remove lun \"%s\", CTL lun %d",
+ lun->name(), lun->ctl_lun());
+ }
+
+ /* Close sockets on all portal groups. */
+ for (auto &kv : conf_portal_groups)
+ kv.second->close_sockets();
+ for (auto &kv : conf_transport_groups)
+ kv.second->close_sockets();
+}
+
bool
timed_out(void)
{
@@ -2772,21 +2805,12 @@
oldconf.reset();
}
} else if (sigterm_received) {
- log_debugx("exiting on signal; "
- "reloading empty configuration");
+ log_debugx("exiting on signal");
- log_debugx("removing CTL iSCSI ports "
+ log_debugx("removing CTL iSCSI and NVMeoF ports "
"and terminating all connections");
- oldconf = std::move(newconf);
- newconf = std::make_unique<conf>();
- if (debug > 0)
- newconf->set_debug(debug);
- error = newconf->apply(oldconf.get());
- if (error != 0)
- log_warnx("failed to apply configuration");
- oldconf.reset();
-
+ newconf->shutdown();
log_warnx("exiting on signal");
return (0);
} else {

File Metadata

Mime Type
text/plain
Expires
Wed, Jul 22, 1:43 AM (4 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35341718
Default Alt Text
D56532.id175919.diff (2 KB)

Event Timeline