Linux-CIFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] cifs: Fix lookup of SMB connections on multichannel
@ 2019-12-04 14:25 Paulo Alcantara (SUSE)
  2019-12-04 17:55 ` Steve French
  0 siblings, 1 reply; 2+ messages in thread
From: Paulo Alcantara (SUSE) @ 2019-12-04 14:25 UTC (permalink / raw)
  To: smfrench; +Cc: linux-cifs, Paulo Alcantara (SUSE), Aurelien Aptel

With the addition of SMB session channels, we introduced new TCP
server pointers that have no sessions or tcons associated with them.

In this case, when we started looking for TCP connections, we might
end up picking session channel rather than the master connection,
hence failing to get either a session or a tcon.

In order to fix that, this patch introduces a new "is_channel" field
to TCP_Server_Info structure so we can skip session channels during
lookup of connections.

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
---
 fs/cifs/cifsglob.h | 1 +
 fs/cifs/connect.c  | 6 +++++-
 fs/cifs/sess.c     | 3 +++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 5b976e01dd6b..fd0262ce5ad5 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -777,6 +777,7 @@ struct TCP_Server_Info {
 	 */
 	int nr_targets;
 	bool noblockcnt; /* use non-blocking connect() */
+	bool is_channel; /* if a session channel */
 };
 
 struct cifs_credits {
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 86d1baedf21c..05ea0e2b7e0e 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2712,7 +2712,11 @@ cifs_find_tcp_session(struct smb_vol *vol)
 
 	spin_lock(&cifs_tcp_ses_lock);
 	list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
-		if (!match_server(server, vol))
+		/*
+		 * Skip ses channels since they're only handled in lower layers
+		 * (e.g. cifs_send_recv).
+		 */
+		if (server->is_channel || !match_server(server, vol))
 			continue;
 
 		++server->srv_count;
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
index fb3bdc44775c..d95137304224 100644
--- a/fs/cifs/sess.c
+++ b/fs/cifs/sess.c
@@ -213,6 +213,9 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
 		chan->server = NULL;
 		goto out;
 	}
+	spin_lock(&cifs_tcp_ses_lock);
+	chan->server->is_channel = true;
+	spin_unlock(&cifs_tcp_ses_lock);
 
 	/*
 	 * We need to allocate the server crypto now as we will need
-- 
2.24.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] cifs: Fix lookup of SMB connections on multichannel
  2019-12-04 14:25 [PATCH] cifs: Fix lookup of SMB connections on multichannel Paulo Alcantara (SUSE)
@ 2019-12-04 17:55 ` Steve French
  0 siblings, 0 replies; 2+ messages in thread
From: Steve French @ 2019-12-04 17:55 UTC (permalink / raw)
  To: Paulo Alcantara (SUSE); +Cc: CIFS, Aurelien Aptel

tentatively merged to cifs-2.6.git for-next and buildbot github tree
pending more testing

On Wed, Dec 4, 2019 at 8:25 AM Paulo Alcantara (SUSE) <pc@cjr.nz> wrote:
>
> With the addition of SMB session channels, we introduced new TCP
> server pointers that have no sessions or tcons associated with them.
>
> In this case, when we started looking for TCP connections, we might
> end up picking session channel rather than the master connection,
> hence failing to get either a session or a tcon.
>
> In order to fix that, this patch introduces a new "is_channel" field
> to TCP_Server_Info structure so we can skip session channels during
> lookup of connections.
>
> Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
> Reviewed-by: Aurelien Aptel <aaptel@suse.com>
> ---
>  fs/cifs/cifsglob.h | 1 +
>  fs/cifs/connect.c  | 6 +++++-
>  fs/cifs/sess.c     | 3 +++
>  3 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index 5b976e01dd6b..fd0262ce5ad5 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -777,6 +777,7 @@ struct TCP_Server_Info {
>          */
>         int nr_targets;
>         bool noblockcnt; /* use non-blocking connect() */
> +       bool is_channel; /* if a session channel */
>  };
>
>  struct cifs_credits {
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 86d1baedf21c..05ea0e2b7e0e 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -2712,7 +2712,11 @@ cifs_find_tcp_session(struct smb_vol *vol)
>
>         spin_lock(&cifs_tcp_ses_lock);
>         list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) {
> -               if (!match_server(server, vol))
> +               /*
> +                * Skip ses channels since they're only handled in lower layers
> +                * (e.g. cifs_send_recv).
> +                */
> +               if (server->is_channel || !match_server(server, vol))
>                         continue;
>
>                 ++server->srv_count;
> diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
> index fb3bdc44775c..d95137304224 100644
> --- a/fs/cifs/sess.c
> +++ b/fs/cifs/sess.c
> @@ -213,6 +213,9 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
>                 chan->server = NULL;
>                 goto out;
>         }
> +       spin_lock(&cifs_tcp_ses_lock);
> +       chan->server->is_channel = true;
> +       spin_unlock(&cifs_tcp_ses_lock);
>
>         /*
>          * We need to allocate the server crypto now as we will need
> --
> 2.24.0
>


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-04 14:25 [PATCH] cifs: Fix lookup of SMB connections on multichannel Paulo Alcantara (SUSE)
2019-12-04 17:55 ` Steve French

Linux-CIFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-cifs/0 linux-cifs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-cifs linux-cifs/ https://lore.kernel.org/linux-cifs \
		linux-cifs@vger.kernel.org
	public-inbox-index linux-cifs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-cifs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git