Commit 25315e96 authored by Mike Snitzer's avatar Mike Snitzer

dm vdo: add 'log_level' module parameter

Expose control over dm-vdo's log-level in terms of a module param. It
can be read and written via /sys/module/dm_vdo/parameters/log_level.
Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
Signed-off-by: default avatarKen Raeburn <raeburn@redhat.com>
Signed-off-by: default avatarMatthew Sakai <msakai@redhat.com>
parent a9da0fb6
......@@ -2905,6 +2905,9 @@ static void __exit vdo_exit(void)
module_init(vdo_init);
module_exit(vdo_exit);
module_param_named(log_level, vdo_log_level, uint, 0644);
MODULE_PARM_DESC(log_level, "Log level for log messages");
MODULE_DESCRIPTION(DM_NAME " target for transparent deduplication");
MODULE_AUTHOR("Red Hat, Inc.");
MODULE_LICENSE("GPL");
......@@ -49,11 +49,17 @@ static const char *const PRIORITY_STRINGS[] = {
"DEBUG",
};
static int log_level = UDS_LOG_INFO;
int vdo_log_level = UDS_LOG_DEFAULT;
int uds_get_log_level(void)
{
return log_level;
int log_level_latch = READ_ONCE(vdo_log_level);
if (unlikely(log_level_latch > UDS_LOG_MAX)) {
log_level_latch = UDS_LOG_DEFAULT;
WRITE_ONCE(vdo_log_level, log_level_latch);
}
return log_level_latch;
}
int uds_log_string_to_priority(const char *string)
......
......@@ -6,20 +6,28 @@
#ifndef UDS_LOGGER_H
#define UDS_LOGGER_H
#include <linux/kern_levels.h>
#include <linux/module.h>
#include <linux/ratelimit.h>
#include <linux/device-mapper.h>
/* Custom logging utilities for UDS */
#define UDS_LOG_EMERG 0
#define UDS_LOG_ALERT 1
#define UDS_LOG_CRIT 2
#define UDS_LOG_ERR 3
#define UDS_LOG_WARNING 4
#define UDS_LOG_NOTICE 5
#define UDS_LOG_INFO 6
#define UDS_LOG_DEBUG 7
enum {
UDS_LOG_EMERG = LOGLEVEL_EMERG,
UDS_LOG_ALERT = LOGLEVEL_ALERT,
UDS_LOG_CRIT = LOGLEVEL_CRIT,
UDS_LOG_ERR = LOGLEVEL_ERR,
UDS_LOG_WARNING = LOGLEVEL_WARNING,
UDS_LOG_NOTICE = LOGLEVEL_NOTICE,
UDS_LOG_INFO = LOGLEVEL_INFO,
UDS_LOG_DEBUG = LOGLEVEL_DEBUG,
UDS_LOG_MAX = UDS_LOG_DEBUG,
UDS_LOG_DEFAULT = UDS_LOG_INFO,
};
extern int vdo_log_level;
#define DM_MSG_PREFIX "vdo"
#define UDS_LOGGING_MODULE_NAME DM_NAME ": " DM_MSG_PREFIX
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment