From ac04407ffec555f2a3385d8e817d0c20870ce33c Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 17 Sep 2024 16:15:42 -0400 Subject: [PATCH] Remove extra newline from spa_set_allocator(). zfs_dbgmsg() does not need newline at the end of the message. While there, slightly update/sync FreeBSD __dprintf(). Reviewed by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16536 --- module/os/freebsd/zfs/zfs_debug.c | 15 +++++++++++---- module/zfs/metaslab.c | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/module/os/freebsd/zfs/zfs_debug.c b/module/os/freebsd/zfs/zfs_debug.c index c4cebe102..d08d445e8 100644 --- a/module/os/freebsd/zfs/zfs_debug.c +++ b/module/os/freebsd/zfs/zfs_debug.c @@ -218,12 +218,19 @@ __dprintf(boolean_t dprint, const char *file, const char *func, } /* - * Get rid of trailing newline. + * Get rid of trailing newline for dprintf logs. */ - nl = strrchr(buf, '\n'); - if (nl != NULL) - *nl = '\0'; + if (dprint && buf[0] != '\0') { + nl = &buf[strlen(buf) - 1]; + if (*nl == '\n') + *nl = '\0'; + } + /* + * To get this data: + * + * $ sysctl -n kstat.zfs.misc.dbgmsg + */ __zfs_dbgmsg(buf); kmem_free(buf, size); diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c index 7170b5eef..3bd6e93e9 100644 --- a/module/zfs/metaslab.c +++ b/module/zfs/metaslab.c @@ -1679,7 +1679,7 @@ spa_set_allocator(spa_t *spa, const char *allocator) int a = spa_find_allocator_byname(allocator); if (a < 0) a = 0; spa->spa_active_allocator = a; - zfs_dbgmsg("spa allocator: %s\n", metaslab_allocators[a].msop_name); + zfs_dbgmsg("spa allocator: %s", metaslab_allocators[a].msop_name); } int