File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2905,6 +2905,9 @@ static void __exit vdo_exit(void)
29052905module_init (vdo_init );
29062906module_exit (vdo_exit );
29072907
2908+ module_param_named (log_level , vdo_log_level , uint , 0644 );
2909+ MODULE_PARM_DESC (log_level , "Log level for log messages" );
2910+
29082911MODULE_DESCRIPTION (DM_NAME " target for transparent deduplication" );
29092912MODULE_AUTHOR ("Red Hat, Inc." );
29102913MODULE_LICENSE ("GPL" );
Original file line number Diff line number Diff line change @@ -49,11 +49,17 @@ static const char *const PRIORITY_STRINGS[] = {
4949 "DEBUG" ,
5050};
5151
52- static int log_level = UDS_LOG_INFO ;
52+ int vdo_log_level = UDS_LOG_DEFAULT ;
5353
5454int uds_get_log_level (void )
5555{
56- return log_level ;
56+ int log_level_latch = READ_ONCE (vdo_log_level );
57+
58+ if (unlikely (log_level_latch > UDS_LOG_MAX )) {
59+ log_level_latch = UDS_LOG_DEFAULT ;
60+ WRITE_ONCE (vdo_log_level , log_level_latch );
61+ }
62+ return log_level_latch ;
5763}
5864
5965int uds_log_string_to_priority (const char * string )
Original file line number Diff line number Diff line change 66#ifndef UDS_LOGGER_H
77#define UDS_LOGGER_H
88
9+ #include <linux/kern_levels.h>
910#include <linux/module.h>
1011#include <linux/ratelimit.h>
1112#include <linux/device-mapper.h>
1213
1314/* Custom logging utilities for UDS */
1415
15- #define UDS_LOG_EMERG 0
16- #define UDS_LOG_ALERT 1
17- #define UDS_LOG_CRIT 2
18- #define UDS_LOG_ERR 3
19- #define UDS_LOG_WARNING 4
20- #define UDS_LOG_NOTICE 5
21- #define UDS_LOG_INFO 6
22- #define UDS_LOG_DEBUG 7
16+ enum {
17+ UDS_LOG_EMERG = LOGLEVEL_EMERG ,
18+ UDS_LOG_ALERT = LOGLEVEL_ALERT ,
19+ UDS_LOG_CRIT = LOGLEVEL_CRIT ,
20+ UDS_LOG_ERR = LOGLEVEL_ERR ,
21+ UDS_LOG_WARNING = LOGLEVEL_WARNING ,
22+ UDS_LOG_NOTICE = LOGLEVEL_NOTICE ,
23+ UDS_LOG_INFO = LOGLEVEL_INFO ,
24+ UDS_LOG_DEBUG = LOGLEVEL_DEBUG ,
25+
26+ UDS_LOG_MAX = UDS_LOG_DEBUG ,
27+ UDS_LOG_DEFAULT = UDS_LOG_INFO ,
28+ };
29+
30+ extern int vdo_log_level ;
2331
2432#define DM_MSG_PREFIX "vdo"
2533#define UDS_LOGGING_MODULE_NAME DM_NAME ": " DM_MSG_PREFIX
You can’t perform that action at this time.
0 commit comments