Date: Wed, 10 Jun 2026 04:01:09 +0000 From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 4a56809bb9eb - stable/15 - ctld: kernel-sourced portal groups are not dummies Message-ID: <6a28e185.27f04.7ba781d0@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=4a56809bb9eb59084025af83b5e3fe4e4478f143 commit 4a56809bb9eb59084025af83b5e3fe4e4478f143 Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2026-04-28 20:51:50 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2026-06-10 04:00:35 +0000 ctld: kernel-sourced portal groups are not dummies The current and historical versions of ctld would flag our initial set of kernel ports as dummies, because their portal groups were empty since portals come from the configuration on-disk. As a result, we would never try to remove a kernel port at startup that didn't exist in the configuration (possibly a feature if you wanted concurrent ctld(8)), and we would always try to port->kernel_add() on ports in the configuration (even if they actually did have an existing kernel port). Flag these portal groups as kernel groups so that we avoid trying to add ports that already exist. It may be the case that the kernel_remove() loop in conf::apply() needs to do something other than the current `oldport->is_dummy()` to avoid removing ports that it isn't supposed to be managing, but that wuld also seem to apply to LUNs that would be removed today. Reviewed by: jhb (cherry picked from commit d9c0594191f5c45d7f3c737350321ee59bfce9bf) --- usr.sbin/ctld/ctld.cc | 15 +++++++++++++++ usr.sbin/ctld/ctld.hh | 2 ++ usr.sbin/ctld/kernel.cc | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc index 331c029e282e..6ec64cc253d6 100644 --- a/usr.sbin/ctld/ctld.cc +++ b/usr.sbin/ctld/ctld.cc @@ -591,9 +591,18 @@ conf::find_transport_group(std::string_view name) return (it->second.get()); } +/* + * Foreign portal groups (which only redirect to other targets), and portal + * groups without any active portals are considered dummies and ports belonging + * to such groups are ignored. However, portal groups that exist in the kernel + * prior to ctld starting will contain real ports but no portals, so these are + * never considered dummies. + */ bool portal_group::is_dummy() const { + if (pg_kernel) + return (false); if (pg_foreign) return (true); if (pg_portals.empty()) @@ -710,6 +719,12 @@ portal_group::set_foreign() pg_foreign = true; } +void +portal_group::set_kernel() +{ + pg_kernel = true; +} + bool portal_group::set_offload(const char *offload) { diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh index 3bf18f6a32c0..2e1ee7869ceb 100644 --- a/usr.sbin/ctld/ctld.hh +++ b/usr.sbin/ctld/ctld.hh @@ -220,6 +220,7 @@ struct portal_group { bool set_dscp(u_int dscp); virtual bool set_filter(const char *str) = 0; void set_foreign(); + void set_kernel(); bool set_offload(const char *offload); bool set_pcp(u_int pcp); bool set_redirection(const char *addr); @@ -248,6 +249,7 @@ protected: enum discovery_filter pg_discovery_filter = discovery_filter::UNKNOWN; bool pg_foreign = false; + bool pg_kernel = false; bool pg_assigned = false; std::list<portal_up> pg_portals; std::unordered_map<std::string, port *> pg_ports; diff --git a/usr.sbin/ctld/kernel.cc b/usr.sbin/ctld/kernel.cc index f2bdf53bd3ee..d1210079ca1a 100644 --- a/usr.sbin/ctld/kernel.cc +++ b/usr.sbin/ctld/kernel.cc @@ -483,6 +483,8 @@ add_iscsi_port(struct kports &kports, struct conf *conf, log_warnx("Failed to add portal-group \"%s\"", pg_name); return; } + + pg->set_kernel(); } pg->set_tag(port.cfiscsi_portal_group_tag); if (!conf->add_port(targ, pg, port.port_id)) { @@ -520,6 +522,8 @@ add_nvmf_port(struct conf *conf, const struct cctl_port &port, tg_name); return; } + + pg->set_kernel(); } pg->set_tag(port.portid); if (!conf->add_port(targ, pg, port.port_id)) {home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a28e185.27f04.7ba781d0>
