Skip to contentSkip to conversation

cifs: after disabling multichannel, mark tcon for reconnect

PATCH In review [email protected] 1 participant 2 messages Dec 29, 2023

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

PATCH 1/1 cifs: after disabling multichannel, mark tcon for reconnect

From: Shyam Prasad N <[email protected]>

Once the server disables multichannel for an active multichannel session, on the following reconnect, the client would reduce the number of channels to 1. However, it could be the case that the tree connect was active on one of these disabled channels. This results in an unrecoverable state.

This change fixes that by making sure that whenever a channel is being terminated, the session and tcon are marked for reconnect too. This could mean a few redundant tree connect calls to the server, but considering that this is not a frequent event, we should be okay.

Fixes ee1d21794e55 ("cifs: handle when server stops supporting multichannel")
---
 fs/smb/client/connect.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
fs/smb/client/connect.c +12 -8
index 44bfdd88a906..8b7cffba1ad5 100644
@@ -216,17 +216,21 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
 	/* If server is a channel, select the primary channel */
 	pserver = SERVER_IS_CHAN(server) ? server->primary_server : server;
 
+	/*
+	 * if the server has been marked for termination, there is a
+	 * chance that the remaining channels all need reconnect. To be
+	 * on the safer side, mark the session and trees for reconnect
+	 * for this scenario. This might cause a few redundant session
+	 * setup and tree connect requests, but it is better than not doing
+	 * a tree connect when needed, and all following requests failing
+	 */
+	if (server->terminate) {
+		mark_smb_session = true;
+		server = pserver;
+	}
 
 	spin_lock(&cifs_tcp_ses_lock);
 	list_for_each_entry_safe(ses, nses, &pserver->smb_ses_list, smb_ses_list) {
-		/*
-		 * if channel has been marked for termination, nothing to do
-		 * for the channel. in fact, we cannot find the channel for the
-		 * server. So safe to exit here
-		 */
-		if (server->terminate)
-			break;
-
 		/* check if iface is still active */
 		if (!cifs_chan_is_iface_active(ses, server))
 			cifs_chan_update_iface(ses, server);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 56 lines · On Fri, Dec 29, 2023 at 5:00 PM <[email protected]> wrote:

From: Shyam Prasad N <[email protected]>

Once the server disables multichannel for an active multichannel session, on the following reconnect, the client would reduce the number of channels to 1. However, it could be the case that the tree connect was active on one of these disabled channels. This results in an unrecoverable state.

This change fixes that by making sure that whenever a channel is being terminated, the session and tcon are marked for reconnect too. This could mean a few redundant tree connect calls to the server, but considering that this is not a frequent event, we should be okay.

Fixes ee1d21794e55 ("cifs: handle when server stops supporting multichannel")
---
 fs/smb/client/connect.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
fs/smb/client/connect.c +12 -9
index 44bfdd88a906..8b7cffba1ad5 100644
@@ -216,17 +216,21 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
        /* If server is a channel, select the primary channel */
        pserver = SERVER_IS_CHAN(server) ? server->primary_server : server;
 
+       /*
+        * if the server has been marked for termination, there is a
+        * chance that the remaining channels all need reconnect. To be
+        * on the safer side, mark the session and trees for reconnect
+        * for this scenario. This might cause a few redundant session
+        * setup and tree connect requests, but it is better than not doing
+        * a tree connect when needed, and all following requests failing
+        */
+       if (server->terminate) {
+               mark_smb_session = true;
+               server = pserver;
+       }
 
        spin_lock(&cifs_tcp_ses_lock);
        list_for_each_entry_safe(ses, nses, &pserver->smb_ses_list, smb_ses_list) {
-               /*
-                * if channel has been marked for termination, nothing to do
-                * for the channel. in fact, we cannot find the channel for the
-                * server. So safe to exit here
-                */
-               if (server->terminate)
-                       break;
-
                /* check if iface is still active */
                if (!cifs_chan_is_iface_active(ses, server))
                        cifs_chan_update_iface(ses, server);
--
Quoted 2 lines

2.34.1

Sorry I missed sending out this patch before the other four. This one needs to be applied first. Then the other four.

Signature · 2 lines
Regards,
Shyam