All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifs: include regular shares to the list of unshared tcp servers
@ 2021-07-02 17:17 Paulo Alcantara
  2021-07-05 10:51 ` Aurélien Aptel
  0 siblings, 1 reply; 3+ messages in thread
From: Paulo Alcantara @ 2021-07-02 17:17 UTC (permalink / raw)
  To: linux-cifs, smfrench; +Cc: Paulo Alcantara

We need to make regular shares to also not share tcp servers because
we might have both regular and dfs mounts connecting to same server.

Fixes: f3c852b0b0fc ("cifs: do not share tcp servers with dfs mounts")
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
---
 fs/cifs/connect.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 944fb92f50c7..d9471575935f 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3382,6 +3382,12 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
 	char *oldmnt = NULL;
 	bool ref_server = false;
 
+	/*
+	 * Do not share tcp servers when CONFIG_CIFS_DFS_UPCALL option is enabled to properly handle
+	 * reconnect of regular and dfs shares when they were connected to same server.
+	 */
+	ctx->nosharesock = true;
+
 	rc = mount_get_conns(ctx, cifs_sb, &xid, &server, &ses, &tcon);
 	/*
 	 * If called with 'nodfs' mount option, then skip DFS resolving.  Otherwise unconditionally
@@ -3403,8 +3409,6 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
 			goto error;
 	}
 
-	ctx->nosharesock = true;
-
 	/* Get path of DFS root */
 	ref_path = build_unc_path_to_root(ctx, cifs_sb, false);
 	if (IS_ERR(ref_path)) {
-- 
2.32.0


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

* Re: [PATCH] cifs: include regular shares to the list of unshared tcp servers
  2021-07-02 17:17 [PATCH] cifs: include regular shares to the list of unshared tcp servers Paulo Alcantara
@ 2021-07-05 10:51 ` Aurélien Aptel
  2021-07-05 14:37   ` Paulo Alcantara
  0 siblings, 1 reply; 3+ messages in thread
From: Aurélien Aptel @ 2021-07-05 10:51 UTC (permalink / raw)
  To: Paulo Alcantara, linux-cifs, smfrench; +Cc: Paulo Alcantara

Paulo Alcantara <pc@cjr.nz> writes:
> We need to make regular shares to also not share tcp servers because
> we might have both regular and dfs mounts connecting to same server.

So with this change we never reuse tcp connections, and nosharesock
because the default mount option for all cases. We might as well remove
all the code for searching/matching/reusing tcp connection, smb session,
tree connects.

That doesn't seem good. If dfs connections are made with the nosharesock
flag they should not be reused already no?

Cheers,
-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)


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

* Re: [PATCH] cifs: include regular shares to the list of unshared tcp servers
  2021-07-05 10:51 ` Aurélien Aptel
@ 2021-07-05 14:37   ` Paulo Alcantara
  0 siblings, 0 replies; 3+ messages in thread
From: Paulo Alcantara @ 2021-07-05 14:37 UTC (permalink / raw)
  To: Aurélien Aptel, linux-cifs, smfrench

Aurélien Aptel <aaptel@suse.com> writes:

> Paulo Alcantara <pc@cjr.nz> writes:
>> We need to make regular shares to also not share tcp servers because
>> we might have both regular and dfs mounts connecting to same server.
>
> So with this change we never reuse tcp connections, and nosharesock
> because the default mount option for all cases. We might as well remove
> all the code for searching/matching/reusing tcp connection, smb session,
> tree connects.

Sounds like a good idea, yes.  Of course, if we really want to do this
regardless CONFIG_CIFS_DFS_UPCALL, it would probably be better off doing
it in a separate series.

> That doesn't seem good. If dfs connections are made with the nosharesock
> flag they should not be reused already no?

The previous version only made sure to not share tcp servers among DFS
shares, however, we must do it for all shares when we have
CONFIG_CIFS_DFS_UPCALL option enabled.

Without this change, the following would occur:

mount //dfsroot/dfs (new tcp)
mount //dfsroot/share (reuse tcp because


	rc = mount_get_conns(ctx, cifs_sb, &xid, &server, &ses, &tcon);
	/*
	 * If called with 'nodfs' mount option, then skip DFS resolving.  Otherwise unconditionally
	 * try to get an DFS referral (even cached) to determine whether it is an DFS mount.
	 *
	 * Skip prefix path to provide support for DFS referrals from w2k8 servers which don't seem
	 * to respond with PATH_NOT_COVERED to requests that include the prefix.
	 */
	if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS) ||
	    dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb), ctx->UNC + 1, NULL,
			   NULL)) {
		if (rc)
			goto error;
		/* Check if it is fully accessible and then mount it */
		rc = is_path_remote(cifs_sb, ctx, xid, server, tcon);
		if (!rc)
			goto out;
		if (rc != -EREMOTE)
			goto error;
	}

would get executed in cifs_mount() and we only set nosharesock after that)

With this patch:

mount //dfsroot/dfs (new tcp)
mount //dfsroot/share (new tcp)

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

end of thread, other threads:[~2021-07-05 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 17:17 [PATCH] cifs: include regular shares to the list of unshared tcp servers Paulo Alcantara
2021-07-05 10:51 ` Aurélien Aptel
2021-07-05 14:37   ` Paulo Alcantara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.