Skip to contentSkip to conversation

Fix reconnect to not defer smb3 session reconnect long after socket reconnect

PATCH Superseded Steve French 1 participant 2 messages Jun 24, 2016 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Fix reconnect to not defer smb3 session reconnect long after socket reconnect

Azure server blocks clients that open a socket and don't do anything on it. In our reconnect scenarios, we can reconnect the tcp session and detect the socket is available but we defer the negprot and SMB3 session setup and tree connect reconnection until the next i/o is requested, but this looks suspicous to some servers who expect SMB3 negprog and session setup soon after a socket is created.

In the echo thread, reconnect SMB3 sessions and tree connections that are disconnected. A later patch will replay persistent (and resilient) handle opens.

---
 fs/cifs/connect.c |  4 +++-
 fs/cifs/smb2pdu.c | 24 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
fs/cifs/connect.c +3 -1
index 66736f5..7d2b15c 100644
@@ -428,7 +428,9 @@ cifs_echo_request(struct work_struct *work)
 	 * server->ops->need_neg() == true. Also, no need to ping if
 	 * we got a response recently.
 	 */
-	if (!server->ops->need_neg || server->ops->need_neg(server) ||
+
+	if (server->tcpStatus == CifsNeedReconnect ||
+	    server->tcpStatus == CifsExiting || server->tcpStatus == CifsNew ||
 	    (server->ops->can_echo && !server->ops->can_echo(server)) ||
 	    time_before(jiffies, server->lstrp + echo_interval - HZ))
 		goto requeue_echo;
fs/cifs/smb2pdu.c +24 -0
index 8f38e33..4030cbd 100644
@@ -1818,6 +1818,30 @@ SMB2_echo(struct TCP_Server_Info *server)
 
 	cifs_dbg(FYI, "In echo request\n");
 
+	if (server->tcpStatus == CifsNeedNegotiate) {
+		struct list_head *tmp, *tmp2;
+		struct cifs_ses *ses;
+		struct cifs_tcon *tcon;
+
+		cifs_dbg(FYI, "Need negotiate, reconnecting tcons\n");
+		spin_lock(&cifs_tcp_ses_lock);
+		list_for_each(tmp, &server->smb_ses_list) {
+			ses = list_entry(tmp, struct cifs_ses, smb_ses_list);
+			list_for_each(tmp2, &ses->tcon_list) {
+				tcon = list_entry(tmp2, struct cifs_tcon,
+						  tcon_list);
+				/* add check for persistent handle reconnect */
+				if (tcon && tcon->need_reconnect)
+					rc = smb2_reconnect(SMB2_ECHO, tcon);
+			}
+		}
+		spin_unlock(&cifs_tcp_ses_lock);
+	}
+
+	/* if no session, renegotiate failed above */
+	if (server->tcpStatus == CifsNeedNegotiate)
+		return -EIO;
+
 	rc = small_smb2_init(SMB2_ECHO, NULL, (void **)&req);
 	if (rc)
 		return rc;
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1466742647-9805-1-git-send-email-smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 2/2 Avoid possible deadlock in previous patch

---
 fs/cifs/smb2pdu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/cifs/smb2pdu.c +4 -1
index 4030cbd..f2cbb28 100644
@@ -1831,8 +1831,11 @@ SMB2_echo(struct TCP_Server_Info *server)
 				tcon = list_entry(tmp2, struct cifs_tcon,
 						  tcon_list);
 				/* add check for persistent handle reconnect */
-				if (tcon && tcon->need_reconnect)
+				if (tcon && tcon->need_reconnect) {
+					spin_unlock(&cifs_tcp_ses_lock);
 					rc = smb2_reconnect(SMB2_ECHO, tcon);
+					spin_lock(&cifs_tcp_ses_lock);
+				}
 			}
 		}
 		spin_unlock(&cifs_tcp_ses_lock);
Signature · 1 line
1.9.1