From nobody Wed Jun 05 20:04:01 2024 X-Original-To: dev-commits-src-main@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 4VvdhK6hL7z5M3Zn; Wed, 05 Jun 2024 20:04:01 +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 4VvdhK4jSQz4jBX; Wed, 5 Jun 2024 20:04:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717617841; 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=t+PathxO4z6yerhIeVXY0zEEQ0oVDRHjaoYDJ+1uRS8=; b=KzzwVaoSVk9Pfr5DSTKnVBapkdSkwhsOn+5tYLJf3dBwVIGdsOi8ui+O5sNdhTH4QoDkwC EXgZZDcAoP24ybF9u2RN9bSoByuzZcrWIUH0NYdkyyELFcUVzqccwDvj4OocLPEte91eV3 5vyG/wFLNqiemSErLuR+zQjvoCKYQsiK0LyuetR0SGCYdbbiX60TdUCzVl2fXe9RRcHsII HNvG1JkyrJJE9l+mQ8TBtM9cDUnfGOdt26mZEBb4E8JIU7V3hQt1RqSPRz3b9gR+kiBlwu hBQeKmZM0WLh5hfk6j7oLqhzXcJ0Bn6ouahISapL+pOrgLq5gypQavd5mAo7+Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717617841; a=rsa-sha256; cv=none; b=ttYP9AnTXYlYEUeKpYh7IzHXUkoYWXUSYmtBCx98B9jhzl8pIO30fMj3X8MxuqDctsTN97 NO4ybIKaAdZ6+TQ2CGzk9dwAzI0FRz7HN+1n3NCeqGVkJbWzTyYR2Cz0MB6i39LhzddpGC Mc29kM+8uumqeWp0TtYTP7ALss205TqsX5N5e5hhevHvAlSONbUYdql3nQ7CdvKPLlrKbe if5kua/y46o3cdqDkXUC+7hG238GU+d0GTK0sEQUNE6ZUg/VSEM7GGVDV8ZuVBZmFkIlhs uDC8V3eQAnEY7ee54gFBFXUHSM+CdmTdSnVhF0b6zVtPZkvQSsaWNofSi97MyA== 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=1717617841; 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=t+PathxO4z6yerhIeVXY0zEEQ0oVDRHjaoYDJ+1uRS8=; b=G1iQSEZbD6kF7z9i5UzgUidFd8vU66vYOEOJ6yfu7ygmcf0XySqrLNc+7KAzlpsVwESN3J /V/gw5vjd11jw0k1zFPAyzg47gKXjHEGE3mUv/M0uX9h+IjYlhwjYyh4y8/uBogDInTUR0 JHAhj+cHxJLw++0gJzXA94jOJJQjxH1sw+5MwybiC50e8tGe8PSEJTRnyXgziac8cwF5fC /D1yMa/DgReD2KQzB2w+tZ6udqau48SjXiWvMXlplssCrsVs6MG7osOM1vk+OfFkDQ7rEu BRYoxLDO6IGDeAytnvsPUIaiK/6shzgVNuNMaQbFGGWiUzTgL7owAq372peEPw== 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 4VvdhK4FgVzGMk; Wed, 5 Jun 2024 20:04:01 +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 455K414S011736; Wed, 5 Jun 2024 20:04:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 455K41wc011733; Wed, 5 Jun 2024 20:04:01 GMT (envelope-from git) Date: Wed, 5 Jun 2024 20:04:01 GMT Message-Id: <202406052004.455K41wc011733@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: f6d434f110fd - main - nvmf: Rescan all namespaces if the changed NS log page is too large List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: f6d434f110fd95e346f18fb09a6f91f36b528d2d Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f6d434f110fd95e346f18fb09a6f91f36b528d2d commit f6d434f110fd95e346f18fb09a6f91f36b528d2d Author: John Baldwin AuthorDate: 2024-06-05 19:52:43 +0000 Commit: John Baldwin CommitDate: 2024-06-05 19:52:43 +0000 nvmf: Rescan all namespaces if the changed NS log page is too large Previously this just punted with a warning message. Reviewed by: imp Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D45460 --- sys/dev/nvmf/host/nvmf.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ sys/dev/nvmf/host/nvmf_aer.c | 2 +- sys/dev/nvmf/host/nvmf_var.h | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/sys/dev/nvmf/host/nvmf.c b/sys/dev/nvmf/host/nvmf.c index 086df5f637c9..1e7fce42b2a3 100644 --- a/sys/dev/nvmf/host/nvmf.c +++ b/sys/dev/nvmf/host/nvmf.c @@ -804,6 +804,55 @@ nvmf_rescan_ns(struct nvmf_softc *sc, uint32_t nsid) 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 index 4c950f1518d0..2f7f177d0421 100644 --- a/sys/dev/nvmf/host/nvmf_aer.c +++ b/sys/dev/nvmf/host/nvmf_aer.c @@ -62,7 +62,7 @@ nvmf_handle_changed_namespaces(struct nvmf_softc *sc, * 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 index e0f6d33d2a73..2fa0216baab8 100644 --- a/sys/dev/nvmf/host/nvmf_var.h +++ b/sys/dev/nvmf/host/nvmf_var.h @@ -148,6 +148,7 @@ int nvmf_init_ivars(struct nvmf_ivars *ivars, struct nvmf_handoff_host *hh); 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);