提交 fd88ce93 编写于 作者: S Steve French

[CIFS] cifs: clarify the meaning of tcpStatus == CifsGood

When the TCP_Server_Info is first allocated and connected, tcpStatus ==
CifsGood means that the NEGOTIATE_PROTOCOL request has completed and the
socket is ready for other calls. cifs_reconnect however sets tcpStatus
to CifsGood as soon as the socket is reconnected and the optional
RFC1001 session setup is done. We have no clear way to tell the
difference between these two states, and we need to know this in order
to know whether we can send an echo or not.

Resolve this by adding a new statusEnum value -- CifsNeedNegotiate. When
the socket has been connected but has not yet had a NEGOTIATE_PROTOCOL
request done, set it to this value. Once the NEGOTIATE is done,
cifs_negotiate_protocol will set tcpStatus to CifsGood.

This also fixes and cleans the logic in cifs_reconnect and
cifs_reconnect_tcon. The old code checked for specific states when what
it really wants to know is whether the state has actually changed from
CifsNeedReconnect.
Reported-and-Tested-by: NJG <jg@cms.ac>
Signed-off-by: NJeff Layton <jlayton@redhat.com>
Signed-off-by: NSteve French <sfrench@us.ibm.com>
上级 157c2491
...@@ -91,7 +91,8 @@ enum statusEnum { ...@@ -91,7 +91,8 @@ enum statusEnum {
CifsNew = 0, CifsNew = 0,
CifsGood, CifsGood,
CifsExiting, CifsExiting,
CifsNeedReconnect CifsNeedReconnect,
CifsNeedNegotiate
}; };
enum securityEnum { enum securityEnum {
......
...@@ -142,9 +142,9 @@ cifs_reconnect_tcon(struct cifsTconInfo *tcon, int smb_command) ...@@ -142,9 +142,9 @@ cifs_reconnect_tcon(struct cifsTconInfo *tcon, int smb_command)
*/ */
while (server->tcpStatus == CifsNeedReconnect) { while (server->tcpStatus == CifsNeedReconnect) {
wait_event_interruptible_timeout(server->response_q, wait_event_interruptible_timeout(server->response_q,
(server->tcpStatus == CifsGood), 10 * HZ); (server->tcpStatus != CifsNeedReconnect), 10 * HZ);
/* is TCP session is reestablished now ?*/ /* are we still trying to reconnect? */
if (server->tcpStatus != CifsNeedReconnect) if (server->tcpStatus != CifsNeedReconnect)
break; break;
......
...@@ -199,8 +199,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -199,8 +199,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
while ((server->tcpStatus != CifsExiting) && while (server->tcpStatus == CifsNeedReconnect) {
(server->tcpStatus != CifsGood)) {
try_to_freeze(); try_to_freeze();
/* we should try only the port we connected to before */ /* we should try only the port we connected to before */
...@@ -212,7 +211,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -212,7 +211,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
atomic_inc(&tcpSesReconnectCount); atomic_inc(&tcpSesReconnectCount);
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if (server->tcpStatus != CifsExiting) if (server->tcpStatus != CifsExiting)
server->tcpStatus = CifsGood; server->tcpStatus = CifsNeedNegotiate;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
} }
} }
...@@ -421,7 +420,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) ...@@ -421,7 +420,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
pdu_length = 4; /* enough to get RFC1001 header */ pdu_length = 4; /* enough to get RFC1001 header */
incomplete_rcv: incomplete_rcv:
if (echo_retries > 0 && if (echo_retries > 0 && server->tcpStatus == CifsGood &&
time_after(jiffies, server->lstrp + time_after(jiffies, server->lstrp +
(echo_retries * SMB_ECHO_INTERVAL))) { (echo_retries * SMB_ECHO_INTERVAL))) {
cERROR(1, "Server %s has not responded in %d seconds. " cERROR(1, "Server %s has not responded in %d seconds. "
...@@ -1766,6 +1765,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) ...@@ -1766,6 +1765,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
module_put(THIS_MODULE); module_put(THIS_MODULE);
goto out_err_crypto_release; goto out_err_crypto_release;
} }
tcp_ses->tcpStatus = CifsNeedNegotiate;
/* thread spawned, put it on the list */ /* thread spawned, put it on the list */
spin_lock(&cifs_tcp_ses_lock); spin_lock(&cifs_tcp_ses_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册