Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F107944485
D45460.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D45460.diff
View Options
diff --git a/sys/dev/nvmf/host/nvmf.c b/sys/dev/nvmf/host/nvmf.c
--- a/sys/dev/nvmf/host/nvmf.c
+++ b/sys/dev/nvmf/host/nvmf.c
@@ -804,6 +804,55 @@
free(data, M_NVMF);
}
+static void
+nvmf_purge_namespaces(struct nvmf_softc *sc, uint32_t first_nsid,
+ uint32_t next_valid_nsid)
+{
+ struct nvmf_namespace *ns;
+
+ for (uint32_t nsid = first_nsid; nsid < next_valid_nsid; nsid++)
+ {
+ /* XXX: Needs locking around sc->ns[]. */
+ ns = sc->ns[nsid - 1];
+ if (ns != NULL) {
+ nvmf_destroy_ns(ns);
+ sc->ns[nsid - 1] = NULL;
+
+ nvmf_sim_rescan_ns(sc, nsid);
+ }
+ }
+}
+
+static bool
+nvmf_rescan_ns_cb(struct nvmf_softc *sc, uint32_t nsid,
+ const struct nvme_namespace_data *data, void *arg)
+{
+ uint32_t *last_nsid = arg;
+
+ /* Check for any gaps prior to this namespace. */
+ nvmf_purge_namespaces(sc, *last_nsid + 1, nsid);
+ *last_nsid = nsid;
+
+ nvmf_rescan_ns_1(sc, nsid, data);
+ return (true);
+}
+
+void
+nvmf_rescan_all_ns(struct nvmf_softc *sc)
+{
+ uint32_t last_nsid;
+
+ last_nsid = 0;
+ if (!nvmf_scan_active_namespaces(sc, nvmf_rescan_ns_cb, &last_nsid))
+ return;
+
+ /*
+ * Check for any namespace devices after the last active
+ * namespace.
+ */
+ nvmf_purge_namespaces(sc, last_nsid + 1, sc->cdata->nn + 1);
+}
+
int
nvmf_passthrough_cmd(struct nvmf_softc *sc, struct nvme_pt_command *pt,
bool admin)
diff --git a/sys/dev/nvmf/host/nvmf_aer.c b/sys/dev/nvmf/host/nvmf_aer.c
--- a/sys/dev/nvmf/host/nvmf_aer.c
+++ b/sys/dev/nvmf/host/nvmf_aer.c
@@ -62,7 +62,7 @@
* probably just rescan the entire set of namespaces.
*/
if (ns_list->ns[0] == 0xffffffff) {
- device_printf(sc->dev, "too many changed namespaces\n");
+ nvmf_rescan_all_ns(sc);
return;
}
diff --git a/sys/dev/nvmf/host/nvmf_var.h b/sys/dev/nvmf/host/nvmf_var.h
--- a/sys/dev/nvmf/host/nvmf_var.h
+++ b/sys/dev/nvmf/host/nvmf_var.h
@@ -148,6 +148,7 @@
void nvmf_free_ivars(struct nvmf_ivars *ivars);
void nvmf_disconnect(struct nvmf_softc *sc);
void nvmf_rescan_ns(struct nvmf_softc *sc, uint32_t nsid);
+void nvmf_rescan_all_ns(struct nvmf_softc *sc);
int nvmf_passthrough_cmd(struct nvmf_softc *sc, struct nvme_pt_command *pt,
bool admin);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 20, 7:38 PM (21 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15982642
Default Alt Text
D45460.diff (2 KB)
Attached To
Mode
D45460: nvmf: Rescan all namespaces if the changed NS log page is too large
Attached
Detach File
Event Timeline
Log In to Comment