zfs_debug: specific variant for userspace

Just nice and simple, with room to grow.

Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <robn@despairlabs.com>
Sponsored-by: https://despairlabs.com/sponsor/
Closes #16492
This commit is contained in:
Rob Norris
2024-08-28 22:28:58 +10:00
committed by Brian Behlendorf
parent c22d56e3ed
commit e8ede2ba78
5 changed files with 118 additions and 82 deletions
-40
View File
@@ -111,12 +111,7 @@ zfs_dbgmsg_fini(void)
procfs_list_uninstall(&zfs_dbgmsgs);
zfs_dbgmsg_purge(0);
/*
* TODO - decide how to make this permanent
*/
#ifdef _KERNEL
procfs_list_destroy(&zfs_dbgmsgs);
#endif
}
void
@@ -148,8 +143,6 @@ __zfs_dbgmsg(char *buf)
mutex_exit(&zfs_dbgmsgs.pl_lock);
}
#ifdef _KERNEL
void
__dprintf(boolean_t dprint, const char *file, const char *func,
int line, const char *fmt, ...)
@@ -218,38 +211,6 @@ __dprintf(boolean_t dprint, const char *file, const char *func,
kmem_free(buf, size);
}
#else
void
zfs_dbgmsg_print(int fd, 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.
*/
ret = write(fd, "ZFS_DBGMSG(", 11);
ret = write(fd, tag, strlen(tag));
ret = write(fd, ") START:\n", 9);
for (zfs_dbgmsg_t *zdm = list_head(&zfs_dbgmsgs.pl_list); zdm != NULL;
zdm = list_next(&zfs_dbgmsgs.pl_list, zdm)) {
ret = write(fd, zdm->zdm_msg, strlen(zdm->zdm_msg));
ret = write(fd, "\n", 1);
}
ret = write(fd, "ZFS_DBGMSG(", 11);
ret = write(fd, tag, strlen(tag));
ret = write(fd, ") END\n", 6);
mutex_exit(&zfs_dbgmsgs.pl_lock);
}
#endif /* _KERNEL */
#ifdef _KERNEL
module_param(zfs_dbgmsg_enable, int, 0644);
MODULE_PARM_DESC(zfs_dbgmsg_enable, "Enable ZFS debug message log");
@@ -257,4 +218,3 @@ MODULE_PARM_DESC(zfs_dbgmsg_enable, "Enable ZFS debug message log");
module_param(zfs_dbgmsg_maxsize, uint, 0644);
/* END CSTYLED */
MODULE_PARM_DESC(zfs_dbgmsg_maxsize, "Maximum ZFS debug log size");
#endif