Skip to contentSkip to conversation

cifs: add new debugging macro cifs_server_dbg

PATCH In review Ronnie Sahlberg 3 participants 3 messages Aug 28, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: add new debugging macro cifs_server_dbg

which can be used from contexts where we have a TCP_Server_Info *server. This new macro will prepend the debugging string with "Server:<servername> " which will help when debugging issues on hosts with many cifs connections to several different servers.

Convert a bunch of callsites in connect.c from cifs_dbg to instead use cifs_server_dbg.

---
 fs/cifs/cifs_debug.h |  31 ++++++++
 fs/cifs/connect.c    | 194 +++++++++++++++++++++++++--------------------------
 2 files changed, 128 insertions(+), 97 deletions(-)
fs/cifs/cifs_debug.h +31 -0
index 3d392620a2f4..567af916f103 100644
@@ -80,6 +80,30 @@ do {							\
 			type, fmt, ##__VA_ARGS__);	\
 } while (0)
 
+#define cifs_server_dbg_func(ratefunc, type, fmt, ...)		\
+do {								\
+	if ((type) & FYI && cifsFYI & CIFS_INFO) {		\
+		pr_debug_ ## ratefunc("%s: Server:%s "	fmt,	\
+			__FILE__, server->hostname, ##__VA_ARGS__);\
+	} else if ((type) & VFS) {				\
+		pr_err_ ## ratefunc("CIFS VFS: Server:%s " fmt,	\
+			server->hostname, ##__VA_ARGS__);	\
+	} else if ((type) & NOISY && (NOISY != 0)) {		\
+		pr_debug_ ## ratefunc("Server:%s " fmt,		\
+			server->hostname, ##__VA_ARGS__);	\
+	}							\
+} while (0)
+
+#define cifs_server_dbg(type, fmt, ...)			\
+do {							\
+	if ((type) & ONCE)				\
+		cifs_server_dbg_func(once,		\
+			type, fmt, ##__VA_ARGS__);	\
+	else						\
+		cifs_server_dbg_func(ratelimited,	\
+			type, fmt, ##__VA_ARGS__);	\
+} while (0)
+
 /*
  *	debug OFF
  *	---------
@@ -91,6 +115,13 @@ do {									\
 		pr_debug(fmt, ##__VA_ARGS__);				\
 } while (0)
 
+#define cifs_server_dbg(type, fmt, ...)					\
+do {									\
+	if (0)								\
+		pr_debug("Server:%s " fmt,				\
+			 server->hostname, ##__VA_ARGS__);		\
+} while (0)
+
 #define cifs_info(fmt, ...)						\
 do {									\
 	pr_info("CIFS: "fmt, ##__VA_ARGS__);				\
fs/cifs/connect.c +97 -97

658 lines not on this page · raw message

Signature · 1 line
2.13.6
#1 lore raw
Quoted 7 lines · Ronnie Sahlberg

which can be used from contexts where we have a TCP_Server_Info *server. This new macro will prepend the debugging string with "Server:<servername> " which will help when debugging issues on hosts with many cifs connections to several different servers.

Convert a bunch of callsites in connect.c from cifs_dbg to instead use cifs_server_dbg.

This looks like a poorman's ftrace. I'm not sure about it I think it would make more sense to add those (or convert) as ftrace tracepoints as it supports filtering built-in.

Signature · 4 lines
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
#2 lore raw
Quoted 7 lines · Aurélien Aptel
Quoted 5 lines · Ronnie Sahlberg

which can be used from contexts where we have a TCP_Server_Info *server. This new macro will prepend the debugging string with "Server:<servername> " which will help when debugging issues on hosts with many cifs connections to several different servers.

Quoted 6 lines
Quoted 2 lines

Convert a bunch of callsites in connect.c from cifs_dbg to instead use cifs_server_dbg.

This looks like a poorman's ftrace. I'm not sure about it I think it would make more sense to add those (or convert) as ftrace tracepoints as it supports filtering built-in.

In a sense they are but the usecase is different.
Ftrace is way superior if you can handily reproduce an issue in a lab and test. This is to make the dmesg output more meaningful for production scenarios where running a long ftrace is not an option.

If there is an issue that takes days/weeks/.. to reproduce on a production system
you can't run ftrace for that long.

This is for triage when you have rare events that can not (easily) be reproduced on production
systems and when after the fact you only have dmesg to further aid in how to proceed to triage an issue.

Quoted 6 lines

--
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)