From 3f3878dd72c495393d96fd10ee346f0278c14ace Mon Sep 17 00:00:00 2001 From: kardel Date: Fri, 4 Dec 2020 23:03:11 +0000 Subject: [PATCH] PR kern/55839: handle multiple nvme_rescan()s correctly by doing the name-space identify only once per nsid. fixes issue where modloading triggers multiple rescans. --- sys/dev/ic/nvme.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sys/dev/ic/nvme.c b/sys/dev/ic/nvme.c index 08f05b3e07a7..7f90400ee11b 100644 --- a/sys/dev/ic/nvme.c +++ b/sys/dev/ic/nvme.c @@ -1,4 +1,4 @@ -/* $NetBSD: nvme.c,v 1.52 2020/11/10 07:39:12 rin Exp $ */ +/* $NetBSD: nvme.c,v 1.53 2020/12/04 23:03:11 kardel Exp $ */ /* $OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */ /* @@ -18,7 +18,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.52 2020/11/10 07:39:12 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.53 2020/12/04 23:03:11 kardel Exp $"); #include #include @@ -628,6 +628,12 @@ nvme_ns_identify(struct nvme_softc *sc, uint16_t nsid) KASSERT(nsid > 0); + ns = nvme_ns_get(sc, nsid); + KASSERT(ns); + + if (ns->ident != NULL) + return 0; + ccb = nvme_ccb_get(sc->sc_admin_q, false); KASSERT(ccb != NULL); /* it's a bug if we don't have spare ccb here */ @@ -665,9 +671,6 @@ nvme_ns_identify(struct nvme_softc *sc, uint16_t nsid) /* Convert data to host endian */ nvme_identify_namespace_swapbytes(identify); - ns = nvme_ns_get(sc, nsid); - KASSERT(ns); - KASSERT(ns->ident == NULL); ns->ident = identify; done: