linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aurelien Aptel <aaptel@suse.com>
To: linux-cifs@vger.kernel.org
Cc: smfrench@gmail.com, Aurelien Aptel <aaptel@suse.com>
Subject: [PATCH 2/2] cifs: try harder to open new channels
Date: Wed, 20 Nov 2019 17:15:59 +0100	[thread overview]
Message-ID: <20191120161559.30295-2-aaptel@suse.com> (raw)
In-Reply-To: <20191120161559.30295-1-aaptel@suse.com>

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 <aaptel@suse.com>
---
 fs/cifs/sess.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index ee6bf47b6cfe..fb3bdc44775c 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -76,6 +76,7 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
 	int left = ses->chan_max - ses->chan_count;
 	int i = 0;
 	int rc = 0;
+	int tries = 0;
 
 	if (left <= 0) {
 		cifs_dbg(FYI,
@@ -89,29 +90,40 @@ int cifs_try_adding_channels(struct cifs_ses *ses)
 		return 0;
 	}
 
-	/* ifaces are sorted by speed, try them in order */
-	for (i = 0; left > 0 && i < ses->iface_count; i++) {
+	/*
+	 * Keep connecting to same, fastest, iface for all channels as
+	 * long as its RSS. Try next fastest one if not RSS or channel
+	 * creation fails.
+	 */
+	while (left > 0) {
 		struct cifs_server_iface *iface;
 
+		tries++;
+		if (tries > 3*ses->chan_max) {
+			cifs_dbg(FYI, "too many attempt at opening channels (%d channels left to open)\n",
+				 left);
+			break;
+		}
+
 		iface = &ses->iface_list[i];
-		if (is_ses_using_iface(ses, iface) && !iface->rss_capable)
+		if (is_ses_using_iface(ses, iface) && !iface->rss_capable) {
+			i = (i+1) % ses->iface_count;
 			continue;
+		}
 
 		rc = cifs_ses_add_channel(ses, iface);
 		if (rc) {
-			cifs_dbg(FYI, "failed to open extra channel\n");
+			cifs_dbg(FYI, "failed to open extra channel on iface#%d rc=%d\n",
+				 i, rc);
+			i = (i+1) % ses->iface_count;
 			continue;
 		}
 
-		cifs_dbg(FYI, "successfully opened new channel\n");
+		cifs_dbg(FYI, "successfully opened new channel on iface#%d\n",
+			 i);
 		left--;
 	}
 
-	/*
-	 * TODO: if we still have channels left to open try to connect
-	 * to same RSS-capable iface multiple times
-	 */
-
 	return ses->chan_count - old_chan_count;
 }
 
-- 
2.16.4


  reply	other threads:[~2019-11-20 16:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20 16:15 [PATCH 1/2] cifs: dump channel info in DebugData Aurelien Aptel
2019-11-20 16:15 ` Aurelien Aptel [this message]
2019-11-21 21:54 ` Steve French
2019-11-25 12:16   ` [PATCH v2] " Aurelien Aptel
2019-11-21 23:44 ` [PATCH 1/2] " Steve French

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191120161559.30295-2-aaptel@suse.com \
    --to=aaptel@suse.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).