zfs_dbgmsg_print: make FreeBSD and Linux consistent

FreeBSD was using fprintf(), which might not be signal-safe. Meanwhile,
Linux's locking did not cover the header output. This two quirks are
unrelated, but both have the same response: be like the other one. So
with this commit, both functions are the same except for the names of
their lock and list variables.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16181
This commit is contained in:
Rob Norris
2024-05-10 13:54:08 +10:00
committed by Brian Behlendorf
parent 1ea8c59441
commit fa99d9cd9c
2 changed files with 22 additions and 5 deletions
+2 -1
View File
@@ -225,6 +225,8 @@ zfs_dbgmsg_print(const char *tag)
{
ssize_t ret __attribute__((unused));
mutex_enter(&zfs_dbgmsgs.pl_lock);
/*
* We use write() in this function instead of printf()
* so it is safe to call from a signal handler.
@@ -233,7 +235,6 @@ zfs_dbgmsg_print(const char *tag)
ret = write(STDOUT_FILENO, tag, strlen(tag));
ret = write(STDOUT_FILENO, ") START:\n", 9);
mutex_enter(&zfs_dbgmsgs.pl_lock);
for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs.pl_list); zdm != NULL;
zdm = list_next(&zfs_dbgmsgs.pl_list, zdm)) {
ret = write(STDOUT_FILENO, zdm->zdm_msg,