hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/cifs/cifs_debug.h
....@@ -1,26 +1,18 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 *
34 * Copyright (c) International Business Machines Corp., 2000,2002
45 * Modified by Steve French (sfrench@us.ibm.com)
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
14
- * the GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- *
206 */
217
228 #ifndef _H_CIFS_DEBUG
239 #define _H_CIFS_DEBUG
10
+
11
+#ifdef pr_fmt
12
+#undef pr_fmt
13
+#endif
14
+
15
+#define pr_fmt(fmt) "CIFS: " fmt
2416
2517 void cifs_dump_mem(char *label, void *data, int length);
2618 void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
....@@ -47,28 +39,94 @@
4739 */
4840 #ifdef CONFIG_CIFS_DEBUG
4941
42
+
43
+/*
44
+ * When adding tracepoints and debug messages we have various choices.
45
+ * Some considerations:
46
+ *
47
+ * Use cifs_dbg(VFS, ...) for things we always want logged, and the user to see
48
+ * cifs_info(...) slightly less important, admin can filter via loglevel > 6
49
+ * cifs_dbg(FYI, ...) minor debugging messages, off by default
50
+ * trace_smb3_* ftrace functions are preferred for complex debug messages
51
+ * intended for developers or experienced admins, off by default
52
+ */
53
+
54
+/* Information level messages, minor events */
55
+#define cifs_info_func(ratefunc, fmt, ...) \
56
+ pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)
57
+
58
+#define cifs_info(fmt, ...) \
59
+ cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)
60
+
5061 /* information message: e.g., configuration, major event */
51
-#define cifs_dbg_func(ratefunc, type, fmt, ...) \
52
-do { \
53
- if ((type) & FYI && cifsFYI & CIFS_INFO) { \
54
- pr_debug_ ## ratefunc("%s: " \
55
- fmt, __FILE__, ##__VA_ARGS__); \
56
- } else if ((type) & VFS) { \
57
- pr_err_ ## ratefunc("CIFS VFS: " \
58
- fmt, ##__VA_ARGS__); \
59
- } else if ((type) & NOISY && (NOISY != 0)) { \
60
- pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__); \
61
- } \
62
+#define cifs_dbg_func(ratefunc, type, fmt, ...) \
63
+do { \
64
+ if ((type) & FYI && cifsFYI & CIFS_INFO) { \
65
+ pr_debug_ ## ratefunc("%s: " fmt, \
66
+ __FILE__, ##__VA_ARGS__); \
67
+ } else if ((type) & VFS) { \
68
+ pr_err_ ## ratefunc("VFS: " fmt, ##__VA_ARGS__); \
69
+ } else if ((type) & NOISY && (NOISY != 0)) { \
70
+ pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__); \
71
+ } \
6272 } while (0)
6373
64
-#define cifs_dbg(type, fmt, ...) \
65
-do { \
66
- if ((type) & ONCE) \
67
- cifs_dbg_func(once, \
68
- type, fmt, ##__VA_ARGS__); \
69
- else \
70
- cifs_dbg_func(ratelimited, \
71
- type, fmt, ##__VA_ARGS__); \
74
+#define cifs_dbg(type, fmt, ...) \
75
+do { \
76
+ if ((type) & ONCE) \
77
+ cifs_dbg_func(once, type, fmt, ##__VA_ARGS__); \
78
+ else \
79
+ cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__); \
80
+} while (0)
81
+
82
+#define cifs_server_dbg_func(ratefunc, type, fmt, ...) \
83
+do { \
84
+ const char *sn = ""; \
85
+ if (server && server->hostname) \
86
+ sn = server->hostname; \
87
+ if ((type) & FYI && cifsFYI & CIFS_INFO) { \
88
+ pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \
89
+ __FILE__, sn, ##__VA_ARGS__); \
90
+ } else if ((type) & VFS) { \
91
+ pr_err_ ## ratefunc("VFS: \\\\%s " fmt, \
92
+ sn, ##__VA_ARGS__); \
93
+ } else if ((type) & NOISY && (NOISY != 0)) { \
94
+ pr_debug_ ## ratefunc("\\\\%s " fmt, \
95
+ sn, ##__VA_ARGS__); \
96
+ } \
97
+} while (0)
98
+
99
+#define cifs_server_dbg(type, fmt, ...) \
100
+do { \
101
+ if ((type) & ONCE) \
102
+ cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__); \
103
+ else \
104
+ cifs_server_dbg_func(ratelimited, type, fmt, \
105
+ ##__VA_ARGS__); \
106
+} while (0)
107
+
108
+#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
109
+do { \
110
+ const char *tn = ""; \
111
+ if (tcon && tcon->treeName) \
112
+ tn = tcon->treeName; \
113
+ if ((type) & FYI && cifsFYI & CIFS_INFO) { \
114
+ pr_debug_ ## ratefunc("%s: %s " fmt, \
115
+ __FILE__, tn, ##__VA_ARGS__); \
116
+ } else if ((type) & VFS) { \
117
+ pr_err_ ## ratefunc("VFS: %s " fmt, tn, ##__VA_ARGS__); \
118
+ } else if ((type) & NOISY && (NOISY != 0)) { \
119
+ pr_debug_ ## ratefunc("%s " fmt, tn, ##__VA_ARGS__); \
120
+ } \
121
+} while (0)
122
+
123
+#define cifs_tcon_dbg(type, fmt, ...) \
124
+do { \
125
+ if ((type) & ONCE) \
126
+ cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__); \
127
+ else \
128
+ cifs_tcon_dbg_func(ratelimited, type, fmt, \
129
+ ##__VA_ARGS__); \
72130 } while (0)
73131
74132 /*
....@@ -81,6 +139,22 @@
81139 if (0) \
82140 pr_debug(fmt, ##__VA_ARGS__); \
83141 } while (0)
142
+
143
+#define cifs_server_dbg(type, fmt, ...) \
144
+do { \
145
+ if (0) \
146
+ pr_debug("\\\\%s " fmt, \
147
+ server->hostname, ##__VA_ARGS__); \
148
+} while (0)
149
+
150
+#define cifs_tcon_dbg(type, fmt, ...) \
151
+do { \
152
+ if (0) \
153
+ pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \
154
+} while (0)
155
+
156
+#define cifs_info(fmt, ...) \
157
+ pr_info(fmt, ##__VA_ARGS__)
84158 #endif
85159
86160 #endif /* _H_CIFS_DEBUG */