mirror of
https://github.com/opnsense/src.git
synced 2026-06-05 06:42:56 -04:00
nvmf: Factor out most of nvmf_rescan_ns into a helper routine
This function accepts a namespace ID and associated namespace data from IDENTIFY and takes care of updating nvmeXnY and ndaZ. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45459
This commit is contained in:
parent
02ddb305cc
commit
8a082ca89f
1 changed files with 30 additions and 22 deletions
|
|
@ -733,12 +733,40 @@ nvmf_detach(device_t dev)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
nvmf_rescan_ns_1(struct nvmf_softc *sc, uint32_t nsid,
|
||||
const struct nvme_namespace_data *data)
|
||||
{
|
||||
struct nvmf_namespace *ns;
|
||||
|
||||
/* XXX: Needs locking around sc->ns[]. */
|
||||
ns = sc->ns[nsid - 1];
|
||||
if (data->nsze == 0) {
|
||||
/* XXX: Needs locking */
|
||||
if (ns != NULL) {
|
||||
nvmf_destroy_ns(ns);
|
||||
sc->ns[nsid - 1] = NULL;
|
||||
}
|
||||
} else {
|
||||
/* XXX: Needs locking */
|
||||
if (ns == NULL) {
|
||||
sc->ns[nsid - 1] = nvmf_init_ns(sc, nsid, data);
|
||||
} else {
|
||||
if (!nvmf_update_ns(ns, data)) {
|
||||
nvmf_destroy_ns(ns);
|
||||
sc->ns[nsid - 1] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nvmf_sim_rescan_ns(sc, nsid);
|
||||
}
|
||||
|
||||
void
|
||||
nvmf_rescan_ns(struct nvmf_softc *sc, uint32_t nsid)
|
||||
{
|
||||
struct nvmf_completion_status status;
|
||||
struct nvme_namespace_data *data;
|
||||
struct nvmf_namespace *ns;
|
||||
|
||||
data = malloc(sizeof(*data), M_NVMF, M_WAITOK);
|
||||
|
||||
|
|
@ -771,29 +799,9 @@ nvmf_rescan_ns(struct nvmf_softc *sc, uint32_t nsid)
|
|||
|
||||
nvme_namespace_data_swapbytes(data);
|
||||
|
||||
/* XXX: Needs locking around sc->ns[]. */
|
||||
ns = sc->ns[nsid - 1];
|
||||
if (data->nsze == 0) {
|
||||
/* XXX: Needs locking */
|
||||
if (ns != NULL) {
|
||||
nvmf_destroy_ns(ns);
|
||||
sc->ns[nsid - 1] = NULL;
|
||||
}
|
||||
} else {
|
||||
/* XXX: Needs locking */
|
||||
if (ns == NULL) {
|
||||
sc->ns[nsid - 1] = nvmf_init_ns(sc, nsid, data);
|
||||
} else {
|
||||
if (!nvmf_update_ns(ns, data)) {
|
||||
nvmf_destroy_ns(ns);
|
||||
sc->ns[nsid - 1] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
nvmf_rescan_ns_1(sc, nsid, data);
|
||||
|
||||
free(data, M_NVMF);
|
||||
|
||||
nvmf_sim_rescan_ns(sc, nsid);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
Loading…
Reference in a new issue