Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/nvme/nvme_sim.c
Show First 20 Lines • Show All 320 Lines • ▼ Show 20 Lines | err1: | ||||
free(sc, M_NVME); | free(sc, M_NVME); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static void * | static void * | ||||
nvme_sim_ns_change(struct nvme_namespace *ns, void *sc_arg) | nvme_sim_ns_change(struct nvme_namespace *ns, void *sc_arg) | ||||
{ | { | ||||
struct nvme_sim_softc *sc = sc_arg; | struct nvme_sim_softc *sc = sc_arg; | ||||
struct cam_path *tmppath; | |||||
union ccb *ccb; | 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_FLAG_GONE) { | |||||
xpt_async(AC_LOST_DEVICE, tmppath, NULL); | |||||
xpt_free_path(tmppath); | |||||
return (sc_arg); | |||||
} | |||||
/* | |||||
* If it's changed, then signal that and leave. | |||||
*/ | |||||
if (ns->flags & NVME_NS_FLAG_CHANGED) { | |||||
xpt_async(AC_GETDEV_CHANGED, tmppath, NULL); | |||||
return (sc_arg); | |||||
} | |||||
ccb = xpt_alloc_ccb_nowait(); | ccb = xpt_alloc_ccb_nowait(); | ||||
if (ccb == NULL) { | if (ccb == NULL) { | ||||
printf("unable to alloc CCB for rescan\n"); | printf("unable to alloc CCB for rescan\n"); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
ccb->ccb_h.path = tmppath; | |||||
/* | /* | ||||
* We map the NVMe namespace idea onto the CAM unit LUN. For | * 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 | * each new namespace, we create a new CAM path for it. We then | ||||
* rescan the path to get it to enumerate. | * rescan the path to get it to enumerate. | ||||
* | |||||
* At the end of the scan, the path is freed, I think... | |||||
*/ | */ | ||||
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); | xpt_rescan(ccb); | ||||
return (sc_arg); | return (sc_arg); | ||||
} | } | ||||
static void | static void | ||||
nvme_sim_controller_fail(void *ctrlr_arg) | nvme_sim_controller_fail(void *ctrlr_arg) | ||||
{ | { | ||||
struct nvme_sim_softc *sc = ctrlr_arg; | struct nvme_sim_softc *sc = ctrlr_arg; | ||||
xpt_async(AC_LOST_DEVICE, sc->s_path, NULL); | xpt_async(AC_LOST_DEVICE, sc->s_path, NULL); | ||||
xpt_free_path(sc->s_path); | xpt_free_path(sc->s_path); | ||||
xpt_bus_deregister(cam_sim_path(sc->s_sim)); | xpt_bus_deregister(cam_sim_path(sc->s_sim)); | ||||
cam_sim_free(sc->s_sim, /*free_devq*/TRUE); | cam_sim_free(sc->s_sim, /*free_devq*/TRUE); | ||||
imp: this is also wrong. It doesn't handle the multiple name spaces arriving or departing. It only… | |||||
Done Inline ActionsI will not use async callback this time. wanpengqian_gmail.com: I will not use async callback this time. | |||||
free(sc, M_NVME); | free(sc, M_NVME); | ||||
} | } | ||||
struct nvme_consumer *consumer_cookie; | struct nvme_consumer *consumer_cookie; | ||||
static void | static void | ||||
nvme_sim_init(void) | nvme_sim_init(void) | ||||
{ | { | ||||
Show All 22 Lines |
this is also wrong. It doesn't handle the multiple name spaces arriving or departing. It only handles the size change.