Commit a0a3036b authored by Joe Perches's avatar Joe Perches Committed by Steve French
Browse files

cifs: Standardize logging output



Use pr_fmt to standardize all logging for fs/cifs.

Some logging output had no CIFS: specific prefix.

Now all output has one of three prefixes:

o CIFS:
o CIFS: VFS:
o Root-CIFS:

Miscellanea:

o Convert printks to pr_<level>
o Neaten macro definitions
o Remove embedded CIFS: prefixes from formats
o Convert "illegal" to "invalid"
o Coalesce formats
o Add missing '\n' format terminations
o Consolidate multiple cifs_dbg continuations into single calls
o More consistent use of upper case first word output logging
o Multiline statement argument alignment and wrapping

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 82e9367c
Loading
Loading
Loading
Loading
+69 −76
Original line number Diff line number Diff line
@@ -8,6 +8,12 @@
#ifndef _H_CIFS_DEBUG
#define _H_CIFS_DEBUG

#ifdef pr_fmt
#undef pr_fmt
#endif

#define pr_fmt(fmt) "CIFS: " fmt

void cifs_dump_mem(char *label, void *data, int length);
void cifs_dump_detail(void *buf, struct TCP_Server_Info *ptcp_info);
void cifs_dump_mids(struct TCP_Server_Info *);
@@ -47,24 +53,19 @@ extern int cifsFYI;

/* Information level messages, minor events */
#define cifs_info_func(ratefunc, fmt, ...)				\
do {								\
	pr_info_ ## ratefunc("CIFS: " fmt, ##__VA_ARGS__); 	\
} while (0)
	pr_info_ ## ratefunc(fmt, ##__VA_ARGS__)

#define cifs_info(fmt, ...)						\
do { 								\
	cifs_info_func(ratelimited, fmt, ##__VA_ARGS__); 	\
} while (0)
	cifs_info_func(ratelimited, fmt, ##__VA_ARGS__)

/* information message: e.g., configuration, major event */
#define cifs_dbg_func(ratefunc, type, fmt, ...)				\
do {									\
	if ((type) & FYI && cifsFYI & CIFS_INFO) {			\
		pr_debug_ ## ratefunc("%s: "			\
				fmt, __FILE__, ##__VA_ARGS__);	\
		pr_debug_ ## ratefunc("%s: " fmt,			\
				      __FILE__, ##__VA_ARGS__);		\
	} else if ((type) & VFS) {					\
		pr_err_ ## ratefunc("CIFS VFS: "		\
				 fmt, ##__VA_ARGS__);		\
		pr_err_ ## ratefunc("VFS: " fmt, ##__VA_ARGS__);	\
	} else if ((type) & NOISY && (NOISY != 0)) {			\
		pr_debug_ ## ratefunc(fmt, ##__VA_ARGS__);		\
	}								\
@@ -73,11 +74,9 @@ do { \
#define cifs_dbg(type, fmt, ...)					\
do {									\
	if ((type) & ONCE)						\
		cifs_dbg_func(once,			\
			 type, fmt, ##__VA_ARGS__);	\
		cifs_dbg_func(once, type, fmt, ##__VA_ARGS__);		\
	else								\
		cifs_dbg_func(ratelimited,		\
			type, fmt, ##__VA_ARGS__);	\
		cifs_dbg_func(ratelimited, type, fmt, ##__VA_ARGS__);	\
} while (0)

#define cifs_server_dbg_func(ratefunc, type, fmt, ...)			\
@@ -89,7 +88,7 @@ do { \
		pr_debug_ ## ratefunc("%s: \\\\%s " fmt,		\
				      __FILE__, sn, ##__VA_ARGS__);	\
	} else if ((type) & VFS) {					\
		pr_err_ ## ratefunc("CIFS VFS: \\\\%s " fmt,	\
		pr_err_ ## ratefunc("VFS: \\\\%s " fmt,			\
				    sn, ##__VA_ARGS__);			\
	} else if ((type) & NOISY && (NOISY != 0)) {			\
		pr_debug_ ## ratefunc("\\\\%s " fmt,			\
@@ -100,11 +99,10 @@ do { \
#define cifs_server_dbg(type, fmt, ...)					\
do {									\
	if ((type) & ONCE)						\
		cifs_server_dbg_func(once,		\
			type, fmt, ##__VA_ARGS__);	\
		cifs_server_dbg_func(once, type, fmt, ##__VA_ARGS__);	\
	else								\
		cifs_server_dbg_func(ratelimited,	\
			type, fmt, ##__VA_ARGS__);	\
		cifs_server_dbg_func(ratelimited, type, fmt,		\
				     ##__VA_ARGS__);			\
} while (0)

#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...)			\
@@ -116,22 +114,19 @@ do { \
		pr_debug_ ## ratefunc("%s: %s "	fmt,			\
				      __FILE__, tn, ##__VA_ARGS__);	\
	} else if ((type) & VFS) {					\
		pr_err_ ## ratefunc("CIFS VFS: %s " fmt,	\
			tn, ##__VA_ARGS__);			\
		pr_err_ ## ratefunc("VFS: %s " fmt, tn, ##__VA_ARGS__);	\
	} else if ((type) & NOISY && (NOISY != 0)) {			\
		pr_debug_ ## ratefunc("%s " fmt,		\
			tn, ##__VA_ARGS__);			\
		pr_debug_ ## ratefunc("%s " fmt, tn, ##__VA_ARGS__);	\
	}								\
} while (0)

#define cifs_tcon_dbg(type, fmt, ...)					\
do {									\
	if ((type) & ONCE)						\
		cifs_tcon_dbg_func(once,		\
			type, fmt, ##__VA_ARGS__);	\
		cifs_tcon_dbg_func(once, type, fmt, ##__VA_ARGS__);	\
	else								\
		cifs_tcon_dbg_func(ratelimited,	\
			type, fmt, ##__VA_ARGS__);	\
		cifs_tcon_dbg_func(ratelimited, type, fmt,		\
				   ##__VA_ARGS__);			\
} while (0)

/*
@@ -159,9 +154,7 @@ do { \
} while (0)

#define cifs_info(fmt, ...)						\
do {									\
	pr_info("CIFS: "fmt, ##__VA_ARGS__);				\
} while (0)
	pr_info(fmt, ##__VA_ARGS__)
#endif

#endif				/* _H_CIFS_DEBUG */
+4 −4
Original line number Diff line number Diff line
@@ -520,7 +520,7 @@ static int calc_ntlmv2_hash(struct cifs_ses *ses, char *ntlmv2_hash,

	rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash);
	if (rc) {
		cifs_dbg(VFS, "%s: could not init hmacmd5\n", __func__);
		cifs_dbg(VFS, "%s: Could not init hmacmd5\n", __func__);
		return rc;
	}

@@ -624,7 +624,7 @@ CalcNTLMv2_response(const struct cifs_ses *ses, char *ntlmv2_hash)

	rc = crypto_shash_init(&ses->server->secmech.sdeschmacmd5->shash);
	if (rc) {
		cifs_dbg(VFS, "%s: could not init hmacmd5\n", __func__);
		cifs_dbg(VFS, "%s: Could not init hmacmd5\n", __func__);
		return rc;
	}

@@ -723,7 +723,7 @@ setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp)
	/* calculate ntlmv2_hash */
	rc = calc_ntlmv2_hash(ses, ntlmv2_hash, nls_cp);
	if (rc) {
		cifs_dbg(VFS, "could not get v2 hash rc %d\n", rc);
		cifs_dbg(VFS, "Could not get v2 hash rc %d\n", rc);
		goto unlock;
	}

@@ -783,7 +783,7 @@ calc_seckey(struct cifs_ses *ses)

	ctx_arc4 = kmalloc(sizeof(*ctx_arc4), GFP_KERNEL);
	if (!ctx_arc4) {
		cifs_dbg(VFS, "could not allocate arc4 context\n");
		cifs_dbg(VFS, "Could not allocate arc4 context\n");
		return -ENOMEM;
	}

+13 −13
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ extern void _free_xid(unsigned int);
#define get_xid()							\
({									\
	unsigned int __xid = _get_xid();				\
	cifs_dbg(FYI, "CIFS VFS: in %s as Xid: %u with uid: %d\n",	\
	cifs_dbg(FYI, "VFS: in %s as Xid: %u with uid: %d\n",		\
		 __func__, __xid,					\
		 from_kuid(&init_user_ns, current_fsuid()));		\
	trace_smb3_enter(__xid, __func__);				\
@@ -58,7 +58,7 @@ extern void _free_xid(unsigned int);
#define free_xid(curr_xid)						\
do {									\
	_free_xid(curr_xid);						\
	cifs_dbg(FYI, "CIFS VFS: leaving %s (xid = %u) rc = %d\n",	\
	cifs_dbg(FYI, "VFS: leaving %s (xid = %u) rc = %d\n",		\
		 __func__, curr_xid, (int)rc);				\
	if (rc)								\
		trace_smb3_exit_err(curr_xid, __func__, (int)rc);	\
+3 −3
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ static int __init cifs_root_setup(char *line)
		/* len is strlen(unc) + '\0' */
		len = s - line + 1;
		if (len > sizeof(root_dev)) {
			printk(KERN_ERR "Root-CIFS: UNC path too long\n");
			pr_err("Root-CIFS: UNC path too long\n");
			return 1;
		}
		strlcpy(root_dev, line, len);
@@ -66,7 +66,7 @@ static int __init cifs_root_setup(char *line)
					 sizeof(root_opts), "%s,%s",
					 DEFAULT_MNT_OPTS, s + 1);
			if (n >= sizeof(root_opts)) {
				printk(KERN_ERR "Root-CIFS: mount options string too long\n");
				pr_err("Root-CIFS: mount options string too long\n");
				root_opts[sizeof(root_opts)-1] = '\0';
				return 1;
			}
@@ -83,7 +83,7 @@ __setup("cifsroot=", cifs_root_setup);
int __init cifs_root_data(char **dev, char **opts)
{
	if (!root_dev[0] || root_server_addr == htonl(INADDR_NONE)) {
		printk(KERN_ERR "Root-CIFS: no SMB server address\n");
		pr_err("Root-CIFS: no SMB server address\n");
		return -1;
	}

+12 −12
Original line number Diff line number Diff line
@@ -281,8 +281,8 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
						      (server->tcpStatus != CifsNeedReconnect),
						      10 * HZ);
		if (rc < 0) {
			cifs_dbg(FYI, "%s: aborting reconnect due to a received"
				 " signal by the process\n", __func__);
			cifs_dbg(FYI, "%s: aborting reconnect due to a received signal by the process\n",
				 __func__);
			return -ERESTARTSYS;
		}

@@ -343,7 +343,7 @@ cifs_reconnect_tcon(struct cifs_tcon *tcon, int smb_command)
	cifs_dbg(FYI, "reconnect tcon rc = %d\n", rc);

	if (rc) {
		printk_once(KERN_WARNING "reconnect tcon failed rc = %d\n", rc);
		pr_warn_once("reconnect tcon failed rc = %d\n", rc);
		goto out;
	}

@@ -576,7 +576,7 @@ cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required)
	/* If server requires signing, does client allow it? */
	if (srv_sign_required) {
		if (!mnt_sign_enabled) {
			cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!");
			cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!\n");
			return -ENOTSUPP;
		}
		server->sign = true;
@@ -585,14 +585,14 @@ cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required)
	/* If client requires signing, does server allow it? */
	if (mnt_sign_required) {
		if (!srv_sign_enabled) {
			cifs_dbg(VFS, "Server does not support signing!");
			cifs_dbg(VFS, "Server does not support signing!\n");
			return -ENOTSUPP;
		}
		server->sign = true;
	}

	if (cifs_rdma_enabled(server) && server->sign)
		cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled");
		cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled\n");

	return 0;
}
@@ -722,7 +722,7 @@ CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses)
	pSMB->hdr.Flags2 |= (SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS);

	if (should_set_ext_sec_flag(ses->sectype)) {
		cifs_dbg(FYI, "Requesting extended security.");
		cifs_dbg(FYI, "Requesting extended security\n");
		pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
	}

@@ -3887,7 +3887,7 @@ GetExtAttrRetry:
			struct file_chattr_info *pfinfo;
			/* BB Do we need a cast or hash here ? */
			if (count != 16) {
				cifs_dbg(FYI, "Illegal size ret in GetExtAttr\n");
				cifs_dbg(FYI, "Invalid size ret in GetExtAttr\n");
				rc = -EIO;
				goto GetExtAttrOut;
			}
@@ -4263,7 +4263,7 @@ QFileInfoRetry:
	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
	if (rc) {
		cifs_dbg(FYI, "Send error in QFileInfo = %d", rc);
		cifs_dbg(FYI, "Send error in QFileInfo = %d\n", rc);
	} else {		/* decode response */
		rc = validate_t2((struct smb_t2_rsp *)pSMBr);

@@ -4430,7 +4430,7 @@ UnixQFileInfoRetry:
	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
	if (rc) {
		cifs_dbg(FYI, "Send error in UnixQFileInfo = %d", rc);
		cifs_dbg(FYI, "Send error in UnixQFileInfo = %d\n", rc);
	} else {		/* decode response */
		rc = validate_t2((struct smb_t2_rsp *)pSMBr);

@@ -4512,7 +4512,7 @@ UnixQPathInfoRetry:
	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
	if (rc) {
		cifs_dbg(FYI, "Send error in UnixQPathInfo = %d", rc);
		cifs_dbg(FYI, "Send error in UnixQPathInfo = %d\n", rc);
	} else {		/* decode response */
		rc = validate_t2((struct smb_t2_rsp *)pSMBr);

@@ -4932,7 +4932,7 @@ GetInodeNumberRetry:
			struct file_internal_info *pfinfo;
			/* BB Do we need a cast or hash here ? */
			if (count < 8) {
				cifs_dbg(FYI, "Illegal size ret in QryIntrnlInf\n");
				cifs_dbg(FYI, "Invalid size ret in QryIntrnlInf\n");
				rc = -EIO;
				goto GetInodeNumOut;
			}
Loading