From nobody Thu Mar 07 01:39:12 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 4TqsR50tV7z5CLlK; Thu, 7 Mar 2024 01:39:13 +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 4TqsR50NHMz4vLY; Thu, 7 Mar 2024 01:39:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709775553; 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=pDnsPyodec7cnjIMbTFAumgFrMSXB8wu1Lg+R3ZMptM=; b=ClZXGNLthXnW8qEanAHFeoTT3PvBMtBJkTQfRFY/yqYEH2xOLCnVIKt7uS29fEz6P7B0FN C+rHtBaaWi83j8JMHJL40PqkDplNnbc4QGi5n4w96rvUtAWNpo7L1M27kF/ktUWaWT+Rgs PVN0mZoj4pwVksJIKcQ6omhY03EVq/TpKQmTBFwvlUf5XLNX6/6qEyWEDhtOVe+nXrEGpD ZO+fDiKH5pu3oYUByiCJ3PmKbFPg2nsMAco/ZHxrqKXVO3R6O6eiSPr8mhqvWf7xEmVtmT YnuvhO+1hqLdw8RxKB12TZtJ9VtD3jZxmQJaa0V9adw+BLpa6f0Hb05ODH2UCQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709775553; a=rsa-sha256; cv=none; b=xR6lHMXi3fV1a146/G7YOS94F+4v3LUL3oCzMbPDu1dZz8QVZjn/LNkQegOT8U7VHW6Obx gvvrntiPaXm4mYj4wNHJgfJ4JcOca85nX/jdIUGjHOuqxx3iinVdEjlts1rsFAu5vjGksm xUp4AVe1n3PAkhQdFxBlJTd7OvyJZmGvu8O9KW1lDeg5Z2GnlKoG/Ka8Voey0lQuO0Dane LBNn0qRRNAyDSdPxUIn3tf/UF3U3w1i1Z58djyrpALnNu4IqF6SL23D6TK+dGNYeSrFuTS nP1oZE5cIhr4NhGUIX2Cv5KqlhTcBcVoXTrQbDdMlkIvnYLGQeVOj7RcSbYfSg== 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=1709775553; 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=pDnsPyodec7cnjIMbTFAumgFrMSXB8wu1Lg+R3ZMptM=; b=bdKg9zH/2Kn4wIiQdE80D3Z2ILrkcsZ2NxUkybUaY7XzL23z0o/yxz1nfD9q+LHX008SeG qeZ/rU1QLULfUgvlk7T90QFyGlUwT9oL2jORha3RJYsDRX8+92yl2NY02Mm2Ysv2Wl4Owk +bbUpRVwMilJuCLu1z592Dl29um0Xt4dA2eeeld8MavFjIWmcW6TUiA0hVY5hyyxM9bPa9 LkQ63fogd0ubRXBWK5l/Syr2jlpkwYnrr8OrHoOJAyZZqGBjn8tPPcoGsykJq+IdRiYMLp OxopKZPoqTeidKGrQeavsnaB+d4TQx4n2jiWdasuJz+O8CsT5dBvyNwl8+AsZw== 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 4TqsR475l6zF3p; Thu, 7 Mar 2024 01:39:12 +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 4271dCZP057025; Thu, 7 Mar 2024 01:39:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4271dCXb057021; Thu, 7 Mar 2024 01:39:12 GMT (envelope-from git) Date: Thu, 7 Mar 2024 01:39:12 GMT Message-Id: <202403070139.4271dCXb057021@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: fc3afe939530 - main - nvme: split devctl out to its own function 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fc3afe93953082549e84925d303f4d9c8676f0ba Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=fc3afe93953082549e84925d303f4d9c8676f0ba commit fc3afe93953082549e84925d303f4d9c8676f0ba Author: Warner Losh AuthorDate: 2024-03-07 01:22:13 +0000 Commit: Warner Losh CommitDate: 2024-03-07 01:38:59 +0000 nvme: split devctl out to its own function Split the devctl aspect of things out to its own function in nvme_ctrlr_devctl_log. In preparing to document this, and based on actual use, we want something different for the SMART errors, so this will facilitate that. Sponsored by: Netflix Reviewed by: chuck, mav Differential Revision: https://reviews.freebsd.org/D44209 --- sys/dev/nvme/nvme_ctrlr.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index 0d33454125bd..1bc0331f002c 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -55,6 +55,24 @@ nvme_ctrlr_barrier(struct nvme_controller *ctrlr, int flags) bus_barrier(ctrlr->resource, 0, rman_get_size(ctrlr->resource), flags); } +static void +nvme_ctrlr_devctl_va(struct nvme_controller *ctrlr, const char *type, + const char *msg, va_list ap) +{ + struct sbuf sb; + int error; + + if (sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND | SBUF_NOWAIT) == NULL) + return; + sbuf_printf(&sb, "name=\"%s\" reason=\"", device_get_nameunit(ctrlr->dev)); + sbuf_vprintf(&sb, msg, ap); + sbuf_printf(&sb, "\""); + error = sbuf_finish(&sb); + if (error == 0) + devctl_notify("nvme", "controller", type, sbuf_data(&sb)); + sbuf_delete(&sb); +} + static void nvme_ctrlr_devctl_log(struct nvme_controller *ctrlr, const char *type, const char *msg, ...) { @@ -71,17 +89,10 @@ nvme_ctrlr_devctl_log(struct nvme_controller *ctrlr, const char *type, const cha error = sbuf_finish(&sb); if (error == 0) printf("%s\n", sbuf_data(&sb)); - - sbuf_clear(&sb); - sbuf_printf(&sb, "name=\"%s\" reason=\"", device_get_nameunit(ctrlr->dev)); + sbuf_delete(&sb); va_start(ap, msg); - sbuf_vprintf(&sb, msg, ap); + nvme_ctrlr_devctl_va(ctrlr, type, msg, ap); va_end(ap); - sbuf_printf(&sb, "\""); - error = sbuf_finish(&sb); - if (error == 0) - devctl_notify("nvme", "controller", type, sbuf_data(&sb)); - sbuf_delete(&sb); } static int