File tree Expand file tree Collapse file tree 3 files changed +27
-10
lines changed Expand file tree Collapse file tree 3 files changed +27
-10
lines changed Original file line number Diff line number Diff line change @@ -2905,6 +2905,9 @@ static void __exit vdo_exit(void)
2905
2905
module_init (vdo_init );
2906
2906
module_exit (vdo_exit );
2907
2907
2908
+ module_param_named (log_level , vdo_log_level , uint , 0644 );
2909
+ MODULE_PARM_DESC (log_level , "Log level for log messages" );
2910
+
2908
2911
MODULE_DESCRIPTION (DM_NAME " target for transparent deduplication" );
2909
2912
MODULE_AUTHOR ("Red Hat, Inc." );
2910
2913
MODULE_LICENSE ("GPL" );
Original file line number Diff line number Diff line change @@ -49,11 +49,17 @@ static const char *const PRIORITY_STRINGS[] = {
49
49
"DEBUG" ,
50
50
};
51
51
52
- static int log_level = UDS_LOG_INFO ;
52
+ int vdo_log_level = UDS_LOG_DEFAULT ;
53
53
54
54
int uds_get_log_level (void )
55
55
{
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 ;
57
63
}
58
64
59
65
int uds_log_string_to_priority (const char * string )
Original file line number Diff line number Diff line change 6
6
#ifndef UDS_LOGGER_H
7
7
#define UDS_LOGGER_H
8
8
9
+ #include <linux/kern_levels.h>
9
10
#include <linux/module.h>
10
11
#include <linux/ratelimit.h>
11
12
#include <linux/device-mapper.h>
12
13
13
14
/* Custom logging utilities for UDS */
14
15
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 ;
23
31
24
32
#define DM_MSG_PREFIX "vdo"
25
33
#define UDS_LOGGING_MODULE_NAME DM_NAME ": " DM_MSG_PREFIX
You can’t perform that action at this time.
0 commit comments