Date: Wed, 10 Jun 2026 04:01:02 +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: 3129ecee97c1 - stable/14 - ctld: kernel-sourced portal groups are not dummies Message-ID: <6a28e17e.26765.1b8f5325@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=3129ecee97c1405fbb6eeab2e8b906b096eab1c9 commit 3129ecee97c1405fbb6eeab2e8b906b096eab1c9 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:45 +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 | 9 +++++++++ usr.sbin/ctld/ctld.hh | 1 + usr.sbin/ctld/kernel.cc | 2 ++ 3 files changed, 12 insertions(+) diff --git a/usr.sbin/ctld/ctld.cc b/usr.sbin/ctld/ctld.cc index c44c3726e74e..05734cde5a49 100644 --- a/usr.sbin/ctld/ctld.cc +++ b/usr.sbin/ctld/ctld.cc @@ -1136,11 +1136,20 @@ port_delete(struct port *port) free(port); } +/* + * 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 port_is_dummy(struct port *port) { if (port->p_portal_group) { + if (port->p_portal_group->pg_kernel) + return (false); if (port->p_portal_group->pg_foreign) return (true); if (TAILQ_EMPTY(&port->p_portal_group->pg_portals)) diff --git a/usr.sbin/ctld/ctld.hh b/usr.sbin/ctld/ctld.hh index b1757f98ac81..a132965cd235 100644 --- a/usr.sbin/ctld/ctld.hh +++ b/usr.sbin/ctld/ctld.hh @@ -117,6 +117,7 @@ struct portal_group { struct auth_group *pg_discovery_auth_group; int pg_discovery_filter; bool pg_foreign; + bool pg_kernel; bool pg_unassigned; TAILQ_HEAD(, portal) pg_portals; TAILQ_HEAD(, port) pg_ports; diff --git a/usr.sbin/ctld/kernel.cc b/usr.sbin/ctld/kernel.cc index fdd290988ce0..809205c176ed 100644 --- a/usr.sbin/ctld/kernel.cc +++ b/usr.sbin/ctld/kernel.cc @@ -577,6 +577,8 @@ retry_port: log_warnx("portal_group_new failed"); continue; } + + pg->pg_kernel = true; } pg->pg_tag = port->cfiscsi_portal_group_tag; cp = port_new(conf, targ, pg);home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a28e17e.26765.1b8f5325>
