Skip to content

Commit 65a37a3

Browse files
aaptelsmfrench
authored andcommitted
cifs: try harder to open new channels
Previously we would only loop over the iface list once. This patch tries to loop over multiple times until all channels are opened. It will also try to reuse RSS ifaces. Signed-off-by: Aurelien Aptel <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 9bd4540 commit 65a37a3

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

fs/cifs/sess.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
7676
int left = ses->chan_max - ses->chan_count;
7777
int i = 0;
7878
int rc = 0;
79+
int tries = 0;
7980

8081
if (left <= 0) {
8182
cifs_dbg(FYI,
@@ -89,29 +90,40 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
8990
return 0;
9091
}
9192

92-
/* ifaces are sorted by speed, try them in order */
93-
for (i = 0; left > 0 && i < ses->iface_count; i++) {
93+
/*
94+
* Keep connecting to same, fastest, iface for all channels as
95+
* long as its RSS. Try next fastest one if not RSS or channel
96+
* creation fails.
97+
*/
98+
while (left > 0) {
9499
struct cifs_server_iface *iface;
95100

101+
tries++;
102+
if (tries > 3*ses->chan_max) {
103+
cifs_dbg(FYI, "too many attempt at opening channels (%d channels left to open)\n",
104+
left);
105+
break;
106+
}
107+
96108
iface = &ses->iface_list[i];
97-
if (is_ses_using_iface(ses, iface) && !iface->rss_capable)
109+
if (is_ses_using_iface(ses, iface) && !iface->rss_capable) {
110+
i = (i+1) % ses->iface_count;
98111
continue;
112+
}
99113

100114
rc = cifs_ses_add_channel(ses, iface);
101115
if (rc) {
102-
cifs_dbg(FYI, "failed to open extra channel\n");
116+
cifs_dbg(FYI, "failed to open extra channel on iface#%d rc=%d\n",
117+
i, rc);
118+
i = (i+1) % ses->iface_count;
103119
continue;
104120
}
105121

106-
cifs_dbg(FYI, "successfully opened new channel\n");
122+
cifs_dbg(FYI, "successfully opened new channel on iface#%d\n",
123+
i);
107124
left--;
108125
}
109126

110-
/*
111-
* TODO: if we still have channels left to open try to connect
112-
* to same RSS-capable iface multiple times
113-
*/
114-
115127
return ses->chan_count - old_chan_count;
116128
}
117129

0 commit comments

Comments
 (0)