From be55e01bc029405217b6904426e27c4d7d82f896 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Mon, 17 Aug 2026 09:26:59 -0400 Subject: [PATCH] FreeBSD: Do not leak TSD zfs_geom_probe_vdev_key on errors If there is an error early in `vdev_geom_open()`, the thread will leak `zfs_geom_probe_vdev_key`, causing every `zvol_geom_open()` in the thread to return `EOPNOTSUPP`. The purpose of `zfs_geom_probe_vdev_key` is to prevent recursion into `vdev_geom_open()`, not inhibit it permanently, so we modify `vdev_geom_open()` to set it after the error checks. Reported-by: Grok 4.5 Build Beta Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Richard Yao Closes #18927 --- module/os/freebsd/zfs/vdev_geom.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/module/os/freebsd/zfs/vdev_geom.c b/module/os/freebsd/zfs/vdev_geom.c index 95aad8cb7cf0..6840b026ad18 100644 --- a/module/os/freebsd/zfs/vdev_geom.c +++ b/module/os/freebsd/zfs/vdev_geom.c @@ -800,12 +800,6 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, int error, has_trim; uint16_t rate; - /* - * Set the TLS to indicate downstack that we - * should not access zvols - */ - VERIFY0(tsd_set(zfs_geom_probe_vdev_key, vd)); - /* * We must have a pathname, and it must be absolute. */ @@ -823,6 +817,13 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize, goto skip_open; } + /* + * Set the TLS to indicate downstack that we + * should not access zvols + */ + VERIFY0(tsd_set(zfs_geom_probe_vdev_key, vd)); + + DROP_GIANT(); g_topology_lock(); error = 0;