From nobody Wed Jun 05 20:04:00 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VvdhJ5dc8z5M3Ps; Wed, 05 Jun 2024 20:04:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VvdhJ3cFCz4jKK; Wed, 5 Jun 2024 20:04:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717617840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=N1slBVglaih0WgTh6jqdMYomYeGg6BXnNr0xwCa+7cM=; b=lk7N3eU2FJdJxBvzmFP+99Ogn05gjMtfIOj7LMuxwcZatqPE8M4iH0zgAkfVZcV9NcM2lw mpXP1aTElrZJQgsmyIZOEpKeLyHU6RTbhXfKqDrIdUEj460V3nb7ZW+UIrG35UGznLsXyK lcQjbzEqPJNVeQEy0PQDO0IfFSfPqaGKK6YaqxOW7I1U7spY/C1/X24JLps3I/7sbDCdmJ TKZuOi6qBAwGLZA38w4bBtJN6YtjF29mUar7TsL/9CvFMAbCRemJFUoGeSfwdnP63Q/NBj 4wEnb4iQdkCheqkrKeCTQSyc8oqmIqqv3vyNCHPqzwWUh27S71sO/3QbOX0gkQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717617840; a=rsa-sha256; cv=none; b=nglCPUIbVE7vKcsLHvt2JtFF6A86PnLoepixSC5CbUI2GXzhvhj40Z6cutl9CYaJBIFsrM 73C6cbJbLfFqqeHaLSrqgtGBSRP2lk39tAO+javGWt2u0xWF0Xj7ud0/XI9jN4vZNifxfL iFLCHQxc1e6ojNivH6yElNWtSnCGCbRfPPRKBb6dRK9gkWrhUqVdWS3+WZlal4rBe7LUxX snld531xSpnL9Il2wMTF92a08+unhqAEyxRta0+tb3fzdhOlpGtHY68G5Hh7t0IM/pUgH9 Qe3AUjPsI926hE9Or67E3E1/XGJkFvY44iktF2fxGrXR91++LE9U4N1wfeYYRg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717617840; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=N1slBVglaih0WgTh6jqdMYomYeGg6BXnNr0xwCa+7cM=; b=U4FTxfnFgFHqMeZc6ep4TODeH/3GicV+FEuirD9kmjEr+lXzok3V14cXgGUfTF0JhQrwqo 9E024M20unt8yFz1mV+fpIL294AvD4U8trS1jn1SLiB6O+8jyjSjjB+cWo2ceNoJklH/Y9 nCPI/73grhh9f5DdyIfAHteCtngYTGk3A7Qig0x9JcBM8mfN8HEoaW8q/PPGcOKiWI6x6x FMJ6akd+9xgQz4PXgQxFDYUQlMIW3YjGoaZk9p1pBVXaXZOjYfRgECBAYfjQ9SvfYMo3TY T+AB78ZdYqS03Dy/0jrJAjlpqTnIIP57vHBIXBhgOWqBhxeNHtzneguxchsZJg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VvdhJ39pqzGMj; Wed, 5 Jun 2024 20:04:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 455K40UW011664; Wed, 5 Jun 2024 20:04:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 455K4002011660; Wed, 5 Jun 2024 20:04:00 GMT (envelope-from git) Date: Wed, 5 Jun 2024 20:04:00 GMT Message-Id: <202406052004.455K4002011660@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 8a082ca89fc0 - main - nvmf: Factor out most of nvmf_rescan_ns into a helper routine List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8a082ca89fc007850b302f4eead2f9b6eb2ccbe0 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=8a082ca89fc007850b302f4eead2f9b6eb2ccbe0 commit 8a082ca89fc007850b302f4eead2f9b6eb2ccbe0 Author: John Baldwin AuthorDate: 2024-06-05 19:52:24 +0000 Commit: John Baldwin CommitDate: 2024-06-05 19:52:24 +0000 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 --- sys/dev/nvmf/host/nvmf.c | 52 ++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/sys/dev/nvmf/host/nvmf.c b/sys/dev/nvmf/host/nvmf.c index df07d70b6c86..086df5f637c9 100644 --- a/sys/dev/nvmf/host/nvmf.c +++ b/sys/dev/nvmf/host/nvmf.c @@ -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