git: 4f817fcf6a26 - main - nvme: Change devctl events for the controller
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 07 Mar 2024 01:39:14 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=4f817fcf6a26435ef634645d9be9ef641b6ee164 commit 4f817fcf6a26435ef634645d9be9ef641b6ee164 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-03-07 01:22:26 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-03-07 01:38:59 +0000 nvme: Change devctl events for the controller Change the devctl events slightly for the controller. SMART errors will log the changed bits in the NVME SMART Critical Warning State as its event. Reset will now emit 'event=start'. Soon more. Sponsored by: Netflix Reviewed by: mav Differential Revision: https://reviews.freebsd.org/D44210 --- sys/dev/nvme/nvme_ctrlr.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index 1bc0331f002c..609794edbf67 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -64,15 +64,24 @@ nvme_ctrlr_devctl_va(struct nvme_controller *ctrlr, const char *type, if (sbuf_new(&sb, NULL, 0, SBUF_AUTOEXTEND | SBUF_NOWAIT) == NULL) return; - sbuf_printf(&sb, "name=\"%s\" reason=\"", device_get_nameunit(ctrlr->dev)); + sbuf_printf(&sb, "name=\"%s\" ", 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(struct nvme_controller *ctrlr, const char *type, const char *msg, ...) +{ + va_list ap; + + va_start(ap, msg); + nvme_ctrlr_devctl_va(ctrlr, type, msg, ap); + va_end(ap); +} + static void nvme_ctrlr_devctl_log(struct nvme_controller *ctrlr, const char *type, const char *msg, ...) { @@ -640,29 +649,25 @@ nvme_ctrlr_log_critical_warnings(struct nvme_controller *ctrlr, { if (state & NVME_CRIT_WARN_ST_AVAILABLE_SPARE) - nvme_ctrlr_devctl_log(ctrlr, "critical", - "available spare space below threshold"); + nvme_printf(ctrlr, "SMART WARNING: available spare space below threshold\n"); if (state & NVME_CRIT_WARN_ST_TEMPERATURE) - nvme_ctrlr_devctl_log(ctrlr, "critical", - "temperature above threshold"); + nvme_printf(ctrlr, "SMART WARNING: temperature above threshold\n"); if (state & NVME_CRIT_WARN_ST_DEVICE_RELIABILITY) - nvme_ctrlr_devctl_log(ctrlr, "critical", - "device reliability degraded"); + nvme_printf(ctrlr, "SMART WARNING: device reliability degraded\n"); if (state & NVME_CRIT_WARN_ST_READ_ONLY) - nvme_ctrlr_devctl_log(ctrlr, "critical", - "media placed in read only mode"); + nvme_printf(ctrlr, "SMART WARNING: media placed in read only mode\n"); if (state & NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP) - nvme_ctrlr_devctl_log(ctrlr, "critical", - "volatile memory backup device failed"); + nvme_printf(ctrlr, "SMART WARNING: volatile memory backup device failed\n"); if (state & NVME_CRIT_WARN_ST_RESERVED_MASK) - nvme_ctrlr_devctl_log(ctrlr, "critical", - "unknown critical warning(s): state = 0x%02x", + nvme_printf(ctrlr, "SMART WARNING: unknown critical warning(s): state = 0x%02x\n", state & NVME_CRIT_WARN_ST_RESERVED_MASK); + + nvme_ctrlr_devctl(ctrlr, "critical", "SMART_ERROR", "state=0x%02x", state); } static void @@ -1172,7 +1177,7 @@ nvme_ctrlr_reset_task(void *arg, int pending) struct nvme_controller *ctrlr = arg; int status; - nvme_ctrlr_devctl_log(ctrlr, "RESET", "resetting controller"); + nvme_ctrlr_devctl_log(ctrlr, "RESET", "event=\"start\""); status = nvme_ctrlr_hw_reset(ctrlr); if (status == 0) nvme_ctrlr_start(ctrlr, true);