From owner-svn-src-all@freebsd.org Thu Sep 17 21:51:06 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5C7BE3EF604; Thu, 17 Sep 2020 21:51:06 +0000 (UTC) (envelope-from allanjude@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BsrJB1sPxz4gHj; Thu, 17 Sep 2020 21:51:06 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 247A310C9B; Thu, 17 Sep 2020 21:51:06 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08HLp6Y1030987; Thu, 17 Sep 2020 21:51:06 GMT (envelope-from allanjude@FreeBSD.org) Received: (from allanjude@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08HLp6RU030986; Thu, 17 Sep 2020 21:51:06 GMT (envelope-from allanjude@FreeBSD.org) Message-Id: <202009172151.08HLp6RU030986@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: allanjude set sender to allanjude@FreeBSD.org using -f From: Allan Jude Date: Thu, 17 Sep 2020 21:51:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r365860 - stable/12/sys/cddl/compat/opensolaris/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: allanjude X-SVN-Commit-Paths: stable/12/sys/cddl/compat/opensolaris/kern X-SVN-Commit-Revision: 365860 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Sep 2020 21:51:06 -0000 Author: allanjude Date: Thu Sep 17 21:51:05 2020 New Revision: 365860 URL: https://svnweb.freebsd.org/changeset/base/365860 Log: Update naming of per-dataset counters introduced in r365689 Upstream OpenZFS is changing the structure of the sysctl mibs to avoid having a / in the element name. Chase this change here to avoid introducing a new sysctl that will change named between 12.2 and 13.0 MFC-with: 365689 Relnotes: yes (fix example) Sponsored by: Klara Inc. Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c Thu Sep 17 21:24:11 2020 (r365859) +++ stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_kstat.c Thu Sep 17 21:51:05 2020 (r365860) @@ -55,6 +55,7 @@ kstat_create(char *module, int instance, char *name, c { struct sysctl_oid *root; kstat_t *ksp; + char *pool; KASSERT(instance == 0, ("instance=%d", instance)); KASSERT(type == KSTAT_TYPE_NAMED, ("type=%hhu", type)); @@ -70,9 +71,18 @@ kstat_create(char *module, int instance, char *name, c ksp->ks_update = kstat_default_update; /* + * Some kstats use a module name like "zfs/poolname" to distinguish a + * set of kstats belonging to a specific pool. Split on '/' to add an + * extra node for the pool name if needed. + */ + pool = strchr(module, '/'); + if (pool != NULL) + *pool++ = '\0'; + + /* * Create sysctl tree for those statistics: * - * kstat.... + * kstat.[.].. */ sysctl_ctx_init(&ksp->ks_sysctl_ctx); root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, @@ -84,11 +94,26 @@ kstat_create(char *module, int instance, char *name, c free(ksp, M_KSTAT); return (NULL); } + if (pool != NULL) { + root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, + SYSCTL_CHILDREN(root), OID_AUTO, pool, CTLFLAG_RW, 0, ""); + if (root == NULL) { + printf("%s: Cannot create kstat.%s.%s tree!\n", + __func__, module, pool); + sysctl_ctx_free(&ksp->ks_sysctl_ctx); + free(ksp, M_KSTAT); + return (NULL); + } + } root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(root), OID_AUTO, class, CTLFLAG_RW, 0, ""); if (root == NULL) { - printf("%s: Cannot create kstat.%s.%s tree!\n", __func__, - module, class); + if (pool != NULL) + printf("%s: Cannot create kstat.%s.%s.%s tree!\n", + __func__, module, pool, class); + else + printf("%s: Cannot create kstat.%s.%s tree!\n", + __func__, module, class); sysctl_ctx_free(&ksp->ks_sysctl_ctx); free(ksp, M_KSTAT); return (NULL); @@ -96,8 +121,13 @@ kstat_create(char *module, int instance, char *name, c root = SYSCTL_ADD_NODE(&ksp->ks_sysctl_ctx, SYSCTL_CHILDREN(root), OID_AUTO, name, CTLFLAG_RW, 0, ""); if (root == NULL) { - printf("%s: Cannot create kstat.%s.%s.%s tree!\n", __func__, - module, class, name); + if (pool != NULL) + printf("%s: Cannot create kstat.%s.%s.%s.%s " + "tree!\n", __func__, module, pool, class, + name); + else + printf("%s: Cannot create kstat.%s.%s.%s " + "tree!\n", __func__, module, class, name); sysctl_ctx_free(&ksp->ks_sysctl_ctx); free(ksp, M_KSTAT); return (NULL);