git: 66c24c94323a - main - nvme: Refactor namespace notifications for additions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 Oct 2026 06:24:38 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=66c24c94323ae36f2132c60bc2788ab70b60f224
commit 66c24c94323ae36f2132c60bc2788ab70b60f224
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-10-19 04:40:45 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-10-19 06:22:50 +0000
nvme: Refactor namespace notifications for additions
When we add a namespace, we have the code inline to do the
notifications. Refactor ahead or reuse.
Reviewed by: seuros
Differential Revision: https://reviews.freebsd.org/D59831
---
sys/dev/nvme/nvme_ctrlr.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 7b2c73c5863b..f27653536c66 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -657,6 +657,22 @@ nvme_ctrlr_construct_namespaces(struct nvme_controller *ctrlr)
return (0);
}
+static void
+nvme_ctrlr_notify_ns_added(struct nvme_controller *ctrlr, device_t child)
+{
+ struct nvme_namespace *ns;
+
+ /*
+ * Notify the consumer of all currently active namespaces.
+ */
+ for (int i = 0; i < nvme_ctrlr_num_namespaces(ctrlr); i++) {
+ ns = &ctrlr->ns[i];
+ if (ns->data.nsze == 0)
+ continue;
+ NVME_NS_ADDED(child, ns);
+ }
+}
+
static bool
is_log_page_id_valid(uint8_t page_id)
{
@@ -1253,17 +1269,7 @@ nvme_ctrlr_start_config_hook(void *arg)
child = device_add_child(ctrlr->dev, NULL, DEVICE_UNIT_ANY);
device_set_ivars(child, ctrlr);
bus_attach_children(ctrlr->dev);
-
- /*
- * Now notify the child of all the known namepsaces
- */
- for (int i = 0; i < nvme_ctrlr_num_namespaces(ctrlr); i++) {
- struct nvme_namespace *ns = &ctrlr->ns[i];
-
- if (ns->data.nsze == 0)
- continue;
- NVME_NS_ADDED(child, ns);
- }
+ nvme_ctrlr_notify_ns_added(ctrlr, child);
}
TSEXIT();
}