nvme_sim: signal namespace depature

Signal when the namespace is gone so we can tear down the disk when a
nvme drive is removed.

Reviewed by: 		imp
Differential Revision:	https://reviews.freebsd.org/D33032
This commit is contained in:
Wanpeng Qian
2025-11-18 10:24:13 -07:00
committed by Warner Losh
parent bd769e73d8
commit 4640f50089
+19 -9
View File
@@ -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);