Date: Wed, 19 Nov 2025 21:44:39 +0000 From: Colin Percival <cperciva@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Wanpeng Qian <wanpengqian@gmail.com> Subject: git: e4416d1e95c4 - releng/15.0 - nvme_sim: signal namespace depature Message-ID: <691e3a47.33542.8fca695@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch releng/15.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=e4416d1e95c40b772dbb6889f468538f4ea9f711 commit e4416d1e95c40b772dbb6889f468538f4ea9f711 Author: Wanpeng Qian <wanpengqian@gmail.com> AuthorDate: 2025-11-18 17:24:13 +0000 Commit: Colin Percival <cperciva@FreeBSD.org> CommitDate: 2025-11-19 21:37:21 +0000 nvme_sim: signal namespace depature Signal when the namespace is gone so we can tear down the disk when a nvme drive is removed. Approved by: re (cperciva) Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D33032 (cherry picked from commit 4640f5008922c5b189d2f7b63edf73300277e6df) (cherry picked from commit b7ffac04541f98d3d8c6078092d59f0fed88b1ef) --- sys/dev/nvme/nvme_sim.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sys/dev/nvme/nvme_sim.c b/sys/dev/nvme/nvme_sim.c index a06774a64761..f7fd0cee931b 100644 --- a/sys/dev/nvme/nvme_sim.c +++ b/sys/dev/nvme/nvme_sim.c @@ -352,25 +352,35 @@ static void * nvme_sim_ns_change(struct nvme_namespace *ns, void *sc_arg) { struct nvme_sim_softc *sc = sc_arg; + struct cam_path *tmppath; union ccb *ccb; + if (xpt_create_path(&tmppath, /*periph*/NULL, + cam_sim_path(sc->s_sim), 0, ns->id) != CAM_REQ_CMP) { + printf("unable to create path for rescan\n"); + return (NULL); + } + /* + * If it's gone, then signal that and leave. + */ + if (ns->flags & NVME_NS_GONE) { + xpt_async(AC_LOST_DEVICE, tmppath, NULL); + xpt_free_path(tmppath); + return (sc_arg); + } + ccb = xpt_alloc_ccb_nowait(); if (ccb == NULL) { printf("unable to alloc CCB for rescan\n"); return (NULL); } + ccb->ccb_h.path = tmppath; /* - * We map the NVMe namespace idea onto the CAM unit LUN. For - * each new namespace, we create a new CAM path for it. We then - * rescan the path to get it to enumerate. + * We map the NVMe namespace idea onto the CAM unit LUN. For each new + * namespace, scan or rescan the path to enumerate it. tmppath freed at + * end of scan. */ - if (xpt_create_path(&ccb->ccb_h.path, /*periph*/NULL, - cam_sim_path(sc->s_sim), 0, ns->id) != CAM_REQ_CMP) { - printf("unable to create path for rescan\n"); - xpt_free_ccb(ccb); - return (NULL); - } xpt_rescan(ccb); return (sc_arg);help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?691e3a47.33542.8fca695>
