Skip to contentSkip to conversation

cifs: reset iface weights when we cannot find a candidate

PATCH In review [email protected] 2 participants 2 messages Jul 17, 2025 – Jul 18, 2025

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

PATCH 1/1 cifs: reset iface weights when we cannot find a candidate

From: Shyam Prasad N <[email protected]>

We now do a weighted selection of server interfaces when allocating new channels. The weights are decided based on the speed advertised. The fulfilled weight for an interface is a counter that is used to track the interface selection. It should be reset back to zero once all interfaces fulfilling their weight.

In cifs_chan_update_iface, this reset logic was missing. As a result when the server interface list changes, the client may not be able to find a new candidate for other channels after all interfaces have been fulfilled.

Fixes a6d8fb54a515 ("cifs: distribute channels across interfaces based on speed")
---
 fs/smb/client/sess.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/smb/client/sess.c +9 -0
index 330bc3d25bad..0a8c2fcc9ded 100644
@@ -332,6 +332,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 	struct cifs_server_iface *old_iface = NULL;
 	struct cifs_server_iface *last_iface = NULL;
 	struct sockaddr_storage ss;
+	int retry = 0;
 
 	spin_lock(&ses->chan_lock);
 	chan_index = cifs_ses_get_chan_index(ses, server);
@@ -360,6 +361,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 		return;
 	}
 
+try_again:
 	last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface,
 				     iface_head);
 	iface_min_speed = last_iface->speed;
@@ -397,6 +399,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
 	}
 
 	if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
+		list_for_each_entry(iface, &ses->iface_list, iface_head)
+			iface->weight_fulfilled = 0;
+
+		/* see if it can be satisfied in second attempt */
+		if (!retry++)
+			goto try_again;
+
 		iface = NULL;
 		cifs_dbg(FYI, "unable to find a suitable iface\n");
 	}
Signature · 1 line
2.43.0
#1 lore raw

applied to cifs-2.6.git for-next pending additional testing and review

Quoted 58 lines · On Thu, Jul 17, 2025 at 7:06 AM <[email protected]> wrote:

From: Shyam Prasad N <[email protected]>

We now do a weighted selection of server interfaces when allocating new channels. The weights are decided based on the speed advertised. The fulfilled weight for an interface is a counter that is used to track the interface selection. It should be reset back to zero once all interfaces fulfilling their weight.

In cifs_chan_update_iface, this reset logic was missing. As a result when the server interface list changes, the client may not be able to find a new candidate for other channels after all interfaces have been fulfilled.

Fixes a6d8fb54a515 ("cifs: distribute channels across interfaces based on speed")
---
 fs/smb/client/sess.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/smb/client/sess.c +9 -1
index 330bc3d25bad..0a8c2fcc9ded 100644
@@ -332,6 +332,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
        struct cifs_server_iface *old_iface = NULL;
        struct cifs_server_iface *last_iface = NULL;
        struct sockaddr_storage ss;
+       int retry = 0;
 
        spin_lock(&ses->chan_lock);
        chan_index = cifs_ses_get_chan_index(ses, server);
@@ -360,6 +361,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
                return;
        }
 
+try_again:
        last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface,
                                     iface_head);
        iface_min_speed = last_iface->speed;
@@ -397,6 +399,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
        }
 
        if (list_entry_is_head(iface, &ses->iface_list, iface_head)) {
+               list_for_each_entry(iface, &ses->iface_list, iface_head)
+                       iface->weight_fulfilled = 0;
+
+               /* see if it can be satisfied in second attempt */
+               if (!retry++)
+                       goto try_again;
+
                iface = NULL;
                cifs_dbg(FYI, "unable to find a suitable iface\n");
        }
--

2.43.0

Signature · 3 lines
Thanks,

Steve