linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cifs: add new debugging macro cifs_server_dbg
@ 2019-08-28  3:17 Ronnie Sahlberg
  2019-08-28 10:04 ` Aurélien Aptel
  0 siblings, 1 reply; 5+ messages in thread
From: Ronnie Sahlberg @ 2019-08-28  3:17 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French

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.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/cifs_debug.h |  31 ++++++++
 fs/cifs/connect.c    | 194 +++++++++++++++++++++++++--------------------------
 2 files changed, 128 insertions(+), 97 deletions(-)

diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h
index 3d392620a2f4..567af916f103 100644
--- a/fs/cifs/cifs_debug.h
+++ b/fs/cifs/cifs_debug.h
@@ -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__);				\
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 5299effa6f7d..31c4762748f5 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -348,7 +348,7 @@ static int reconn_set_ipaddr(struct TCP_Server_Info *server)
 
 	unc = kmalloc(len, GFP_KERNEL);
 	if (!unc) {
-		cifs_dbg(FYI, "%s: failed to create UNC path\n", __func__);
+		cifs_server_dbg(FYI, "%s: failed to create UNC path\n", __func__);
 		return -ENOMEM;
 	}
 	scnprintf(unc, len, "\\\\%s", server->hostname);
@@ -429,7 +429,7 @@ static void reconn_inval_dfs_target(struct TCP_Server_Info *server,
 			*tgt_it = dfs_cache_get_tgt_iterator(tgt_list);
 	}
 
-	cifs_dbg(FYI, "%s: UNC: %s\n", __func__, cifs_sb->origin_fullpath);
+	cifs_server_dbg(FYI, "%s: UNC: %s\n", __func__, cifs_sb->origin_fullpath);
 
 	name = dfs_cache_get_tgt_name(*tgt_it);
 
@@ -437,7 +437,7 @@ static void reconn_inval_dfs_target(struct TCP_Server_Info *server,
 
 	server->hostname = extract_hostname(name);
 	if (IS_ERR(server->hostname)) {
-		cifs_dbg(FYI,
+		cifs_server_dbg(FYI,
 			 "%s: failed to extract hostname from target: %ld\n",
 			 __func__, PTR_ERR(server->hostname));
 	}
@@ -483,19 +483,19 @@ cifs_reconnect(struct TCP_Server_Info *server)
 	cifs_sb = find_super_by_tcp(server);
 	if (IS_ERR(cifs_sb)) {
 		rc = PTR_ERR(cifs_sb);
-		cifs_dbg(FYI, "%s: will not do DFS failover: rc = %d\n",
+		cifs_server_dbg(FYI, "%s: will not do DFS failover: rc = %d\n",
 			 __func__, rc);
 		cifs_sb = NULL;
 	} else {
 		rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list, &tgt_it);
 		if (rc && (rc != -EOPNOTSUPP)) {
-			cifs_dbg(VFS, "%s: no target servers for DFS failover\n",
+			cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n",
 				 __func__);
 		} else {
 			server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list);
 		}
 	}
-	cifs_dbg(FYI, "%s: will retry %d target(s)\n", __func__,
+	cifs_server_dbg(FYI, "%s: will retry %d target(s)\n", __func__,
 		 server->nr_targets);
 	spin_lock(&GlobalMid_Lock);
 #endif
@@ -504,18 +504,17 @@ cifs_reconnect(struct TCP_Server_Info *server)
 		next time through the loop */
 		spin_unlock(&GlobalMid_Lock);
 		return rc;
-	} else
-		server->tcpStatus = CifsNeedReconnect;
+	} else		server->tcpStatus = CifsNeedReconnect;
 	spin_unlock(&GlobalMid_Lock);
 	server->maxBuf = 0;
 	server->max_read = 0;
 
-	cifs_dbg(FYI, "Mark tcp session as need reconnect\n");
+	cifs_server_dbg(FYI, "Mark tcp session as need reconnect\n");
 	trace_smb3_reconnect(server->CurrentMid, server->hostname);
 
 	/* before reconnecting the tcp session, mark the smb session (uid)
 		and the tid bad so they are not used until reconnected */
-	cifs_dbg(FYI, "%s: marking sessions and tcons for reconnect\n",
+	cifs_server_dbg(FYI, "%s: marking sessions and tcons for reconnect\n",
 		 __func__);
 	spin_lock(&cifs_tcp_ses_lock);
 	list_for_each(tmp, &server->smb_ses_list) {
@@ -531,13 +530,13 @@ cifs_reconnect(struct TCP_Server_Info *server)
 	spin_unlock(&cifs_tcp_ses_lock);
 
 	/* do not want to be sending data on a socket we are freeing */
-	cifs_dbg(FYI, "%s: tearing down socket\n", __func__);
+	cifs_server_dbg(FYI, "%s: tearing down socket\n", __func__);
 	mutex_lock(&server->srv_mutex);
 	if (server->ssocket) {
-		cifs_dbg(FYI, "State: 0x%x Flags: 0x%lx\n",
+		cifs_server_dbg(FYI, "State: 0x%x Flags: 0x%lx\n",
 			 server->ssocket->state, server->ssocket->flags);
 		kernel_sock_shutdown(server->ssocket, SHUT_WR);
-		cifs_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n",
+		cifs_server_dbg(FYI, "Post shutdown state: 0x%x Flags: 0x%lx\n",
 			 server->ssocket->state, server->ssocket->flags);
 		sock_release(server->ssocket);
 		server->ssocket = NULL;
@@ -551,7 +550,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
 
 	/* mark submitted MIDs for retry and issue callback */
 	INIT_LIST_HEAD(&retry_list);
-	cifs_dbg(FYI, "%s: moving mids to private list\n", __func__);
+	cifs_server_dbg(FYI, "%s: moving mids to private list\n", __func__);
 	spin_lock(&GlobalMid_Lock);
 	list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
 		mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
@@ -562,7 +561,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
 	spin_unlock(&GlobalMid_Lock);
 	mutex_unlock(&server->srv_mutex);
 
-	cifs_dbg(FYI, "%s: issuing mid callbacks\n", __func__);
+	cifs_server_dbg(FYI, "%s: issuing mid callbacks\n", __func__);
 	list_for_each_safe(tmp, tmp2, &retry_list) {
 		mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
 		list_del_init(&mid_entry->qhead);
@@ -589,14 +588,14 @@ cifs_reconnect(struct TCP_Server_Info *server)
 		else
 			rc = generic_ip_connect(server);
 		if (rc) {
-			cifs_dbg(FYI, "reconnect error %d\n", rc);
+			cifs_server_dbg(FYI, "reconnect error %d\n", rc);
 #ifdef CONFIG_CIFS_DFS_UPCALL
 			reconn_inval_dfs_target(server, cifs_sb, &tgt_list,
 						&tgt_it);
 #endif
 			rc = reconn_set_ipaddr(server);
 			if (rc) {
-				cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n",
+				cifs_server_dbg(FYI, "%s: failed to resolve hostname: %d\n",
 					 __func__, rc);
 			}
 			mutex_unlock(&server->srv_mutex);
@@ -617,12 +616,12 @@ cifs_reconnect(struct TCP_Server_Info *server)
 		rc = dfs_cache_noreq_update_tgthint(cifs_sb->origin_fullpath + 1,
 						    tgt_it);
 		if (rc) {
-			cifs_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
+			cifs_server_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
 				 __func__, rc);
 		}
 		rc = dfs_cache_update_vol(cifs_sb->origin_fullpath, server);
 		if (rc) {
-			cifs_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
+			cifs_server_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
 				 __func__, rc);
 		}
 		dfs_cache_free_tgts(&tgt_list);
@@ -665,8 +664,7 @@ cifs_echo_request(struct work_struct *work)
 
 	rc = server->ops->echo ? server->ops->echo(server) : -ENOSYS;
 	if (rc)
-		cifs_dbg(FYI, "Unable to send echo request to server: %s\n",
-			 server->hostname);
+		cifs_server_dbg(FYI, "Unable to send echo request to server.\n");
 
 requeue_echo:
 	queue_delayed_work(cifsiod_wq, &server->echo, server->echo_interval);
@@ -678,7 +676,7 @@ allocate_buffers(struct TCP_Server_Info *server)
 	if (!server->bigbuf) {
 		server->bigbuf = (char *)cifs_buf_get();
 		if (!server->bigbuf) {
-			cifs_dbg(VFS, "No memory for large SMB response\n");
+			cifs_server_dbg(VFS, "No memory for large SMB response\n");
 			msleep(3000);
 			/* retry will check if exiting */
 			return false;
@@ -691,7 +689,7 @@ allocate_buffers(struct TCP_Server_Info *server)
 	if (!server->smallbuf) {
 		server->smallbuf = (char *)cifs_small_buf_get();
 		if (!server->smallbuf) {
-			cifs_dbg(VFS, "No memory for SMB response\n");
+			cifs_server_dbg(VFS, "No memory for SMB response\n");
 			msleep(1000);
 			/* retry will check if exiting */
 			return false;
@@ -722,8 +720,8 @@ server_unresponsive(struct TCP_Server_Info *server)
 	if ((server->tcpStatus == CifsGood ||
 	    server->tcpStatus == CifsNeedNegotiate) &&
 	    time_after(jiffies, server->lstrp + 3 * server->echo_interval)) {
-		cifs_dbg(VFS, "Server %s has not responded in %lu seconds. Reconnecting...\n",
-			 server->hostname, (3 * server->echo_interval) / HZ);
+		cifs_server_dbg(VFS, "has not responded in %lu seconds. Reconnecting...\n",
+			 (3 * server->echo_interval) / HZ);
 		cifs_reconnect(server);
 		wake_up(&server->response_q);
 		return true;
@@ -794,7 +792,7 @@ cifs_readv_from_socket(struct TCP_Server_Info *server, struct msghdr *smb_msg)
 		}
 
 		if (length <= 0) {
-			cifs_dbg(FYI, "Received no data or error: %d\n", length);
+			cifs_server_dbg(FYI, "Received no data or error: %d\n", length);
 			cifs_reconnect(server);
 			return -ECONNABORTED;
 		}
@@ -837,17 +835,17 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type)
 		/* Regular SMB response */
 		return true;
 	case RFC1002_SESSION_KEEP_ALIVE:
-		cifs_dbg(FYI, "RFC 1002 session keep alive\n");
+		cifs_server_dbg(FYI, "RFC 1002 session keep alive\n");
 		break;
 	case RFC1002_POSITIVE_SESSION_RESPONSE:
-		cifs_dbg(FYI, "RFC 1002 positive session response\n");
+		cifs_server_dbg(FYI, "RFC 1002 positive session response\n");
 		break;
 	case RFC1002_NEGATIVE_SESSION_RESPONSE:
 		/*
 		 * We get this from Windows 98 instead of an error on
 		 * SMB negprot response.
 		 */
-		cifs_dbg(FYI, "RFC 1002 negative session response\n");
+		cifs_server_dbg(FYI, "RFC 1002 negative session response\n");
 		/* give server a second to clean up */
 		msleep(1000);
 		/*
@@ -861,7 +859,7 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type)
 		wake_up(&server->response_q);
 		break;
 	default:
-		cifs_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
+		cifs_server_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
 		cifs_reconnect(server);
 	}
 
@@ -956,7 +954,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
 		spin_lock(&GlobalMid_Lock);
 		list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
 			mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
-			cifs_dbg(FYI, "Clearing mid 0x%llx\n", mid_entry->mid);
+			cifs_server_dbg(FYI, "Clearing mid 0x%llx\n", mid_entry->mid);
 			mid_entry->mid_state = MID_SHUTDOWN;
 			list_move(&mid_entry->qhead, &dispose_list);
 		}
@@ -965,7 +963,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
 		/* now walk dispose list and issue callbacks */
 		list_for_each_safe(tmp, tmp2, &dispose_list) {
 			mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
-			cifs_dbg(FYI, "Callback mid 0x%llx\n", mid_entry->mid);
+			cifs_server_dbg(FYI, "Callback mid 0x%llx\n", mid_entry->mid);
 			list_del_init(&mid_entry->qhead);
 			mid_entry->callback(mid_entry);
 		}
@@ -982,7 +980,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
 		 * least 45 seconds before giving up on a request getting a
 		 * response and going ahead and killing cifsd.
 		 */
-		cifs_dbg(FYI, "Wait for exit from demultiplex thread\n");
+		cifs_server_dbg(FYI, "Wait for exit from demultiplex thread\n");
 		msleep(46000);
 		/*
 		 * If threads still have not exited they are probably never
@@ -1008,7 +1006,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
 	/* make sure this will fit in a large buffer */
 	if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
 		server->vals->header_preamble_size) {
-		cifs_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
+		cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
 		cifs_reconnect(server);
 		wake_up(&server->response_q);
 		return -ECONNABORTED;
@@ -1106,7 +1104,7 @@ cifs_demultiplex_thread(void *p)
 	char *bufs[MAX_COMPOUND];
 
 	current->flags |= PF_MEMALLOC;
-	cifs_dbg(FYI, "Demultiplex PID: %d\n", task_pid_nr(current));
+	cifs_server_dbg(FYI, "Demultiplex PID: %d\n", task_pid_nr(current));
 
 	length = atomic_inc_return(&tcpSesAllocCount);
 	if (length > 1)
@@ -1140,7 +1138,7 @@ cifs_demultiplex_thread(void *p)
 		 */
 		pdu_length = get_rfc1002_length(buf);
 
-		cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length);
+		cifs_server_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length);
 		if (!is_smb_response(server, buf[0]))
 			continue;
 next_pdu:
@@ -1149,7 +1147,7 @@ cifs_demultiplex_thread(void *p)
 		/* make sure we have enough to get to the MID */
 		if (server->pdu_size < HEADER_SIZE(server) - 1 -
 		    server->vals->header_preamble_size) {
-			cifs_dbg(VFS, "SMB response too short (%u bytes)\n",
+			cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n",
 				 server->pdu_size);
 			cifs_reconnect(server);
 			wake_up(&server->response_q);
@@ -1220,9 +1218,9 @@ cifs_demultiplex_thread(void *p)
 				   server->ops->is_oplock_break(bufs[i],
 								server)) {
 				smb2_add_credits_from_hdr(bufs[i], server);
-				cifs_dbg(FYI, "Received oplock break\n");
+				cifs_server_dbg(FYI, "Received oplock break\n");
 			} else {
-				cifs_dbg(VFS, "No task to wake, unknown frame "
+				cifs_server_dbg(VFS, "No task to wake, unknown frame "
 					 "received! NumMids %d\n",
 					 atomic_read(&midCount));
 				cifs_dump_mem("Received Data is: ", bufs[i],
@@ -2601,7 +2599,7 @@ cifs_find_tcp_session(struct smb_vol *vol)
 
 		++server->srv_count;
 		spin_unlock(&cifs_tcp_ses_lock);
-		cifs_dbg(FYI, "Existing tcp session with server found\n");
+		cifs_server_dbg(FYI, "Existing tcp session with server found\n");
 		return server;
 	}
 	spin_unlock(&cifs_tcp_ses_lock);
@@ -2837,6 +2835,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
 {
 	int rc = 0, xid;
 	struct cifs_tcon *tcon;
+	struct TCP_Server_Info *server = ses->server;
 	struct nls_table *nls_codepage;
 	char unc[SERVER_NAME_LENGTH + sizeof("//x/IPC$")] = {0};
 	bool seal = false;
@@ -2849,7 +2848,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
 		if (ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
 			seal = true;
 		else {
-			cifs_dbg(VFS,
+			cifs_server_dbg(VFS,
 				 "IPC: server doesn't support encryption\n");
 			return -EOPNOTSUPP;
 		}
@@ -2872,12 +2871,12 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
 	free_xid(xid);
 
 	if (rc) {
-		cifs_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
+		cifs_server_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
 		tconInfoFree(tcon);
 		goto out;
 	}
 
-	cifs_dbg(FYI, "IPC tcon rc = %d ipc tid = %d\n", rc, tcon->tid);
+	cifs_server_dbg(FYI, "IPC tcon rc = %d ipc tid = %d\n", rc, tcon->tid);
 
 	ses->tcon_ipc = tcon;
 out:
@@ -2895,6 +2894,7 @@ cifs_free_ipc(struct cifs_ses *ses)
 {
 	int rc = 0, xid;
 	struct cifs_tcon *tcon = ses->tcon_ipc;
+	struct TCP_Server_Info *server = ses->server;
 
 	if (tcon == NULL)
 		return 0;
@@ -2906,7 +2906,7 @@ cifs_free_ipc(struct cifs_ses *ses)
 	}
 
 	if (rc)
-		cifs_dbg(FYI, "failed to disconnect IPC tcon (rc=%d)\n", rc);
+		cifs_server_dbg(FYI, "failed to disconnect IPC tcon (rc=%d)\n", rc);
 
 	tconInfoFree(tcon);
 	ses->tcon_ipc = NULL;
@@ -2937,7 +2937,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
 	unsigned int rc, xid;
 	struct TCP_Server_Info *server = ses->server;
 
-	cifs_dbg(FYI, "%s: ses_count=%d\n", __func__, ses->ses_count);
+	cifs_server_dbg(FYI, "%s: ses_count=%d\n", __func__, ses->ses_count);
 
 	spin_lock(&cifs_tcp_ses_lock);
 	if (ses->status == CifsExiting) {
@@ -2958,7 +2958,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
 		xid = get_xid();
 		rc = server->ops->logoff(xid, ses);
 		if (rc)
-			cifs_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
+			cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
 				__func__, rc);
 		_free_xid(xid);
 	}
@@ -3006,24 +3006,24 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
 		sprintf(desc, "cifs:a:%pI6c", &sa6->sin6_addr.s6_addr);
 		break;
 	default:
-		cifs_dbg(FYI, "Bad ss_family (%hu)\n",
+		cifs_server_dbg(FYI, "Bad ss_family (%hu)\n",
 			 server->dstaddr.ss_family);
 		rc = -EINVAL;
 		goto out_err;
 	}
 
-	cifs_dbg(FYI, "%s: desc=%s\n", __func__, desc);
+	cifs_server_dbg(FYI, "%s: desc=%s\n", __func__, desc);
 	key = request_key(&key_type_logon, desc, "");
 	if (IS_ERR(key)) {
 		if (!ses->domainName) {
-			cifs_dbg(FYI, "domainName is NULL\n");
+			cifs_server_dbg(FYI, "domainName is NULL\n");
 			rc = PTR_ERR(key);
 			goto out_err;
 		}
 
 		/* didn't work, try to find a domain key */
 		sprintf(desc, "cifs:d:%s", ses->domainName);
-		cifs_dbg(FYI, "%s: desc=%s\n", __func__, desc);
+		cifs_server_dbg(FYI, "%s: desc=%s\n", __func__, desc);
 		key = request_key(&key_type_logon, desc, "");
 		if (IS_ERR(key)) {
 			rc = PTR_ERR(key);
@@ -3042,9 +3042,9 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
 	/* find first : in payload */
 	payload = upayload->data;
 	delim = strnchr(payload, upayload->datalen, ':');
-	cifs_dbg(FYI, "payload=%s\n", payload);
+	cifs_server_dbg(FYI, "payload=%s\n", payload);
 	if (!delim) {
-		cifs_dbg(FYI, "Unable to find ':' in payload (datalen=%d)\n",
+		cifs_server_dbg(FYI, "Unable to find ':' in payload (datalen=%d)\n",
 			 upayload->datalen);
 		rc = -EINVAL;
 		goto out_key_put;
@@ -3052,7 +3052,7 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
 
 	len = delim - payload;
 	if (len > CIFS_MAX_USERNAME_LEN || len <= 0) {
-		cifs_dbg(FYI, "Bad value from username search (len=%zd)\n",
+		cifs_server_dbg(FYI, "Bad value from username search (len=%zd)\n",
 			 len);
 		rc = -EINVAL;
 		goto out_key_put;
@@ -3060,16 +3060,16 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
 
 	vol->username = kstrndup(payload, len, GFP_KERNEL);
 	if (!vol->username) {
-		cifs_dbg(FYI, "Unable to allocate %zd bytes for username\n",
+		cifs_server_dbg(FYI, "Unable to allocate %zd bytes for username\n",
 			 len);
 		rc = -ENOMEM;
 		goto out_key_put;
 	}
-	cifs_dbg(FYI, "%s: username=%s\n", __func__, vol->username);
+	cifs_server_dbg(FYI, "%s: username=%s\n", __func__, vol->username);
 
 	len = key->datalen - (len + 1);
 	if (len > CIFS_MAX_PASSWORD_LEN || len <= 0) {
-		cifs_dbg(FYI, "Bad len for password search (len=%zd)\n", len);
+		cifs_server_dbg(FYI, "Bad len for password search (len=%zd)\n", len);
 		rc = -EINVAL;
 		kfree(vol->username);
 		vol->username = NULL;
@@ -3079,7 +3079,7 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
 	++delim;
 	vol->password = kstrndup(delim, len, GFP_KERNEL);
 	if (!vol->password) {
-		cifs_dbg(FYI, "Unable to allocate %zd bytes for password\n",
+		cifs_server_dbg(FYI, "Unable to allocate %zd bytes for password\n",
 			 len);
 		rc = -ENOMEM;
 		kfree(vol->username);
@@ -3096,7 +3096,7 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
 					   strlen(ses->domainName),
 					   GFP_KERNEL);
 		if (!vol->domainname) {
-			cifs_dbg(FYI, "Unable to allocate %zd bytes for "
+			cifs_server_dbg(FYI, "Unable to allocate %zd bytes for "
 				 "domain\n", len);
 			rc = -ENOMEM;
 			kfree(vol->username);
@@ -3112,7 +3112,7 @@ cifs_set_cifscreds(struct smb_vol *vol, struct cifs_ses *ses)
 	key_put(key);
 out_err:
 	kfree(desc);
-	cifs_dbg(FYI, "%s: returning %d\n", __func__, rc);
+	cifs_server_dbg(FYI, "%s: returning %d\n", __func__, rc);
 	return rc;
 }
 #else /* ! CONFIG_KEYS */
@@ -3144,7 +3144,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
 
 	ses = cifs_find_smb_ses(server, volume_info);
 	if (ses) {
-		cifs_dbg(FYI, "Existing smb sess found (status=%d)\n",
+		cifs_server_dbg(FYI, "Existing smb sess found (status=%d)\n",
 			 ses->status);
 
 		mutex_lock(&ses->session_mutex);
@@ -3157,7 +3157,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
 			return ERR_PTR(rc);
 		}
 		if (ses->need_reconnect) {
-			cifs_dbg(FYI, "Session needs reconnect\n");
+			cifs_server_dbg(FYI, "Session needs reconnect\n");
 			rc = cifs_setup_session(xid, ses,
 						volume_info->local_nls);
 			if (rc) {
@@ -3176,7 +3176,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info)
 		return ses;
 	}
 
-	cifs_dbg(FYI, "Existing smb sess not found\n");
+	cifs_server_dbg(FYI, "Existing smb sess not found\n");
 	ses = sesInfoAlloc();
 	if (ses == NULL)
 		goto get_ses_fail;
@@ -3331,6 +3331,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
 {
 	int rc, xid;
 	struct cifs_tcon *tcon;
+	struct TCP_Server_Info *server = ses->server;
 
 	tcon = cifs_find_tcon(ses, volume_info);
 	if (tcon) {
@@ -3338,7 +3339,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
 		 * tcon has refcount already incremented but we need to
 		 * decrement extra ses reference gotten by caller (case b)
 		 */
-		cifs_dbg(FYI, "Found match on UNC path\n");
+		cifs_server_dbg(FYI, "Found match on UNC path\n");
 		cifs_put_smb_ses(ses);
 		return tcon;
 	}
@@ -3355,8 +3356,8 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
 	}
 
 	if (volume_info->snapshot_time) {
-		if (ses->server->vals->protocol_id == 0) {
-			cifs_dbg(VFS,
+		if (server->vals->protocol_id == 0) {
+			cifs_server_dbg(VFS,
 			     "Use SMB2 or later for snapshot mount option\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
@@ -3365,8 +3366,8 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
 	}
 
 	if (volume_info->handle_timeout) {
-		if (ses->server->vals->protocol_id == 0) {
-			cifs_dbg(VFS,
+		if (server->vals->protocol_id == 0) {
+			cifs_server_dbg(VFS,
 			     "Use SMB2.1 or later for handle timeout option\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
@@ -3384,28 +3385,27 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
 	}
 
 	if (volume_info->seal) {
-		if (ses->server->vals->protocol_id == 0) {
-			cifs_dbg(VFS,
+		if (server->vals->protocol_id == 0) {
+			cifs_server_dbg(VFS,
 				 "SMB3 or later required for encryption\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
-		} else if (tcon->ses->server->capabilities &
-					SMB2_GLOBAL_CAP_ENCRYPTION)
+		} else if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
 			tcon->seal = true;
 		else {
-			cifs_dbg(VFS, "Encryption is not supported on share\n");
+			cifs_server_dbg(VFS, "Encryption is not supported on share\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
 		}
 	}
 
 	if (volume_info->linux_ext) {
-		if (ses->server->posix_ext_supported) {
+		if (server->posix_ext_supported) {
 			tcon->posix_extensions = true;
 			printk_once(KERN_WARNING
 				"SMB3.11 POSIX Extensions are experimental\n");
 		} else {
-			cifs_dbg(VFS, "Server does not support mounting with posix SMB3.11 extensions.\n");
+			cifs_server_dbg(VFS, "does not support mounting with posix SMB3.11 extensions.\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
 		}
@@ -3416,38 +3416,38 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
 	 * SetFS as we do on SessSetup and reconnect?
 	 */
 	xid = get_xid();
-	rc = ses->server->ops->tree_connect(xid, ses, volume_info->UNC, tcon,
+	rc = server->ops->tree_connect(xid, ses, volume_info->UNC, tcon,
 					    volume_info->local_nls);
 	free_xid(xid);
-	cifs_dbg(FYI, "Tcon rc = %d\n", rc);
+	cifs_server_dbg(FYI, "Tcon rc = %d\n", rc);
 	if (rc)
 		goto out_fail;
 
 	tcon->use_persistent = false;
 	/* check if SMB2 or later, CIFS does not support persistent handles */
 	if (volume_info->persistent) {
-		if (ses->server->vals->protocol_id == 0) {
-			cifs_dbg(VFS,
+		if (server->vals->protocol_id == 0) {
+			cifs_server_dbg(VFS,
 			     "SMB3 or later required for persistent handles\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
-		} else if (ses->server->capabilities &
+		} else if (server->capabilities &
 			   SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
 			tcon->use_persistent = true;
 		else /* persistent handles requested but not supported */ {
-			cifs_dbg(VFS,
+			cifs_server_dbg(VFS,
 				"Persistent handles not supported on share\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
 		}
 	} else if ((tcon->capabilities & SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY)
-	     && (ses->server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
+	     && (server->capabilities & SMB2_GLOBAL_CAP_PERSISTENT_HANDLES)
 	     && (volume_info->nopersistent == false)) {
-		cifs_dbg(FYI, "enabling persistent handles\n");
+		cifs_server_dbg(FYI, "enabling persistent handles\n");
 		tcon->use_persistent = true;
 	} else if (volume_info->resilient) {
-		if (ses->server->vals->protocol_id == 0) {
-			cifs_dbg(VFS,
+		if (server->vals->protocol_id == 0) {
+			cifs_server_dbg(VFS,
 			     "SMB2.1 or later required for resilient handles\n");
 			rc = -EOPNOTSUPP;
 			goto out_fail;
@@ -3659,10 +3659,10 @@ bind_socket(struct TCP_Server_Info *server)
 			saddr4 = (struct sockaddr_in *)&server->srcaddr;
 			saddr6 = (struct sockaddr_in6 *)&server->srcaddr;
 			if (saddr6->sin6_family == AF_INET6)
-				cifs_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
+				cifs_server_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
 					 &saddr6->sin6_addr, rc);
 			else
-				cifs_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
+				cifs_server_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
 					 &saddr4->sin_addr.s_addr, rc);
 		}
 	}
@@ -3766,13 +3766,13 @@ generic_ip_connect(struct TCP_Server_Info *server)
 		rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
 				   IPPROTO_TCP, &socket, 1);
 		if (rc < 0) {
-			cifs_dbg(VFS, "Error %d creating socket\n", rc);
+			cifs_server_dbg(VFS, "Error %d creating socket\n", rc);
 			server->ssocket = NULL;
 			return rc;
 		}
 
 		/* BB other socket options to set KEEPALIVE, NODELAY? */
-		cifs_dbg(FYI, "Socket created\n");
+		cifs_server_dbg(FYI, "Socket created\n");
 		server->ssocket = socket;
 		socket->sk->sk_allocation = GFP_NOFS;
 		if (sfamily == AF_INET6)
@@ -3806,17 +3806,17 @@ generic_ip_connect(struct TCP_Server_Info *server)
 		rc = kernel_setsockopt(socket, SOL_TCP, TCP_NODELAY,
 				(char *)&val, sizeof(val));
 		if (rc)
-			cifs_dbg(FYI, "set TCP_NODELAY socket option error %d\n",
+			cifs_server_dbg(FYI, "set TCP_NODELAY socket option error %d\n",
 				 rc);
 	}
 
-	cifs_dbg(FYI, "sndbuf %d rcvbuf %d rcvtimeo 0x%lx\n",
+	cifs_server_dbg(FYI, "sndbuf %d rcvbuf %d rcvtimeo 0x%lx\n",
 		 socket->sk->sk_sndbuf,
 		 socket->sk->sk_rcvbuf, socket->sk->sk_rcvtimeo);
 
 	rc = socket->ops->connect(socket, saddr, slen, 0);
 	if (rc < 0) {
-		cifs_dbg(FYI, "Error %d connecting to server\n", rc);
+		cifs_server_dbg(FYI, "Error %d connecting to server\n", rc);
 		sock_release(socket);
 		server->ssocket = NULL;
 		return rc;
@@ -4150,7 +4150,7 @@ static int mount_get_conns(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
 
 	if ((vol->persistent == true) && (!(ses->server->capabilities &
 					    SMB2_GLOBAL_CAP_PERSISTENT_HANDLES))) {
-		cifs_dbg(VFS, "persistent handles not supported by server\n");
+		cifs_server_dbg(VFS, "persistent handles not supported by server\n");
 		return -EOPNOTSUPP;
 	}
 
@@ -4575,7 +4575,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
 	if (full_path == NULL)
 		return -ENOMEM;
 
-	cifs_dbg(FYI, "%s: full_path: %s\n", __func__, full_path);
+	cifs_server_dbg(FYI, "%s: full_path: %s\n", __func__, full_path);
 
 	rc = server->ops->is_path_accessible(xid, tcon, cifs_sb,
 					     full_path);
@@ -4588,7 +4588,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
 		rc = cifs_are_all_path_components_accessible(server, xid, tcon,
 			cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);
 		if (rc != 0) {
-			cifs_dbg(VFS, "cannot query dirs between root and final path, "
+			cifs_server_dbg(VFS, "cannot query dirs between root and final path, "
 				 "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
 			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH;
 			rc = 0;
@@ -5075,11 +5075,11 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
 	if (linuxExtEnabled == 0)
 		ses->capabilities &= (~server->vals->cap_unix);
 
-	cifs_dbg(FYI, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n",
+	cifs_server_dbg(FYI, "Security Mode: 0x%x Capabilities: 0x%x TimeAdjust: %d\n",
 		 server->sec_mode, server->capabilities, server->timeAdj);
 
 	if (ses->auth_key.response) {
-		cifs_dbg(FYI, "Free previous auth_key.response = %p\n",
+		cifs_server_dbg(FYI, "Free previous auth_key.response = %p\n",
 			 ses->auth_key.response);
 		kfree(ses->auth_key.response);
 		ses->auth_key.response = NULL;
@@ -5090,7 +5090,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
 		rc = server->ops->sess_setup(xid, ses, nls_info);
 
 	if (rc)
-		cifs_dbg(VFS, "Send error in SessSetup = %d\n", rc);
+		cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc);
 
 	return rc;
 }
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] cifs: add new debugging macro cifs_server_dbg
  2019-08-28  3:17 [PATCH] cifs: add new debugging macro cifs_server_dbg Ronnie Sahlberg
@ 2019-08-28 10:04 ` Aurélien Aptel
  2019-08-28 10:13   ` ronnie sahlberg
  0 siblings, 1 reply; 5+ messages in thread
From: Aurélien Aptel @ 2019-08-28 10:04 UTC (permalink / raw)
  To: Ronnie Sahlberg, linux-cifs; +Cc: Steve French

Ronnie Sahlberg <lsahlber@redhat.com> writes:
> 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.

-- 
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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cifs: add new debugging macro cifs_server_dbg
  2019-08-28 10:04 ` Aurélien Aptel
@ 2019-08-28 10:13   ` ronnie sahlberg
  0 siblings, 0 replies; 5+ messages in thread
From: ronnie sahlberg @ 2019-08-28 10:13 UTC (permalink / raw)
  To: Aurélien Aptel; +Cc: Ronnie Sahlberg, linux-cifs, Steve French

On Wed, Aug 28, 2019 at 8:05 PM Aurélien Aptel <aaptel@suse.com> wrote:
>
> Ronnie Sahlberg <lsahlber@redhat.com> writes:
> > 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.

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.


>
> --
> 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)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cifs: add new debugging macro cifs_server_dbg
  2019-08-28  7:15 ` [PATCH] cifs: add new debugging macro cifs_server_dbg Ronnie Sahlberg
@ 2019-08-30  1:47   ` Steve French
  0 siblings, 0 replies; 5+ messages in thread
From: Steve French @ 2019-08-30  1:47 UTC (permalink / raw)
  To: Ronnie Sahlberg; +Cc: linux-cifs

tentatively merged into cifs-2.6.git pending additional reviews but
looked useful in my review

On Wed, Aug 28, 2019 at 2:15 AM Ronnie Sahlberg <lsahlber@redhat.com> wrote:
>
> 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 cifs_dbg(VFS) calls to cifs_server_dbg(VFS)
>
> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
> ---
>  fs/cifs/cifs_debug.h    |  31 +++++++++++++
>  fs/cifs/connect.c       |  47 ++++++++++----------
>  fs/cifs/smb2pdu.c       | 113 ++++++++++++++++++++++++-----------------------
>  fs/cifs/smb2transport.c |  61 ++++++++++++-------------
>  fs/cifs/transport.c     | 115 +++++++++++++++++++++++++-----------------------
>  5 files changed, 204 insertions(+), 163 deletions(-)
>
> diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h
> index 3d392620a2f4..567af916f103 100644
> --- a/fs/cifs/cifs_debug.h
> +++ b/fs/cifs/cifs_debug.h
> @@ -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__);                            \
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 5299effa6f7d..bce9c22d72b4 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -489,7 +489,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
>         } else {
>                 rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list, &tgt_it);
>                 if (rc && (rc != -EOPNOTSUPP)) {
> -                       cifs_dbg(VFS, "%s: no target servers for DFS failover\n",
> +                       cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n",
>                                  __func__);
>                 } else {
>                         server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list);
> @@ -617,12 +617,12 @@ cifs_reconnect(struct TCP_Server_Info *server)
>                 rc = dfs_cache_noreq_update_tgthint(cifs_sb->origin_fullpath + 1,
>                                                     tgt_it);
>                 if (rc) {
> -                       cifs_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
> +                       cifs_server_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
>                                  __func__, rc);
>                 }
>                 rc = dfs_cache_update_vol(cifs_sb->origin_fullpath, server);
>                 if (rc) {
> -                       cifs_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
> +                       cifs_server_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
>                                  __func__, rc);
>                 }
>                 dfs_cache_free_tgts(&tgt_list);
> @@ -678,7 +678,7 @@ allocate_buffers(struct TCP_Server_Info *server)
>         if (!server->bigbuf) {
>                 server->bigbuf = (char *)cifs_buf_get();
>                 if (!server->bigbuf) {
> -                       cifs_dbg(VFS, "No memory for large SMB response\n");
> +                       cifs_server_dbg(VFS, "No memory for large SMB response\n");
>                         msleep(3000);
>                         /* retry will check if exiting */
>                         return false;
> @@ -691,7 +691,7 @@ allocate_buffers(struct TCP_Server_Info *server)
>         if (!server->smallbuf) {
>                 server->smallbuf = (char *)cifs_small_buf_get();
>                 if (!server->smallbuf) {
> -                       cifs_dbg(VFS, "No memory for SMB response\n");
> +                       cifs_server_dbg(VFS, "No memory for SMB response\n");
>                         msleep(1000);
>                         /* retry will check if exiting */
>                         return false;
> @@ -722,8 +722,8 @@ server_unresponsive(struct TCP_Server_Info *server)
>         if ((server->tcpStatus == CifsGood ||
>             server->tcpStatus == CifsNeedNegotiate) &&
>             time_after(jiffies, server->lstrp + 3 * server->echo_interval)) {
> -               cifs_dbg(VFS, "Server %s has not responded in %lu seconds. Reconnecting...\n",
> -                        server->hostname, (3 * server->echo_interval) / HZ);
> +               cifs_server_dbg(VFS, "has not responded in %lu seconds. Reconnecting...\n",
> +                        (3 * server->echo_interval) / HZ);
>                 cifs_reconnect(server);
>                 wake_up(&server->response_q);
>                 return true;
> @@ -861,7 +861,7 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type)
>                 wake_up(&server->response_q);
>                 break;
>         default:
> -               cifs_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
> +               cifs_server_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
>                 cifs_reconnect(server);
>         }
>
> @@ -1008,7 +1008,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
>         /* make sure this will fit in a large buffer */
>         if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
>                 server->vals->header_preamble_size) {
> -               cifs_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
> +               cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
>                 cifs_reconnect(server);
>                 wake_up(&server->response_q);
>                 return -ECONNABORTED;
> @@ -1149,7 +1149,7 @@ cifs_demultiplex_thread(void *p)
>                 /* make sure we have enough to get to the MID */
>                 if (server->pdu_size < HEADER_SIZE(server) - 1 -
>                     server->vals->header_preamble_size) {
> -                       cifs_dbg(VFS, "SMB response too short (%u bytes)\n",
> +                       cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n",
>                                  server->pdu_size);
>                         cifs_reconnect(server);
>                         wake_up(&server->response_q);
> @@ -1222,7 +1222,7 @@ cifs_demultiplex_thread(void *p)
>                                 smb2_add_credits_from_hdr(bufs[i], server);
>                                 cifs_dbg(FYI, "Received oplock break\n");
>                         } else {
> -                               cifs_dbg(VFS, "No task to wake, unknown frame "
> +                               cifs_server_dbg(VFS, "No task to wake, unknown frame "
>                                          "received! NumMids %d\n",
>                                          atomic_read(&midCount));
>                                 cifs_dump_mem("Received Data is: ", bufs[i],
> @@ -2840,16 +2840,17 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
>         struct nls_table *nls_codepage;
>         char unc[SERVER_NAME_LENGTH + sizeof("//x/IPC$")] = {0};
>         bool seal = false;
> +       struct TCP_Server_Info *server = ses->server;
>
>         /*
>          * If the mount request that resulted in the creation of the
>          * session requires encryption, force IPC to be encrypted too.
>          */
>         if (volume_info->seal) {
> -               if (ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
> +               if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
>                         seal = true;
>                 else {
> -                       cifs_dbg(VFS,
> +                       cifs_server_dbg(VFS,
>                                  "IPC: server doesn't support encryption\n");
>                         return -EOPNOTSUPP;
>                 }
> @@ -2859,7 +2860,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
>         if (tcon == NULL)
>                 return -ENOMEM;
>
> -       scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", ses->server->hostname);
> +       scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname);
>
>         /* cannot fail */
>         nls_codepage = load_nls_default();
> @@ -2868,11 +2869,11 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
>         tcon->ses = ses;
>         tcon->ipc = true;
>         tcon->seal = seal;
> -       rc = ses->server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
> +       rc = server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
>         free_xid(xid);
>
>         if (rc) {
> -               cifs_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
> +               cifs_server_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
>                 tconInfoFree(tcon);
>                 goto out;
>         }
> @@ -2958,7 +2959,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
>                 xid = get_xid();
>                 rc = server->ops->logoff(xid, ses);
>                 if (rc)
> -                       cifs_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
> +                       cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
>                                 __func__, rc);
>                 _free_xid(xid);
>         }
> @@ -3659,10 +3660,10 @@ bind_socket(struct TCP_Server_Info *server)
>                         saddr4 = (struct sockaddr_in *)&server->srcaddr;
>                         saddr6 = (struct sockaddr_in6 *)&server->srcaddr;
>                         if (saddr6->sin6_family == AF_INET6)
> -                               cifs_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
> +                               cifs_server_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
>                                          &saddr6->sin6_addr, rc);
>                         else
> -                               cifs_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
> +                               cifs_server_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
>                                          &saddr4->sin_addr.s_addr, rc);
>                 }
>         }
> @@ -3766,7 +3767,7 @@ generic_ip_connect(struct TCP_Server_Info *server)
>                 rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
>                                    IPPROTO_TCP, &socket, 1);
>                 if (rc < 0) {
> -                       cifs_dbg(VFS, "Error %d creating socket\n", rc);
> +                       cifs_server_dbg(VFS, "Error %d creating socket\n", rc);
>                         server->ssocket = NULL;
>                         return rc;
>                 }
> @@ -4150,7 +4151,7 @@ static int mount_get_conns(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
>
>         if ((vol->persistent == true) && (!(ses->server->capabilities &
>                                             SMB2_GLOBAL_CAP_PERSISTENT_HANDLES))) {
> -               cifs_dbg(VFS, "persistent handles not supported by server\n");
> +               cifs_server_dbg(VFS, "persistent handles not supported by server\n");
>                 return -EOPNOTSUPP;
>         }
>
> @@ -4588,7 +4589,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
>                 rc = cifs_are_all_path_components_accessible(server, xid, tcon,
>                         cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);
>                 if (rc != 0) {
> -                       cifs_dbg(VFS, "cannot query dirs between root and final path, "
> +                       cifs_server_dbg(VFS, "cannot query dirs between root and final path, "
>                                  "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
>                         cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH;
>                         rc = 0;
> @@ -5090,7 +5091,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
>                 rc = server->ops->sess_setup(xid, ses, nls_info);
>
>         if (rc)
> -               cifs_dbg(VFS, "Send error in SessSetup = %d\n", rc);
> +               cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc);
>
>         return rc;
>  }
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 31e4a1b0b170..8145ca95d48e 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -543,7 +543,7 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
>
>         if (*total_len > 200) {
>                 /* In case length corrupted don't want to overrun smb buffer */
> -               cifs_dbg(VFS, "Bad frame length assembling neg contexts\n");
> +               cifs_server_dbg(VFS, "Bad frame length assembling neg contexts\n");
>                 return;
>         }
>
> @@ -661,7 +661,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,
>
>         cifs_dbg(FYI, "decoding %d negotiate contexts\n", ctxt_cnt);
>         if (len_of_smb <= offset) {
> -               cifs_dbg(VFS, "Invalid response: negotiate context offset\n");
> +               cifs_server_dbg(VFS, "Invalid response: negotiate context offset\n");
>                 return -EINVAL;
>         }
>
> @@ -693,7 +693,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,
>                 else if (pctx->ContextType == SMB2_POSIX_EXTENSIONS_AVAILABLE)
>                         server->posix_ext_supported = true;
>                 else
> -                       cifs_dbg(VFS, "unknown negcontext of type %d ignored\n",
> +                       cifs_server_dbg(VFS, "unknown negcontext of type %d ignored\n",
>                                 le16_to_cpu(pctx->ContextType));
>
>                 if (rc)
> @@ -818,7 +818,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>                 req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
>                 req->DialectCount = cpu_to_le16(2);
>                 total_len += 4;
> -       } else if (strcmp(ses->server->vals->version_string,
> +       } else if (strcmp(server->vals->version_string,
>                    SMBDEFAULT_VERSION_STRING) == 0) {
>                 req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
>                 req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
> @@ -841,16 +841,16 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>         else
>                 req->SecurityMode = 0;
>
> -       req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);
> +       req->Capabilities = cpu_to_le32(server->vals->req_capabilities);
>
>         /* ClientGUID must be zero for SMB2.02 dialect */
> -       if (ses->server->vals->protocol_id == SMB20_PROT_ID)
> +       if (server->vals->protocol_id == SMB20_PROT_ID)
>                 memset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE);
>         else {
>                 memcpy(req->ClientGUID, server->client_guid,
>                         SMB2_CLIENT_GUID_SIZE);
> -               if ((ses->server->vals->protocol_id == SMB311_PROT_ID) ||
> -                   (strcmp(ses->server->vals->version_string,
> +               if ((server->vals->protocol_id == SMB311_PROT_ID) ||
> +                   (strcmp(server->vals->version_string,
>                      SMBDEFAULT_VERSION_STRING) == 0))
>                         assemble_neg_contexts(req, server, &total_len);
>         }
> @@ -869,42 +869,42 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>          * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);
>          */
>         if (rc == -EOPNOTSUPP) {
> -               cifs_dbg(VFS, "Dialect not supported by server. Consider "
> +               cifs_server_dbg(VFS, "Dialect not supported by server. Consider "
>                         "specifying vers=1.0 or vers=2.0 on mount for accessing"
>                         " older servers\n");
>                 goto neg_exit;
>         } else if (rc != 0)
>                 goto neg_exit;
>
> -       if (strcmp(ses->server->vals->version_string,
> +       if (strcmp(server->vals->version_string,
>                    SMB3ANY_VERSION_STRING) == 0) {
>                 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
> -                       cifs_dbg(VFS,
> +                       cifs_server_dbg(VFS,
>                                 "SMB2 dialect returned but not requested\n");
>                         return -EIO;
>                 } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
> -                       cifs_dbg(VFS,
> +                       cifs_server_dbg(VFS,
>                                 "SMB2.1 dialect returned but not requested\n");
>                         return -EIO;
>                 }
> -       } else if (strcmp(ses->server->vals->version_string,
> +       } else if (strcmp(server->vals->version_string,
>                    SMBDEFAULT_VERSION_STRING) == 0) {
>                 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
> -                       cifs_dbg(VFS,
> +                       cifs_server_dbg(VFS,
>                                 "SMB2 dialect returned but not requested\n");
>                         return -EIO;
>                 } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
>                         /* ops set to 3.0 by default for default so update */
> -                       ses->server->ops = &smb21_operations;
> -                       ses->server->vals = &smb21_values;
> +                       server->ops = &smb21_operations;
> +                       server->vals = &smb21_values;
>                 } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {
> -                       ses->server->ops = &smb311_operations;
> -                       ses->server->vals = &smb311_values;
> +                       server->ops = &smb311_operations;
> +                       server->vals = &smb311_values;
>                 }
>         } else if (le16_to_cpu(rsp->DialectRevision) !=
> -                               ses->server->vals->protocol_id) {
> +                               server->vals->protocol_id) {
>                 /* if requested single dialect ensure returned dialect matched */
> -               cifs_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n",
> +               cifs_server_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n",
>                         le16_to_cpu(rsp->DialectRevision));
>                 return -EIO;
>         }
> @@ -922,7 +922,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>         else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))
>                 cifs_dbg(FYI, "negotiated smb3.1.1 dialect\n");
>         else {
> -               cifs_dbg(VFS, "Illegal dialect returned by server 0x%x\n",
> +               cifs_server_dbg(VFS, "Illegal dialect returned by server 0x%x\n",
>                          le16_to_cpu(rsp->DialectRevision));
>                 rc = -EIO;
>                 goto neg_exit;
> @@ -982,7 +982,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>                         rc = smb311_decode_neg_context(rsp, server,
>                                                        rsp_iov.iov_len);
>                 else
> -                       cifs_dbg(VFS, "Missing expected negotiate contexts\n");
> +                       cifs_server_dbg(VFS, "Missing expected negotiate contexts\n");
>         }
>  neg_exit:
>         free_rsp_buf(resp_buftype, rsp);
> @@ -996,11 +996,12 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>         struct validate_negotiate_info_rsp *pneg_rsp = NULL;
>         u32 rsplen;
>         u32 inbuflen; /* max of 4 dialects */
> +       struct TCP_Server_Info *server = tcon->ses->server;
>
>         cifs_dbg(FYI, "validate negotiate\n");
>
>         /* In SMB3.11 preauth integrity supersedes validate negotiate */
> -       if (tcon->ses->server->dialect == SMB311_PROT_ID)
> +       if (server->dialect == SMB311_PROT_ID)
>                 return 0;
>
>         /*
> @@ -1019,15 +1020,15 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>         }
>
>         if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
> -               cifs_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
> +               cifs_server_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
>
>         pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS);
>         if (!pneg_inbuf)
>                 return -ENOMEM;
>
>         pneg_inbuf->Capabilities =
> -                       cpu_to_le32(tcon->ses->server->vals->req_capabilities);
> -       memcpy(pneg_inbuf->Guid, tcon->ses->server->client_guid,
> +                       cpu_to_le32(server->vals->req_capabilities);
> +       memcpy(pneg_inbuf->Guid, server->client_guid,
>                                         SMB2_CLIENT_GUID_SIZE);
>
>         if (tcon->ses->sign)
> @@ -1040,7 +1041,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>                 pneg_inbuf->SecurityMode = 0;
>
>
> -       if (strcmp(tcon->ses->server->vals->version_string,
> +       if (strcmp(server->vals->version_string,
>                 SMB3ANY_VERSION_STRING) == 0) {
>                 pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
>                 pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
> @@ -1048,7 +1049,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>                 /* structure is big enough for 3 dialects, sending only 2 */
>                 inbuflen = sizeof(*pneg_inbuf) -
>                                 (2 * sizeof(pneg_inbuf->Dialects[0]));
> -       } else if (strcmp(tcon->ses->server->vals->version_string,
> +       } else if (strcmp(server->vals->version_string,
>                 SMBDEFAULT_VERSION_STRING) == 0) {
>                 pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
>                 pneg_inbuf->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
> @@ -1060,7 +1061,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>         } else {
>                 /* otherwise specific dialect was requested */
>                 pneg_inbuf->Dialects[0] =
> -                       cpu_to_le16(tcon->ses->server->vals->protocol_id);
> +                       cpu_to_le16(server->vals->protocol_id);
>                 pneg_inbuf->DialectCount = cpu_to_le16(1);
>                 /* structure is big enough for 3 dialects, sending only 1 */
>                 inbuflen = sizeof(*pneg_inbuf) -
> @@ -1076,18 +1077,18 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>                  * Old Windows versions or Netapp SMB server can return
>                  * not supported error. Client should accept it.
>                  */
> -               cifs_dbg(VFS, "Server does not support validate negotiate\n");
> +               cifs_server_dbg(VFS, "Server does not support validate negotiate\n");
>                 rc = 0;
>                 goto out_free_inbuf;
>         } else if (rc != 0) {
> -               cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
> +               cifs_server_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
>                 rc = -EIO;
>                 goto out_free_inbuf;
>         }
>
>         rc = -EIO;
>         if (rsplen != sizeof(*pneg_rsp)) {
> -               cifs_dbg(VFS, "invalid protocol negotiate response size: %d\n",
> +               cifs_server_dbg(VFS, "invalid protocol negotiate response size: %d\n",
>                          rsplen);
>
>                 /* relax check since Mac returns max bufsize allowed on ioctl */
> @@ -1096,16 +1097,16 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>         }
>
>         /* check validate negotiate info response matches what we got earlier */
> -       if (pneg_rsp->Dialect != cpu_to_le16(tcon->ses->server->dialect))
> +       if (pneg_rsp->Dialect != cpu_to_le16(server->dialect))
>                 goto vneg_out;
>
> -       if (pneg_rsp->SecurityMode != cpu_to_le16(tcon->ses->server->sec_mode))
> +       if (pneg_rsp->SecurityMode != cpu_to_le16(server->sec_mode))
>                 goto vneg_out;
>
>         /* do not validate server guid because not saved at negprot time yet */
>
>         if ((le32_to_cpu(pneg_rsp->Capabilities) | SMB2_NT_FIND |
> -             SMB2_LARGE_FILES) != tcon->ses->server->capabilities)
> +             SMB2_LARGE_FILES) != server->capabilities)
>                 goto vneg_out;
>
>         /* validate negotiate successful */
> @@ -1114,7 +1115,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>         goto out_free_rsp;
>
>  vneg_out:
> -       cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n");
> +       cifs_server_dbg(VFS, "protocol revalidation - security settings mismatch\n");
>  out_free_rsp:
>         kfree(pneg_rsp);
>  out_free_inbuf:
> @@ -1568,7 +1569,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
>                 sess_data->func(sess_data);
>
>         if ((ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) && (ses->sign))
> -               cifs_dbg(VFS, "signing requested but authenticated as guest\n");
> +               cifs_server_dbg(VFS, "signing requested but authenticated as guest\n");
>         rc = sess_data->result;
>  out:
>         kfree(sess_data);
> @@ -1661,10 +1662,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
>         __le16 *unc_path = NULL;
>         int flags = 0;
>         unsigned int total_len;
> +       struct TCP_Server_Info *server = ses->server;
>
>         cifs_dbg(FYI, "TCON\n");
>
> -       if (!(ses->server) || !tree)
> +       if (!server || !tree)
>                 return -EIO;
>
>         unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL);
> @@ -1707,7 +1709,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
>          * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1
>          * (Samba servers don't always set the flag so also check if null user)
>          */
> -       if ((ses->server->dialect == SMB311_PROT_ID) &&
> +       if ((server->dialect == SMB311_PROT_ID) &&
>             !smb3_encryption_required(tcon) &&
>             !(ses->session_flags &
>                     (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) &&
> @@ -1746,7 +1748,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
>                 cifs_dbg(FYI, "connection to printer\n");
>                 break;
>         default:
> -               cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
> +               cifs_server_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
>                 rc = -EOPNOTSUPP;
>                 goto tcon_error_exit;
>         }
> @@ -1761,15 +1763,15 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
>
>         if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) &&
>             ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))
> -               cifs_dbg(VFS, "DFS capability contradicts DFS flag\n");
> +               cifs_server_dbg(VFS, "DFS capability contradicts DFS flag\n");
>
>         if (tcon->seal &&
> -           !(tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
> -               cifs_dbg(VFS, "Encryption is requested but not supported\n");
> +           !(server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
> +               cifs_server_dbg(VFS, "Encryption is requested but not supported\n");
>
>         init_copy_chunk_defaults(tcon);
> -       if (tcon->ses->server->ops->validate_negotiate)
> -               rc = tcon->ses->server->ops->validate_negotiate(xid, tcon);
> +       if (server->ops->validate_negotiate)
> +               rc = server->ops->validate_negotiate(xid, tcon);
>  tcon_exit:
>
>         free_rsp_buf(resp_buftype, rsp);
> @@ -1778,7 +1780,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
>
>  tcon_error_exit:
>         if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) {
> -               cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
> +               cifs_server_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
>         }
>         goto tcon_exit;
>  }
> @@ -2742,6 +2744,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>         int resp_buftype = CIFS_NO_BUFFER;
>         int rc = 0;
>         int flags = 0;
> +       struct TCP_Server_Info *server;
>
>         cifs_dbg(FYI, "SMB2 IOCTL\n");
>
> @@ -2757,7 +2760,8 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>         else
>                 return -EIO;
>
> -       if (!ses || !(ses->server))
> +       server = ses->server;
> +       if (!ses || !(server))
>                 return -EIO;
>
>         if (smb3_encryption_required(tcon))
> @@ -2807,14 +2811,14 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
>         if (*plen == 0)
>                 goto ioctl_exit; /* server returned no data */
>         else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) {
> -               cifs_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen);
> +               cifs_server_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen);
>                 *plen = 0;
>                 rc = -EIO;
>                 goto ioctl_exit;
>         }
>
>         if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) {
> -               cifs_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen,
> +               cifs_server_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen,
>                         le32_to_cpu(rsp->OutputOffset));
>                 *plen = 0;
>                 rc = -EIO;
> @@ -3055,12 +3059,13 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
>         int rc = 0;
>         int resp_buftype = CIFS_NO_BUFFER;
>         struct cifs_ses *ses = tcon->ses;
> +       struct TCP_Server_Info *server = ses->server;
>         int flags = 0;
>         bool allocated = false;
>
>         cifs_dbg(FYI, "Query Info\n");
>
> -       if (!ses || !(ses->server))
> +       if (!ses || !(server))
>                 return -EIO;
>
>         if (smb3_encryption_required(tcon))
> @@ -3098,7 +3103,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
>                 if (!*data) {
>                         *data = kmalloc(*dlen, GFP_KERNEL);
>                         if (!*data) {
> -                               cifs_dbg(VFS,
> +                               cifs_server_dbg(VFS,
>                                         "Error %d allocating memory for acl\n",
>                                         rc);
>                                 *dlen = 0;
> @@ -3468,7 +3473,7 @@ smb2_readv_callback(struct mid_q_entry *mid)
>
>                         rc = smb2_verify_signature(&rqst, server);
>                         if (rc)
> -                               cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
> +                               cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
>                                          rc);
>                 }
>                 /* FIXME: should this be counted toward the initiating task? */
> @@ -4058,7 +4063,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
>                 info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO) - 1;
>                 break;
>         default:
> -               cifs_dbg(VFS, "info level %u isn't supported\n",
> +               cifs_server_dbg(VFS, "info level %u isn't supported\n",
>                          srch_inf->info_level);
>                 rc = -EINVAL;
>                 goto qdir_exit;
> @@ -4149,7 +4154,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
>         else if (resp_buftype == CIFS_SMALL_BUFFER)
>                 srch_inf->smallBuf = true;
>         else
> -               cifs_dbg(VFS, "illegal search buffer type\n");
> +               cifs_server_dbg(VFS, "illegal search buffer type\n");
>
>         trace_smb3_query_dir_done(xid, persistent_fid, tcon->tid,
>                         tcon->ses->Suid, index, srch_inf->entries_in_buffer);
> diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
> index 1ccbcf9c2c3b..b02242eacb55 100644
> --- a/fs/cifs/smb2transport.c
> +++ b/fs/cifs/smb2transport.c
> @@ -176,7 +176,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
>
>         ses = smb2_find_smb_ses(server, shdr->SessionId);
>         if (!ses) {
> -               cifs_dbg(VFS, "%s: Could not find session\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
>                 return 0;
>         }
>
> @@ -185,21 +185,21 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
>
>         rc = smb2_crypto_shash_allocate(server);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: sha256 alloc failed\n", __func__);
> +               cifs_server_dbg(VFS, "%s: sha256 alloc failed\n", __func__);
>                 return rc;
>         }
>
>         rc = crypto_shash_setkey(server->secmech.hmacsha256,
>                                  ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not update with response\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not update with response\n", __func__);
>                 return rc;
>         }
>
>         shash = &server->secmech.sdeschmacsha256->shash;
>         rc = crypto_shash_init(shash);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not init sha256", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not init sha256", __func__);
>                 return rc;
>         }
>
> @@ -215,7 +215,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
>                 rc = crypto_shash_update(shash, iov[0].iov_base,
>                                          iov[0].iov_len);
>                 if (rc) {
> -                       cifs_dbg(VFS, "%s: Could not update with payload\n",
> +                       cifs_server_dbg(VFS, "%s: Could not update with payload\n",
>                                  __func__);
>                         return rc;
>                 }
> @@ -239,68 +239,69 @@ static int generate_key(struct cifs_ses *ses, struct kvec label,
>         int rc = 0;
>         unsigned char prfhash[SMB2_HMACSHA256_SIZE];
>         unsigned char *hashptr = prfhash;
> +       struct TCP_Server_Info *server = ses->server;
>
>         memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE);
>         memset(key, 0x0, key_size);
>
> -       rc = smb3_crypto_shash_allocate(ses->server);
> +       rc = smb3_crypto_shash_allocate(server);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__);
> +               cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_setkey(ses->server->secmech.hmacsha256,
> +       rc = crypto_shash_setkey(server->secmech.hmacsha256,
>                 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not set with session key\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not set with session key\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_init(&ses->server->secmech.sdeschmacsha256->shash);
> +       rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
> +       rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
>                                 i, 4);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not update with n\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not update with n\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
> +       rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
>                                 label.iov_base, label.iov_len);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not update with label\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not update with label\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
> +       rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
>                                 &zero, 1);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not update with zero\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not update with zero\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
> +       rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
>                                 context.iov_base, context.iov_len);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not update with context\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not update with context\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
> +       rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
>                                 L, 4);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not update with L\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not update with L\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> -       rc = crypto_shash_final(&ses->server->secmech.sdeschmacsha256->shash,
> +       rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash,
>                                 hashptr);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
>                 goto smb3signkey_ret;
>         }
>
> @@ -436,7 +437,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
>
>         ses = smb2_find_smb_ses(server, shdr->SessionId);
>         if (!ses) {
> -               cifs_dbg(VFS, "%s: Could not find session\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
>                 return 0;
>         }
>
> @@ -446,7 +447,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
>         rc = crypto_shash_setkey(server->secmech.cmacaes,
>                                  ses->smb3signingkey, SMB2_CMACAES_SIZE);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
>                 return rc;
>         }
>
> @@ -457,7 +458,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
>          */
>         rc = crypto_shash_init(shash);
>         if (rc) {
> -               cifs_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
> +               cifs_server_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
>                 return rc;
>         }
>
> @@ -473,7 +474,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
>                 rc = crypto_shash_update(shash, iov[0].iov_base,
>                                          iov[0].iov_len);
>                 if (rc) {
> -                       cifs_dbg(VFS, "%s: Could not update with payload\n",
> +                       cifs_server_dbg(VFS, "%s: Could not update with payload\n",
>                                  __func__);
>                         return rc;
>                 }
> @@ -665,7 +666,7 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
>
>                 rc = smb2_verify_signature(&rqst, server);
>                 if (rc)
> -                       cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
> +                       cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
>                                  rc);
>         }
>
> @@ -739,7 +740,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server)
>                 else
>                         tfm = crypto_alloc_aead("ccm(aes)", 0, 0);
>                 if (IS_ERR(tfm)) {
> -                       cifs_dbg(VFS, "%s: Failed to alloc encrypt aead\n",
> +                       cifs_server_dbg(VFS, "%s: Failed to alloc encrypt aead\n",
>                                  __func__);
>                         return PTR_ERR(tfm);
>                 }
> @@ -754,7 +755,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server)
>                 if (IS_ERR(tfm)) {
>                         crypto_free_aead(server->secmech.ccmaesencrypt);
>                         server->secmech.ccmaesencrypt = NULL;
> -                       cifs_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
> +                       cifs_server_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
>                                  __func__);
>                         return PTR_ERR(tfm);
>                 }
> diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
> index 5d6d44bfe10a..0d60bd2f4dca 100644
> --- a/fs/cifs/transport.c
> +++ b/fs/cifs/transport.c
> @@ -118,7 +118,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
>  #ifdef CONFIG_CIFS_STATS2
>         now = jiffies;
>         if (now < midEntry->when_alloc)
> -               cifs_dbg(VFS, "invalid mid allocation time\n");
> +               cifs_server_dbg(VFS, "invalid mid allocation time\n");
>         roundtrip_time = now - midEntry->when_alloc;
>
>         if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) {
> @@ -232,7 +232,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
>                         retries++;
>                         if (retries >= 14 ||
>                             (!server->noblocksnd && (retries > 2))) {
> -                               cifs_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
> +                               cifs_server_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
>                                          ssocket);
>                                 return -EAGAIN;
>                         }
> @@ -246,7 +246,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
>                 if (rc == 0) {
>                         /* should never happen, letting socket clear before
>                            retrying is our only obvious option here */
> -                       cifs_dbg(VFS, "tcp sent no data\n");
> +                       cifs_server_dbg(VFS, "tcp sent no data\n");
>                         msleep(500);
>                         continue;
>                 }
> @@ -440,7 +440,7 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
>         }
>  smbd_done:
>         if (rc < 0 && rc != -EINTR)
> -               cifs_dbg(VFS, "Error %d sending data on socket to server\n",
> +               cifs_server_dbg(VFS, "Error %d sending data on socket to server\n",
>                          rc);
>         else if (rc > 0)
>                 rc = 0;
> @@ -473,8 +473,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
>         cur_rqst[0].rq_nvec = 1;
>
>         if (!server->ops->init_transform_rq) {
> -               cifs_dbg(VFS, "Encryption requested but transform callback "
> -                        "is missing\n");
> +               cifs_server_dbg(VFS, "Encryption requested but transform "
> +                               "callback is missing\n");
>                 return -EIO;
>         }
>
> @@ -548,7 +548,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
>                         if (!rc) {
>                                 trace_smb3_credit_timeout(server->CurrentMid,
>                                         server->hostname, num_credits);
> -                               cifs_dbg(VFS, "wait timed out after %d ms\n",
> +                               cifs_server_dbg(VFS, "wait timed out after %d ms\n",
>                                          timeout);
>                                 return -ENOTSUPP;
>                         }
> @@ -589,7 +589,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
>                                         trace_smb3_credit_timeout(
>                                                 server->CurrentMid,
>                                                 server->hostname, num_credits);
> -                                       cifs_dbg(VFS, "wait timed out after %d ms\n",
> +                                       cifs_server_dbg(VFS, "wait timed out after %d ms\n",
>                                                  timeout);
>                                         return -ENOTSUPP;
>                                 }
> @@ -869,7 +869,7 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
>                 break;
>         default:
>                 list_del_init(&mid->qhead);
> -               cifs_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
> +               cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
>                          __func__, mid->mid, mid->mid_state);
>                 rc = -EIO;
>         }
> @@ -910,7 +910,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
>                 rc = cifs_verify_signature(&rqst, server,
>                                            mid->sequence_number);
>                 if (rc)
> -                       cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
> +                       cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
>                                  rc);
>         }
>
> @@ -1107,7 +1107,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
>         }
>         if (rc != 0) {
>                 for (; i < num_rqst; i++) {
> -                       cifs_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
> +                       cifs_server_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
>                                  midQ[i]->mid, le16_to_cpu(midQ[i]->command));
>                         send_cancel(server, &rqst[i], midQ[i]);
>                         spin_lock(&GlobalMid_Lock);
> @@ -1242,17 +1242,18 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
>         struct kvec iov = { .iov_base = in_buf, .iov_len = len };
>         struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
>         struct cifs_credits credits = { .value = 1, .instance = 0 };
> +       struct TCP_Server_Info *server = ses->server;
>
>         if (ses == NULL) {
>                 cifs_dbg(VFS, "Null smb session\n");
>                 return -EIO;
>         }
> -       if (ses->server == NULL) {
> +       if (server == NULL) {
>                 cifs_dbg(VFS, "Null tcp session\n");
>                 return -EIO;
>         }
>
> -       if (ses->server->tcpStatus == CifsExiting)
> +       if (server->tcpStatus == CifsExiting)
>                 return -ENOENT;
>
>         /* Ensure that we do not send more than 50 overlapping requests
> @@ -1260,12 +1261,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
>            use ses->maxReq */
>
>         if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
> -               cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
> +               cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
>                          len);
>                 return -EIO;
>         }
>
> -       rc = wait_for_free_request(ses->server, flags, &credits.instance);
> +       rc = wait_for_free_request(server, flags, &credits.instance);
>         if (rc)
>                 return rc;
>
> @@ -1273,70 +1274,70 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
>            and avoid races inside tcp sendmsg code that could cause corruption
>            of smb data */
>
> -       mutex_lock(&ses->server->srv_mutex);
> +       mutex_lock(&server->srv_mutex);
>
>         rc = allocate_mid(ses, in_buf, &midQ);
>         if (rc) {
>                 mutex_unlock(&ses->server->srv_mutex);
>                 /* Update # of requests on wire to server */
> -               add_credits(ses->server, &credits, 0);
> +               add_credits(server, &credits, 0);
>                 return rc;
>         }
>
> -       rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
> +       rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
>         if (rc) {
> -               mutex_unlock(&ses->server->srv_mutex);
> +               mutex_unlock(&server->srv_mutex);
>                 goto out;
>         }
>
>         midQ->mid_state = MID_REQUEST_SUBMITTED;
>
> -       cifs_in_send_inc(ses->server);
> -       rc = smb_send(ses->server, in_buf, len);
> -       cifs_in_send_dec(ses->server);
> +       cifs_in_send_inc(server);
> +       rc = smb_send(server, in_buf, len);
> +       cifs_in_send_dec(server);
>         cifs_save_when_sent(midQ);
>
>         if (rc < 0)
> -               ses->server->sequence_number -= 2;
> +               server->sequence_number -= 2;
>
> -       mutex_unlock(&ses->server->srv_mutex);
> +       mutex_unlock(&server->srv_mutex);
>
>         if (rc < 0)
>                 goto out;
>
> -       rc = wait_for_response(ses->server, midQ);
> +       rc = wait_for_response(server, midQ);
>         if (rc != 0) {
> -               send_cancel(ses->server, &rqst, midQ);
> +               send_cancel(server, &rqst, midQ);
>                 spin_lock(&GlobalMid_Lock);
>                 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
>                         /* no longer considered to be "in-flight" */
>                         midQ->callback = DeleteMidQEntry;
>                         spin_unlock(&GlobalMid_Lock);
> -                       add_credits(ses->server, &credits, 0);
> +                       add_credits(server, &credits, 0);
>                         return rc;
>                 }
>                 spin_unlock(&GlobalMid_Lock);
>         }
>
> -       rc = cifs_sync_mid_result(midQ, ses->server);
> +       rc = cifs_sync_mid_result(midQ, server);
>         if (rc != 0) {
> -               add_credits(ses->server, &credits, 0);
> +               add_credits(server, &credits, 0);
>                 return rc;
>         }
>
>         if (!midQ->resp_buf || !out_buf ||
>             midQ->mid_state != MID_RESPONSE_RECEIVED) {
>                 rc = -EIO;
> -               cifs_dbg(VFS, "Bad MID state?\n");
> +               cifs_server_dbg(VFS, "Bad MID state?\n");
>                 goto out;
>         }
>
>         *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
>         memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
> -       rc = cifs_check_receive(midQ, ses->server, 0);
> +       rc = cifs_check_receive(midQ, server, 0);
>  out:
>         cifs_delete_mid(midQ);
> -       add_credits(ses->server, &credits, 0);
> +       add_credits(server, &credits, 0);
>
>         return rc;
>  }
> @@ -1379,19 +1380,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
>         struct kvec iov = { .iov_base = in_buf, .iov_len = len };
>         struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
>         unsigned int instance;
> +       struct TCP_Server_Info *server;
>
>         if (tcon == NULL || tcon->ses == NULL) {
>                 cifs_dbg(VFS, "Null smb session\n");
>                 return -EIO;
>         }
>         ses = tcon->ses;
> +       server = ses->server;
>
> -       if (ses->server == NULL) {
> +       if (server == NULL) {
>                 cifs_dbg(VFS, "Null tcp session\n");
>                 return -EIO;
>         }
>
> -       if (ses->server->tcpStatus == CifsExiting)
> +       if (server->tcpStatus == CifsExiting)
>                 return -ENOENT;
>
>         /* Ensure that we do not send more than 50 overlapping requests
> @@ -1399,12 +1402,12 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
>            use ses->maxReq */
>
>         if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
> -               cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
> +               cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
>                          len);
>                 return -EIO;
>         }
>
> -       rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, &instance);
> +       rc = wait_for_free_request(server, CIFS_BLOCKING_OP, &instance);
>         if (rc)
>                 return rc;
>
> @@ -1412,31 +1415,31 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
>            and avoid races inside tcp sendmsg code that could cause corruption
>            of smb data */
>
> -       mutex_lock(&ses->server->srv_mutex);
> +       mutex_lock(&server->srv_mutex);
>
>         rc = allocate_mid(ses, in_buf, &midQ);
>         if (rc) {
> -               mutex_unlock(&ses->server->srv_mutex);
> +               mutex_unlock(&server->srv_mutex);
>                 return rc;
>         }
>
> -       rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
> +       rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
>         if (rc) {
>                 cifs_delete_mid(midQ);
> -               mutex_unlock(&ses->server->srv_mutex);
> +               mutex_unlock(&server->srv_mutex);
>                 return rc;
>         }
>
>         midQ->mid_state = MID_REQUEST_SUBMITTED;
> -       cifs_in_send_inc(ses->server);
> -       rc = smb_send(ses->server, in_buf, len);
> -       cifs_in_send_dec(ses->server);
> +       cifs_in_send_inc(server);
> +       rc = smb_send(server, in_buf, len);
> +       cifs_in_send_dec(server);
>         cifs_save_when_sent(midQ);
>
>         if (rc < 0)
> -               ses->server->sequence_number -= 2;
> +               server->sequence_number -= 2;
>
> -       mutex_unlock(&ses->server->srv_mutex);
> +       mutex_unlock(&server->srv_mutex);
>
>         if (rc < 0) {
>                 cifs_delete_mid(midQ);
> @@ -1444,21 +1447,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
>         }
>
>         /* Wait for a reply - allow signals to interrupt. */
> -       rc = wait_event_interruptible(ses->server->response_q,
> +       rc = wait_event_interruptible(server->response_q,
>                 (!(midQ->mid_state == MID_REQUEST_SUBMITTED)) ||
> -               ((ses->server->tcpStatus != CifsGood) &&
> -                (ses->server->tcpStatus != CifsNew)));
> +               ((server->tcpStatus != CifsGood) &&
> +                (server->tcpStatus != CifsNew)));
>
>         /* Were we interrupted by a signal ? */
>         if ((rc == -ERESTARTSYS) &&
>                 (midQ->mid_state == MID_REQUEST_SUBMITTED) &&
> -               ((ses->server->tcpStatus == CifsGood) ||
> -                (ses->server->tcpStatus == CifsNew))) {
> +               ((server->tcpStatus == CifsGood) ||
> +                (server->tcpStatus == CifsNew))) {
>
>                 if (in_buf->Command == SMB_COM_TRANSACTION2) {
>                         /* POSIX lock. We send a NT_CANCEL SMB to cause the
>                            blocking lock to return. */
> -                       rc = send_cancel(ses->server, &rqst, midQ);
> +                       rc = send_cancel(server, &rqst, midQ);
>                         if (rc) {
>                                 cifs_delete_mid(midQ);
>                                 return rc;
> @@ -1477,9 +1480,9 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
>                         }
>                 }
>
> -               rc = wait_for_response(ses->server, midQ);
> +               rc = wait_for_response(server, midQ);
>                 if (rc) {
> -                       send_cancel(ses->server, &rqst, midQ);
> +                       send_cancel(server, &rqst, midQ);
>                         spin_lock(&GlobalMid_Lock);
>                         if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
>                                 /* no longer considered to be "in-flight" */
> @@ -1494,20 +1497,20 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
>                 rstart = 1;
>         }
>
> -       rc = cifs_sync_mid_result(midQ, ses->server);
> +       rc = cifs_sync_mid_result(midQ, server);
>         if (rc != 0)
>                 return rc;
>
>         /* rcvd frame is ok */
>         if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) {
>                 rc = -EIO;
> -               cifs_dbg(VFS, "Bad MID state?\n");
> +               cifs_server_dbg(VFS, "Bad MID state?\n");
>                 goto out;
>         }
>
>         *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
>         memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
> -       rc = cifs_check_receive(midQ, ses->server, 0);
> +       rc = cifs_check_receive(midQ, server, 0);
>  out:
>         cifs_delete_mid(midQ);
>         if (rstart && rc == -EACCES)
> --
> 2.13.6
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] cifs: add new debugging macro cifs_server_dbg
  2019-08-28  7:15 [PATCH 0/1] add new debugging macro Ronnie Sahlberg
@ 2019-08-28  7:15 ` Ronnie Sahlberg
  2019-08-30  1:47   ` Steve French
  0 siblings, 1 reply; 5+ messages in thread
From: Ronnie Sahlberg @ 2019-08-28  7:15 UTC (permalink / raw)
  To: linux-cifs; +Cc: Steve French

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 cifs_dbg(VFS) calls to cifs_server_dbg(VFS)

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/cifs_debug.h    |  31 +++++++++++++
 fs/cifs/connect.c       |  47 ++++++++++----------
 fs/cifs/smb2pdu.c       | 113 ++++++++++++++++++++++++-----------------------
 fs/cifs/smb2transport.c |  61 ++++++++++++-------------
 fs/cifs/transport.c     | 115 +++++++++++++++++++++++++-----------------------
 5 files changed, 204 insertions(+), 163 deletions(-)

diff --git a/fs/cifs/cifs_debug.h b/fs/cifs/cifs_debug.h
index 3d392620a2f4..567af916f103 100644
--- a/fs/cifs/cifs_debug.h
+++ b/fs/cifs/cifs_debug.h
@@ -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__);				\
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 5299effa6f7d..bce9c22d72b4 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -489,7 +489,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
 	} else {
 		rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list, &tgt_it);
 		if (rc && (rc != -EOPNOTSUPP)) {
-			cifs_dbg(VFS, "%s: no target servers for DFS failover\n",
+			cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n",
 				 __func__);
 		} else {
 			server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list);
@@ -617,12 +617,12 @@ cifs_reconnect(struct TCP_Server_Info *server)
 		rc = dfs_cache_noreq_update_tgthint(cifs_sb->origin_fullpath + 1,
 						    tgt_it);
 		if (rc) {
-			cifs_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
+			cifs_server_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
 				 __func__, rc);
 		}
 		rc = dfs_cache_update_vol(cifs_sb->origin_fullpath, server);
 		if (rc) {
-			cifs_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
+			cifs_server_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
 				 __func__, rc);
 		}
 		dfs_cache_free_tgts(&tgt_list);
@@ -678,7 +678,7 @@ allocate_buffers(struct TCP_Server_Info *server)
 	if (!server->bigbuf) {
 		server->bigbuf = (char *)cifs_buf_get();
 		if (!server->bigbuf) {
-			cifs_dbg(VFS, "No memory for large SMB response\n");
+			cifs_server_dbg(VFS, "No memory for large SMB response\n");
 			msleep(3000);
 			/* retry will check if exiting */
 			return false;
@@ -691,7 +691,7 @@ allocate_buffers(struct TCP_Server_Info *server)
 	if (!server->smallbuf) {
 		server->smallbuf = (char *)cifs_small_buf_get();
 		if (!server->smallbuf) {
-			cifs_dbg(VFS, "No memory for SMB response\n");
+			cifs_server_dbg(VFS, "No memory for SMB response\n");
 			msleep(1000);
 			/* retry will check if exiting */
 			return false;
@@ -722,8 +722,8 @@ server_unresponsive(struct TCP_Server_Info *server)
 	if ((server->tcpStatus == CifsGood ||
 	    server->tcpStatus == CifsNeedNegotiate) &&
 	    time_after(jiffies, server->lstrp + 3 * server->echo_interval)) {
-		cifs_dbg(VFS, "Server %s has not responded in %lu seconds. Reconnecting...\n",
-			 server->hostname, (3 * server->echo_interval) / HZ);
+		cifs_server_dbg(VFS, "has not responded in %lu seconds. Reconnecting...\n",
+			 (3 * server->echo_interval) / HZ);
 		cifs_reconnect(server);
 		wake_up(&server->response_q);
 		return true;
@@ -861,7 +861,7 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type)
 		wake_up(&server->response_q);
 		break;
 	default:
-		cifs_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
+		cifs_server_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
 		cifs_reconnect(server);
 	}
 
@@ -1008,7 +1008,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid)
 	/* make sure this will fit in a large buffer */
 	if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
 		server->vals->header_preamble_size) {
-		cifs_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
+		cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
 		cifs_reconnect(server);
 		wake_up(&server->response_q);
 		return -ECONNABORTED;
@@ -1149,7 +1149,7 @@ cifs_demultiplex_thread(void *p)
 		/* make sure we have enough to get to the MID */
 		if (server->pdu_size < HEADER_SIZE(server) - 1 -
 		    server->vals->header_preamble_size) {
-			cifs_dbg(VFS, "SMB response too short (%u bytes)\n",
+			cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n",
 				 server->pdu_size);
 			cifs_reconnect(server);
 			wake_up(&server->response_q);
@@ -1222,7 +1222,7 @@ cifs_demultiplex_thread(void *p)
 				smb2_add_credits_from_hdr(bufs[i], server);
 				cifs_dbg(FYI, "Received oplock break\n");
 			} else {
-				cifs_dbg(VFS, "No task to wake, unknown frame "
+				cifs_server_dbg(VFS, "No task to wake, unknown frame "
 					 "received! NumMids %d\n",
 					 atomic_read(&midCount));
 				cifs_dump_mem("Received Data is: ", bufs[i],
@@ -2840,16 +2840,17 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
 	struct nls_table *nls_codepage;
 	char unc[SERVER_NAME_LENGTH + sizeof("//x/IPC$")] = {0};
 	bool seal = false;
+	struct TCP_Server_Info *server = ses->server;
 
 	/*
 	 * If the mount request that resulted in the creation of the
 	 * session requires encryption, force IPC to be encrypted too.
 	 */
 	if (volume_info->seal) {
-		if (ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
+		if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
 			seal = true;
 		else {
-			cifs_dbg(VFS,
+			cifs_server_dbg(VFS,
 				 "IPC: server doesn't support encryption\n");
 			return -EOPNOTSUPP;
 		}
@@ -2859,7 +2860,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
 	if (tcon == NULL)
 		return -ENOMEM;
 
-	scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", ses->server->hostname);
+	scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname);
 
 	/* cannot fail */
 	nls_codepage = load_nls_default();
@@ -2868,11 +2869,11 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info)
 	tcon->ses = ses;
 	tcon->ipc = true;
 	tcon->seal = seal;
-	rc = ses->server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
+	rc = server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
 	free_xid(xid);
 
 	if (rc) {
-		cifs_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
+		cifs_server_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
 		tconInfoFree(tcon);
 		goto out;
 	}
@@ -2958,7 +2959,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
 		xid = get_xid();
 		rc = server->ops->logoff(xid, ses);
 		if (rc)
-			cifs_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
+			cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
 				__func__, rc);
 		_free_xid(xid);
 	}
@@ -3659,10 +3660,10 @@ bind_socket(struct TCP_Server_Info *server)
 			saddr4 = (struct sockaddr_in *)&server->srcaddr;
 			saddr6 = (struct sockaddr_in6 *)&server->srcaddr;
 			if (saddr6->sin6_family == AF_INET6)
-				cifs_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
+				cifs_server_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
 					 &saddr6->sin6_addr, rc);
 			else
-				cifs_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
+				cifs_server_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
 					 &saddr4->sin_addr.s_addr, rc);
 		}
 	}
@@ -3766,7 +3767,7 @@ generic_ip_connect(struct TCP_Server_Info *server)
 		rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
 				   IPPROTO_TCP, &socket, 1);
 		if (rc < 0) {
-			cifs_dbg(VFS, "Error %d creating socket\n", rc);
+			cifs_server_dbg(VFS, "Error %d creating socket\n", rc);
 			server->ssocket = NULL;
 			return rc;
 		}
@@ -4150,7 +4151,7 @@ static int mount_get_conns(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
 
 	if ((vol->persistent == true) && (!(ses->server->capabilities &
 					    SMB2_GLOBAL_CAP_PERSISTENT_HANDLES))) {
-		cifs_dbg(VFS, "persistent handles not supported by server\n");
+		cifs_server_dbg(VFS, "persistent handles not supported by server\n");
 		return -EOPNOTSUPP;
 	}
 
@@ -4588,7 +4589,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol,
 		rc = cifs_are_all_path_components_accessible(server, xid, tcon,
 			cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);
 		if (rc != 0) {
-			cifs_dbg(VFS, "cannot query dirs between root and final path, "
+			cifs_server_dbg(VFS, "cannot query dirs between root and final path, "
 				 "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
 			cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH;
 			rc = 0;
@@ -5090,7 +5091,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
 		rc = server->ops->sess_setup(xid, ses, nls_info);
 
 	if (rc)
-		cifs_dbg(VFS, "Send error in SessSetup = %d\n", rc);
+		cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc);
 
 	return rc;
 }
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 31e4a1b0b170..8145ca95d48e 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -543,7 +543,7 @@ assemble_neg_contexts(struct smb2_negotiate_req *req,
 
 	if (*total_len > 200) {
 		/* In case length corrupted don't want to overrun smb buffer */
-		cifs_dbg(VFS, "Bad frame length assembling neg contexts\n");
+		cifs_server_dbg(VFS, "Bad frame length assembling neg contexts\n");
 		return;
 	}
 
@@ -661,7 +661,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,
 
 	cifs_dbg(FYI, "decoding %d negotiate contexts\n", ctxt_cnt);
 	if (len_of_smb <= offset) {
-		cifs_dbg(VFS, "Invalid response: negotiate context offset\n");
+		cifs_server_dbg(VFS, "Invalid response: negotiate context offset\n");
 		return -EINVAL;
 	}
 
@@ -693,7 +693,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,
 		else if (pctx->ContextType == SMB2_POSIX_EXTENSIONS_AVAILABLE)
 			server->posix_ext_supported = true;
 		else
-			cifs_dbg(VFS, "unknown negcontext of type %d ignored\n",
+			cifs_server_dbg(VFS, "unknown negcontext of type %d ignored\n",
 				le16_to_cpu(pctx->ContextType));
 
 		if (rc)
@@ -818,7 +818,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
 		req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
 		req->DialectCount = cpu_to_le16(2);
 		total_len += 4;
-	} else if (strcmp(ses->server->vals->version_string,
+	} else if (strcmp(server->vals->version_string,
 		   SMBDEFAULT_VERSION_STRING) == 0) {
 		req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
 		req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
@@ -841,16 +841,16 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
 	else
 		req->SecurityMode = 0;
 
-	req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);
+	req->Capabilities = cpu_to_le32(server->vals->req_capabilities);
 
 	/* ClientGUID must be zero for SMB2.02 dialect */
-	if (ses->server->vals->protocol_id == SMB20_PROT_ID)
+	if (server->vals->protocol_id == SMB20_PROT_ID)
 		memset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE);
 	else {
 		memcpy(req->ClientGUID, server->client_guid,
 			SMB2_CLIENT_GUID_SIZE);
-		if ((ses->server->vals->protocol_id == SMB311_PROT_ID) ||
-		    (strcmp(ses->server->vals->version_string,
+		if ((server->vals->protocol_id == SMB311_PROT_ID) ||
+		    (strcmp(server->vals->version_string,
 		     SMBDEFAULT_VERSION_STRING) == 0))
 			assemble_neg_contexts(req, server, &total_len);
 	}
@@ -869,42 +869,42 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
 	 * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);
 	 */
 	if (rc == -EOPNOTSUPP) {
-		cifs_dbg(VFS, "Dialect not supported by server. Consider "
+		cifs_server_dbg(VFS, "Dialect not supported by server. Consider "
 			"specifying vers=1.0 or vers=2.0 on mount for accessing"
 			" older servers\n");
 		goto neg_exit;
 	} else if (rc != 0)
 		goto neg_exit;
 
-	if (strcmp(ses->server->vals->version_string,
+	if (strcmp(server->vals->version_string,
 		   SMB3ANY_VERSION_STRING) == 0) {
 		if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
-			cifs_dbg(VFS,
+			cifs_server_dbg(VFS,
 				"SMB2 dialect returned but not requested\n");
 			return -EIO;
 		} else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
-			cifs_dbg(VFS,
+			cifs_server_dbg(VFS,
 				"SMB2.1 dialect returned but not requested\n");
 			return -EIO;
 		}
-	} else if (strcmp(ses->server->vals->version_string,
+	} else if (strcmp(server->vals->version_string,
 		   SMBDEFAULT_VERSION_STRING) == 0) {
 		if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
-			cifs_dbg(VFS,
+			cifs_server_dbg(VFS,
 				"SMB2 dialect returned but not requested\n");
 			return -EIO;
 		} else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
 			/* ops set to 3.0 by default for default so update */
-			ses->server->ops = &smb21_operations;
-			ses->server->vals = &smb21_values;
+			server->ops = &smb21_operations;
+			server->vals = &smb21_values;
 		} else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {
-			ses->server->ops = &smb311_operations;
-			ses->server->vals = &smb311_values;
+			server->ops = &smb311_operations;
+			server->vals = &smb311_values;
 		}
 	} else if (le16_to_cpu(rsp->DialectRevision) !=
-				ses->server->vals->protocol_id) {
+				server->vals->protocol_id) {
 		/* if requested single dialect ensure returned dialect matched */
-		cifs_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n",
+		cifs_server_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n",
 			le16_to_cpu(rsp->DialectRevision));
 		return -EIO;
 	}
@@ -922,7 +922,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
 	else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))
 		cifs_dbg(FYI, "negotiated smb3.1.1 dialect\n");
 	else {
-		cifs_dbg(VFS, "Illegal dialect returned by server 0x%x\n",
+		cifs_server_dbg(VFS, "Illegal dialect returned by server 0x%x\n",
 			 le16_to_cpu(rsp->DialectRevision));
 		rc = -EIO;
 		goto neg_exit;
@@ -982,7 +982,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
 			rc = smb311_decode_neg_context(rsp, server,
 						       rsp_iov.iov_len);
 		else
-			cifs_dbg(VFS, "Missing expected negotiate contexts\n");
+			cifs_server_dbg(VFS, "Missing expected negotiate contexts\n");
 	}
 neg_exit:
 	free_rsp_buf(resp_buftype, rsp);
@@ -996,11 +996,12 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 	struct validate_negotiate_info_rsp *pneg_rsp = NULL;
 	u32 rsplen;
 	u32 inbuflen; /* max of 4 dialects */
+	struct TCP_Server_Info *server = tcon->ses->server;
 
 	cifs_dbg(FYI, "validate negotiate\n");
 
 	/* In SMB3.11 preauth integrity supersedes validate negotiate */
-	if (tcon->ses->server->dialect == SMB311_PROT_ID)
+	if (server->dialect == SMB311_PROT_ID)
 		return 0;
 
 	/*
@@ -1019,15 +1020,15 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 	}
 
 	if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
-		cifs_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
+		cifs_server_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
 
 	pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS);
 	if (!pneg_inbuf)
 		return -ENOMEM;
 
 	pneg_inbuf->Capabilities =
-			cpu_to_le32(tcon->ses->server->vals->req_capabilities);
-	memcpy(pneg_inbuf->Guid, tcon->ses->server->client_guid,
+			cpu_to_le32(server->vals->req_capabilities);
+	memcpy(pneg_inbuf->Guid, server->client_guid,
 					SMB2_CLIENT_GUID_SIZE);
 
 	if (tcon->ses->sign)
@@ -1040,7 +1041,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 		pneg_inbuf->SecurityMode = 0;
 
 
-	if (strcmp(tcon->ses->server->vals->version_string,
+	if (strcmp(server->vals->version_string,
 		SMB3ANY_VERSION_STRING) == 0) {
 		pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
 		pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
@@ -1048,7 +1049,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 		/* structure is big enough for 3 dialects, sending only 2 */
 		inbuflen = sizeof(*pneg_inbuf) -
 				(2 * sizeof(pneg_inbuf->Dialects[0]));
-	} else if (strcmp(tcon->ses->server->vals->version_string,
+	} else if (strcmp(server->vals->version_string,
 		SMBDEFAULT_VERSION_STRING) == 0) {
 		pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
 		pneg_inbuf->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
@@ -1060,7 +1061,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 	} else {
 		/* otherwise specific dialect was requested */
 		pneg_inbuf->Dialects[0] =
-			cpu_to_le16(tcon->ses->server->vals->protocol_id);
+			cpu_to_le16(server->vals->protocol_id);
 		pneg_inbuf->DialectCount = cpu_to_le16(1);
 		/* structure is big enough for 3 dialects, sending only 1 */
 		inbuflen = sizeof(*pneg_inbuf) -
@@ -1076,18 +1077,18 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 		 * Old Windows versions or Netapp SMB server can return
 		 * not supported error. Client should accept it.
 		 */
-		cifs_dbg(VFS, "Server does not support validate negotiate\n");
+		cifs_server_dbg(VFS, "Server does not support validate negotiate\n");
 		rc = 0;
 		goto out_free_inbuf;
 	} else if (rc != 0) {
-		cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
+		cifs_server_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
 		rc = -EIO;
 		goto out_free_inbuf;
 	}
 
 	rc = -EIO;
 	if (rsplen != sizeof(*pneg_rsp)) {
-		cifs_dbg(VFS, "invalid protocol negotiate response size: %d\n",
+		cifs_server_dbg(VFS, "invalid protocol negotiate response size: %d\n",
 			 rsplen);
 
 		/* relax check since Mac returns max bufsize allowed on ioctl */
@@ -1096,16 +1097,16 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 	}
 
 	/* check validate negotiate info response matches what we got earlier */
-	if (pneg_rsp->Dialect != cpu_to_le16(tcon->ses->server->dialect))
+	if (pneg_rsp->Dialect != cpu_to_le16(server->dialect))
 		goto vneg_out;
 
-	if (pneg_rsp->SecurityMode != cpu_to_le16(tcon->ses->server->sec_mode))
+	if (pneg_rsp->SecurityMode != cpu_to_le16(server->sec_mode))
 		goto vneg_out;
 
 	/* do not validate server guid because not saved at negprot time yet */
 
 	if ((le32_to_cpu(pneg_rsp->Capabilities) | SMB2_NT_FIND |
-	      SMB2_LARGE_FILES) != tcon->ses->server->capabilities)
+	      SMB2_LARGE_FILES) != server->capabilities)
 		goto vneg_out;
 
 	/* validate negotiate successful */
@@ -1114,7 +1115,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 	goto out_free_rsp;
 
 vneg_out:
-	cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n");
+	cifs_server_dbg(VFS, "protocol revalidation - security settings mismatch\n");
 out_free_rsp:
 	kfree(pneg_rsp);
 out_free_inbuf:
@@ -1568,7 +1569,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
 		sess_data->func(sess_data);
 
 	if ((ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) && (ses->sign))
-		cifs_dbg(VFS, "signing requested but authenticated as guest\n");
+		cifs_server_dbg(VFS, "signing requested but authenticated as guest\n");
 	rc = sess_data->result;
 out:
 	kfree(sess_data);
@@ -1661,10 +1662,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 	__le16 *unc_path = NULL;
 	int flags = 0;
 	unsigned int total_len;
+	struct TCP_Server_Info *server = ses->server;
 
 	cifs_dbg(FYI, "TCON\n");
 
-	if (!(ses->server) || !tree)
+	if (!server || !tree)
 		return -EIO;
 
 	unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL);
@@ -1707,7 +1709,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 	 * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1
 	 * (Samba servers don't always set the flag so also check if null user)
 	 */
-	if ((ses->server->dialect == SMB311_PROT_ID) &&
+	if ((server->dialect == SMB311_PROT_ID) &&
 	    !smb3_encryption_required(tcon) &&
 	    !(ses->session_flags &
 		    (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) &&
@@ -1746,7 +1748,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 		cifs_dbg(FYI, "connection to printer\n");
 		break;
 	default:
-		cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
+		cifs_server_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
 		rc = -EOPNOTSUPP;
 		goto tcon_error_exit;
 	}
@@ -1761,15 +1763,15 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 
 	if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) &&
 	    ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))
-		cifs_dbg(VFS, "DFS capability contradicts DFS flag\n");
+		cifs_server_dbg(VFS, "DFS capability contradicts DFS flag\n");
 
 	if (tcon->seal &&
-	    !(tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
-		cifs_dbg(VFS, "Encryption is requested but not supported\n");
+	    !(server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
+		cifs_server_dbg(VFS, "Encryption is requested but not supported\n");
 
 	init_copy_chunk_defaults(tcon);
-	if (tcon->ses->server->ops->validate_negotiate)
-		rc = tcon->ses->server->ops->validate_negotiate(xid, tcon);
+	if (server->ops->validate_negotiate)
+		rc = server->ops->validate_negotiate(xid, tcon);
 tcon_exit:
 
 	free_rsp_buf(resp_buftype, rsp);
@@ -1778,7 +1780,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 
 tcon_error_exit:
 	if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) {
-		cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
+		cifs_server_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
 	}
 	goto tcon_exit;
 }
@@ -2742,6 +2744,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
 	int resp_buftype = CIFS_NO_BUFFER;
 	int rc = 0;
 	int flags = 0;
+	struct TCP_Server_Info *server;
 
 	cifs_dbg(FYI, "SMB2 IOCTL\n");
 
@@ -2757,7 +2760,8 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
 	else
 		return -EIO;
 
-	if (!ses || !(ses->server))
+	server = ses->server;
+	if (!ses || !(server))
 		return -EIO;
 
 	if (smb3_encryption_required(tcon))
@@ -2807,14 +2811,14 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
 	if (*plen == 0)
 		goto ioctl_exit; /* server returned no data */
 	else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) {
-		cifs_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen);
+		cifs_server_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen);
 		*plen = 0;
 		rc = -EIO;
 		goto ioctl_exit;
 	}
 
 	if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) {
-		cifs_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen,
+		cifs_server_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen,
 			le32_to_cpu(rsp->OutputOffset));
 		*plen = 0;
 		rc = -EIO;
@@ -3055,12 +3059,13 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
 	int rc = 0;
 	int resp_buftype = CIFS_NO_BUFFER;
 	struct cifs_ses *ses = tcon->ses;
+	struct TCP_Server_Info *server = ses->server;
 	int flags = 0;
 	bool allocated = false;
 
 	cifs_dbg(FYI, "Query Info\n");
 
-	if (!ses || !(ses->server))
+	if (!ses || !(server))
 		return -EIO;
 
 	if (smb3_encryption_required(tcon))
@@ -3098,7 +3103,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
 		if (!*data) {
 			*data = kmalloc(*dlen, GFP_KERNEL);
 			if (!*data) {
-				cifs_dbg(VFS,
+				cifs_server_dbg(VFS,
 					"Error %d allocating memory for acl\n",
 					rc);
 				*dlen = 0;
@@ -3468,7 +3473,7 @@ smb2_readv_callback(struct mid_q_entry *mid)
 
 			rc = smb2_verify_signature(&rqst, server);
 			if (rc)
-				cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
+				cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
 					 rc);
 		}
 		/* FIXME: should this be counted toward the initiating task? */
@@ -4058,7 +4063,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
 		info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO) - 1;
 		break;
 	default:
-		cifs_dbg(VFS, "info level %u isn't supported\n",
+		cifs_server_dbg(VFS, "info level %u isn't supported\n",
 			 srch_inf->info_level);
 		rc = -EINVAL;
 		goto qdir_exit;
@@ -4149,7 +4154,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
 	else if (resp_buftype == CIFS_SMALL_BUFFER)
 		srch_inf->smallBuf = true;
 	else
-		cifs_dbg(VFS, "illegal search buffer type\n");
+		cifs_server_dbg(VFS, "illegal search buffer type\n");
 
 	trace_smb3_query_dir_done(xid, persistent_fid, tcon->tid,
 			tcon->ses->Suid, index, srch_inf->entries_in_buffer);
diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c
index 1ccbcf9c2c3b..b02242eacb55 100644
--- a/fs/cifs/smb2transport.c
+++ b/fs/cifs/smb2transport.c
@@ -176,7 +176,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
 
 	ses = smb2_find_smb_ses(server, shdr->SessionId);
 	if (!ses) {
-		cifs_dbg(VFS, "%s: Could not find session\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
 		return 0;
 	}
 
@@ -185,21 +185,21 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
 
 	rc = smb2_crypto_shash_allocate(server);
 	if (rc) {
-		cifs_dbg(VFS, "%s: sha256 alloc failed\n", __func__);
+		cifs_server_dbg(VFS, "%s: sha256 alloc failed\n", __func__);
 		return rc;
 	}
 
 	rc = crypto_shash_setkey(server->secmech.hmacsha256,
 				 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not update with response\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not update with response\n", __func__);
 		return rc;
 	}
 
 	shash = &server->secmech.sdeschmacsha256->shash;
 	rc = crypto_shash_init(shash);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not init sha256", __func__);
+		cifs_server_dbg(VFS, "%s: Could not init sha256", __func__);
 		return rc;
 	}
 
@@ -215,7 +215,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
 		rc = crypto_shash_update(shash, iov[0].iov_base,
 					 iov[0].iov_len);
 		if (rc) {
-			cifs_dbg(VFS, "%s: Could not update with payload\n",
+			cifs_server_dbg(VFS, "%s: Could not update with payload\n",
 				 __func__);
 			return rc;
 		}
@@ -239,68 +239,69 @@ static int generate_key(struct cifs_ses *ses, struct kvec label,
 	int rc = 0;
 	unsigned char prfhash[SMB2_HMACSHA256_SIZE];
 	unsigned char *hashptr = prfhash;
+	struct TCP_Server_Info *server = ses->server;
 
 	memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE);
 	memset(key, 0x0, key_size);
 
-	rc = smb3_crypto_shash_allocate(ses->server);
+	rc = smb3_crypto_shash_allocate(server);
 	if (rc) {
-		cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__);
+		cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_setkey(ses->server->secmech.hmacsha256,
+	rc = crypto_shash_setkey(server->secmech.hmacsha256,
 		ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not set with session key\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not set with session key\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_init(&ses->server->secmech.sdeschmacsha256->shash);
+	rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
+	rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
 				i, 4);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not update with n\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not update with n\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
+	rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
 				label.iov_base, label.iov_len);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not update with label\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not update with label\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
+	rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
 				&zero, 1);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not update with zero\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not update with zero\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
+	rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
 				context.iov_base, context.iov_len);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not update with context\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not update with context\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
+	rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
 				L, 4);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not update with L\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not update with L\n", __func__);
 		goto smb3signkey_ret;
 	}
 
-	rc = crypto_shash_final(&ses->server->secmech.sdeschmacsha256->shash,
+	rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash,
 				hashptr);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
 		goto smb3signkey_ret;
 	}
 
@@ -436,7 +437,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
 
 	ses = smb2_find_smb_ses(server, shdr->SessionId);
 	if (!ses) {
-		cifs_dbg(VFS, "%s: Could not find session\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
 		return 0;
 	}
 
@@ -446,7 +447,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
 	rc = crypto_shash_setkey(server->secmech.cmacaes,
 				 ses->smb3signingkey, SMB2_CMACAES_SIZE);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
 		return rc;
 	}
 
@@ -457,7 +458,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
 	 */
 	rc = crypto_shash_init(shash);
 	if (rc) {
-		cifs_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
+		cifs_server_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
 		return rc;
 	}
 
@@ -473,7 +474,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
 		rc = crypto_shash_update(shash, iov[0].iov_base,
 					 iov[0].iov_len);
 		if (rc) {
-			cifs_dbg(VFS, "%s: Could not update with payload\n",
+			cifs_server_dbg(VFS, "%s: Could not update with payload\n",
 				 __func__);
 			return rc;
 		}
@@ -665,7 +666,7 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 
 		rc = smb2_verify_signature(&rqst, server);
 		if (rc)
-			cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
+			cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
 				 rc);
 	}
 
@@ -739,7 +740,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server)
 		else
 			tfm = crypto_alloc_aead("ccm(aes)", 0, 0);
 		if (IS_ERR(tfm)) {
-			cifs_dbg(VFS, "%s: Failed to alloc encrypt aead\n",
+			cifs_server_dbg(VFS, "%s: Failed to alloc encrypt aead\n",
 				 __func__);
 			return PTR_ERR(tfm);
 		}
@@ -754,7 +755,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server)
 		if (IS_ERR(tfm)) {
 			crypto_free_aead(server->secmech.ccmaesencrypt);
 			server->secmech.ccmaesencrypt = NULL;
-			cifs_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
+			cifs_server_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
 				 __func__);
 			return PTR_ERR(tfm);
 		}
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 5d6d44bfe10a..0d60bd2f4dca 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -118,7 +118,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
 #ifdef CONFIG_CIFS_STATS2
 	now = jiffies;
 	if (now < midEntry->when_alloc)
-		cifs_dbg(VFS, "invalid mid allocation time\n");
+		cifs_server_dbg(VFS, "invalid mid allocation time\n");
 	roundtrip_time = now - midEntry->when_alloc;
 
 	if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) {
@@ -232,7 +232,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
 			retries++;
 			if (retries >= 14 ||
 			    (!server->noblocksnd && (retries > 2))) {
-				cifs_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
+				cifs_server_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
 					 ssocket);
 				return -EAGAIN;
 			}
@@ -246,7 +246,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
 		if (rc == 0) {
 			/* should never happen, letting socket clear before
 			   retrying is our only obvious option here */
-			cifs_dbg(VFS, "tcp sent no data\n");
+			cifs_server_dbg(VFS, "tcp sent no data\n");
 			msleep(500);
 			continue;
 		}
@@ -440,7 +440,7 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 	}
 smbd_done:
 	if (rc < 0 && rc != -EINTR)
-		cifs_dbg(VFS, "Error %d sending data on socket to server\n",
+		cifs_server_dbg(VFS, "Error %d sending data on socket to server\n",
 			 rc);
 	else if (rc > 0)
 		rc = 0;
@@ -473,8 +473,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
 	cur_rqst[0].rq_nvec = 1;
 
 	if (!server->ops->init_transform_rq) {
-		cifs_dbg(VFS, "Encryption requested but transform callback "
-			 "is missing\n");
+		cifs_server_dbg(VFS, "Encryption requested but transform "
+				"callback is missing\n");
 		return -EIO;
 	}
 
@@ -548,7 +548,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
 			if (!rc) {
 				trace_smb3_credit_timeout(server->CurrentMid,
 					server->hostname, num_credits);
-				cifs_dbg(VFS, "wait timed out after %d ms\n",
+				cifs_server_dbg(VFS, "wait timed out after %d ms\n",
 					 timeout);
 				return -ENOTSUPP;
 			}
@@ -589,7 +589,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits,
 					trace_smb3_credit_timeout(
 						server->CurrentMid,
 						server->hostname, num_credits);
-					cifs_dbg(VFS, "wait timed out after %d ms\n",
+					cifs_server_dbg(VFS, "wait timed out after %d ms\n",
 						 timeout);
 					return -ENOTSUPP;
 				}
@@ -869,7 +869,7 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server)
 		break;
 	default:
 		list_del_init(&mid->qhead);
-		cifs_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
+		cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
 			 __func__, mid->mid, mid->mid_state);
 		rc = -EIO;
 	}
@@ -910,7 +910,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 		rc = cifs_verify_signature(&rqst, server,
 					   mid->sequence_number);
 		if (rc)
-			cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
+			cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
 				 rc);
 	}
 
@@ -1107,7 +1107,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
 	}
 	if (rc != 0) {
 		for (; i < num_rqst; i++) {
-			cifs_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
+			cifs_server_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
 				 midQ[i]->mid, le16_to_cpu(midQ[i]->command));
 			send_cancel(server, &rqst[i], midQ[i]);
 			spin_lock(&GlobalMid_Lock);
@@ -1242,17 +1242,18 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
 	struct kvec iov = { .iov_base = in_buf, .iov_len = len };
 	struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
 	struct cifs_credits credits = { .value = 1, .instance = 0 };
+	struct TCP_Server_Info *server = ses->server;
 
 	if (ses == NULL) {
 		cifs_dbg(VFS, "Null smb session\n");
 		return -EIO;
 	}
-	if (ses->server == NULL) {
+	if (server == NULL) {
 		cifs_dbg(VFS, "Null tcp session\n");
 		return -EIO;
 	}
 
-	if (ses->server->tcpStatus == CifsExiting)
+	if (server->tcpStatus == CifsExiting)
 		return -ENOENT;
 
 	/* Ensure that we do not send more than 50 overlapping requests
@@ -1260,12 +1261,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
 	   use ses->maxReq */
 
 	if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
-		cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
+		cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
 			 len);
 		return -EIO;
 	}
 
-	rc = wait_for_free_request(ses->server, flags, &credits.instance);
+	rc = wait_for_free_request(server, flags, &credits.instance);
 	if (rc)
 		return rc;
 
@@ -1273,70 +1274,70 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses,
 	   and avoid races inside tcp sendmsg code that could cause corruption
 	   of smb data */
 
-	mutex_lock(&ses->server->srv_mutex);
+	mutex_lock(&server->srv_mutex);
 
 	rc = allocate_mid(ses, in_buf, &midQ);
 	if (rc) {
 		mutex_unlock(&ses->server->srv_mutex);
 		/* Update # of requests on wire to server */
-		add_credits(ses->server, &credits, 0);
+		add_credits(server, &credits, 0);
 		return rc;
 	}
 
-	rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
+	rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
 	if (rc) {
-		mutex_unlock(&ses->server->srv_mutex);
+		mutex_unlock(&server->srv_mutex);
 		goto out;
 	}
 
 	midQ->mid_state = MID_REQUEST_SUBMITTED;
 
-	cifs_in_send_inc(ses->server);
-	rc = smb_send(ses->server, in_buf, len);
-	cifs_in_send_dec(ses->server);
+	cifs_in_send_inc(server);
+	rc = smb_send(server, in_buf, len);
+	cifs_in_send_dec(server);
 	cifs_save_when_sent(midQ);
 
 	if (rc < 0)
-		ses->server->sequence_number -= 2;
+		server->sequence_number -= 2;
 
-	mutex_unlock(&ses->server->srv_mutex);
+	mutex_unlock(&server->srv_mutex);
 
 	if (rc < 0)
 		goto out;
 
-	rc = wait_for_response(ses->server, midQ);
+	rc = wait_for_response(server, midQ);
 	if (rc != 0) {
-		send_cancel(ses->server, &rqst, midQ);
+		send_cancel(server, &rqst, midQ);
 		spin_lock(&GlobalMid_Lock);
 		if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
 			/* no longer considered to be "in-flight" */
 			midQ->callback = DeleteMidQEntry;
 			spin_unlock(&GlobalMid_Lock);
-			add_credits(ses->server, &credits, 0);
+			add_credits(server, &credits, 0);
 			return rc;
 		}
 		spin_unlock(&GlobalMid_Lock);
 	}
 
-	rc = cifs_sync_mid_result(midQ, ses->server);
+	rc = cifs_sync_mid_result(midQ, server);
 	if (rc != 0) {
-		add_credits(ses->server, &credits, 0);
+		add_credits(server, &credits, 0);
 		return rc;
 	}
 
 	if (!midQ->resp_buf || !out_buf ||
 	    midQ->mid_state != MID_RESPONSE_RECEIVED) {
 		rc = -EIO;
-		cifs_dbg(VFS, "Bad MID state?\n");
+		cifs_server_dbg(VFS, "Bad MID state?\n");
 		goto out;
 	}
 
 	*pbytes_returned = get_rfc1002_length(midQ->resp_buf);
 	memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
-	rc = cifs_check_receive(midQ, ses->server, 0);
+	rc = cifs_check_receive(midQ, server, 0);
 out:
 	cifs_delete_mid(midQ);
-	add_credits(ses->server, &credits, 0);
+	add_credits(server, &credits, 0);
 
 	return rc;
 }
@@ -1379,19 +1380,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
 	struct kvec iov = { .iov_base = in_buf, .iov_len = len };
 	struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
 	unsigned int instance;
+	struct TCP_Server_Info *server;
 
 	if (tcon == NULL || tcon->ses == NULL) {
 		cifs_dbg(VFS, "Null smb session\n");
 		return -EIO;
 	}
 	ses = tcon->ses;
+	server = ses->server;
 
-	if (ses->server == NULL) {
+	if (server == NULL) {
 		cifs_dbg(VFS, "Null tcp session\n");
 		return -EIO;
 	}
 
-	if (ses->server->tcpStatus == CifsExiting)
+	if (server->tcpStatus == CifsExiting)
 		return -ENOENT;
 
 	/* Ensure that we do not send more than 50 overlapping requests
@@ -1399,12 +1402,12 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
 	   use ses->maxReq */
 
 	if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
-		cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
+		cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
 			 len);
 		return -EIO;
 	}
 
-	rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, &instance);
+	rc = wait_for_free_request(server, CIFS_BLOCKING_OP, &instance);
 	if (rc)
 		return rc;
 
@@ -1412,31 +1415,31 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
 	   and avoid races inside tcp sendmsg code that could cause corruption
 	   of smb data */
 
-	mutex_lock(&ses->server->srv_mutex);
+	mutex_lock(&server->srv_mutex);
 
 	rc = allocate_mid(ses, in_buf, &midQ);
 	if (rc) {
-		mutex_unlock(&ses->server->srv_mutex);
+		mutex_unlock(&server->srv_mutex);
 		return rc;
 	}
 
-	rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
+	rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
 	if (rc) {
 		cifs_delete_mid(midQ);
-		mutex_unlock(&ses->server->srv_mutex);
+		mutex_unlock(&server->srv_mutex);
 		return rc;
 	}
 
 	midQ->mid_state = MID_REQUEST_SUBMITTED;
-	cifs_in_send_inc(ses->server);
-	rc = smb_send(ses->server, in_buf, len);
-	cifs_in_send_dec(ses->server);
+	cifs_in_send_inc(server);
+	rc = smb_send(server, in_buf, len);
+	cifs_in_send_dec(server);
 	cifs_save_when_sent(midQ);
 
 	if (rc < 0)
-		ses->server->sequence_number -= 2;
+		server->sequence_number -= 2;
 
-	mutex_unlock(&ses->server->srv_mutex);
+	mutex_unlock(&server->srv_mutex);
 
 	if (rc < 0) {
 		cifs_delete_mid(midQ);
@@ -1444,21 +1447,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
 	}
 
 	/* Wait for a reply - allow signals to interrupt. */
-	rc = wait_event_interruptible(ses->server->response_q,
+	rc = wait_event_interruptible(server->response_q,
 		(!(midQ->mid_state == MID_REQUEST_SUBMITTED)) ||
-		((ses->server->tcpStatus != CifsGood) &&
-		 (ses->server->tcpStatus != CifsNew)));
+		((server->tcpStatus != CifsGood) &&
+		 (server->tcpStatus != CifsNew)));
 
 	/* Were we interrupted by a signal ? */
 	if ((rc == -ERESTARTSYS) &&
 		(midQ->mid_state == MID_REQUEST_SUBMITTED) &&
-		((ses->server->tcpStatus == CifsGood) ||
-		 (ses->server->tcpStatus == CifsNew))) {
+		((server->tcpStatus == CifsGood) ||
+		 (server->tcpStatus == CifsNew))) {
 
 		if (in_buf->Command == SMB_COM_TRANSACTION2) {
 			/* POSIX lock. We send a NT_CANCEL SMB to cause the
 			   blocking lock to return. */
-			rc = send_cancel(ses->server, &rqst, midQ);
+			rc = send_cancel(server, &rqst, midQ);
 			if (rc) {
 				cifs_delete_mid(midQ);
 				return rc;
@@ -1477,9 +1480,9 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
 			}
 		}
 
-		rc = wait_for_response(ses->server, midQ);
+		rc = wait_for_response(server, midQ);
 		if (rc) {
-			send_cancel(ses->server, &rqst, midQ);
+			send_cancel(server, &rqst, midQ);
 			spin_lock(&GlobalMid_Lock);
 			if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
 				/* no longer considered to be "in-flight" */
@@ -1494,20 +1497,20 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
 		rstart = 1;
 	}
 
-	rc = cifs_sync_mid_result(midQ, ses->server);
+	rc = cifs_sync_mid_result(midQ, server);
 	if (rc != 0)
 		return rc;
 
 	/* rcvd frame is ok */
 	if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) {
 		rc = -EIO;
-		cifs_dbg(VFS, "Bad MID state?\n");
+		cifs_server_dbg(VFS, "Bad MID state?\n");
 		goto out;
 	}
 
 	*pbytes_returned = get_rfc1002_length(midQ->resp_buf);
 	memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
-	rc = cifs_check_receive(midQ, ses->server, 0);
+	rc = cifs_check_receive(midQ, server, 0);
 out:
 	cifs_delete_mid(midQ);
 	if (rstart && rc == -EACCES)
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-30  1:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-28  3:17 [PATCH] cifs: add new debugging macro cifs_server_dbg Ronnie Sahlberg
2019-08-28 10:04 ` Aurélien Aptel
2019-08-28 10:13   ` ronnie sahlberg
2019-08-28  7:15 [PATCH 0/1] add new debugging macro Ronnie Sahlberg
2019-08-28  7:15 ` [PATCH] cifs: add new debugging macro cifs_server_dbg Ronnie Sahlberg
2019-08-30  1:47   ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).