diff mbox series

[CIFS] fix reconnect with SMB1 Unix Extensions

Message ID CAH2r5mu2LTRDPX7KbM3V_d7FybuPnvCMRd6YV3__H-7mn1N9uA@mail.gmail.com
State New
Headers show
Series [CIFS] fix reconnect with SMB1 Unix Extensions | expand

Commit Message

Steve French July 23, 2024, 5:07 a.m. UTC
Andrew had pointed out having problems with SMB1 Unix extensions to
Samba when investigating an unrelated problem, and when I tried it I
noticed a serious reconnect issue with the SMB1 Unix Extensions.

When mounting with the SMB1 Unix Extensions (e.g. mounts
to Samba with vers=1.0), cifs.ko reconnects no longer reset the
Unix Extensions (SetFSInfo SET_FILE_UNIX_BASIC) after tcon so most
operations (e.g. stat, ls, open, statfs) will fail continuously
with:
        "Operation not supported"
if the connection ever resets (e.g. due to brief network disconnect)

Fix attached

Comments

Steve French July 23, 2024, 10:50 p.m. UTC | #1
updated to add missing #ifdef


On Tue, Jul 23, 2024 at 12:07 AM Steve French <smfrench@gmail.com> wrote:
>
> Andrew had pointed out having problems with SMB1 Unix extensions to
> Samba when investigating an unrelated problem, and when I tried it I
> noticed a serious reconnect issue with the SMB1 Unix Extensions.
>
> When mounting with the SMB1 Unix Extensions (e.g. mounts
> to Samba with vers=1.0), cifs.ko reconnects no longer reset the
> Unix Extensions (SetFSInfo SET_FILE_UNIX_BASIC) after tcon so most
> operations (e.g. stat, ls, open, statfs) will fail continuously
> with:
>         "Operation not supported"
> if the connection ever resets (e.g. due to brief network disconnect)
>
> Fix attached
>
>
>
> --
> Thanks,
>
> Steve
diff mbox series

Patch

From 2a9b3eb1b0838cc99aafdc50e37138538d4593bb Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Mon, 22 Jul 2024 23:40:08 -0500
Subject: [PATCH] cifs: fix reconnect with SMB1 UNIX Extensions

When mounting with the SMB1 Unix Extensions (e.g. mounts
to Samba with vers=1.0), reconnects no longer reset the
Unix Extensions (SetFSInfo SET_FILE_UNIX_BASIC) after tcon so most
operations (e.g. stat, ls, open, statfs) will fail continuously
with:
        "Operation not supported"
if the connection ever resets (e.g. due to brief network disconnect)

Cc: stable@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/smb/client/connect.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 7a16e12f5da8..b66d8b03a389 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -3807,8 +3807,21 @@  CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
 		else
 			tcon->Flags = 0;
 		cifs_dbg(FYI, "Tcon flags: 0x%x\n", tcon->Flags);
-	}
 
+		/*
+		 * reset_cifs_unix_caps calls QFSInfo which requires
+		 * need_reconnect to be false, but we would not need to call
+		 * reset_caps if this were not a reconnect case so must check
+		 * need_reconnect flag here.  The caller will also clear
+		 * need_reconnect when tcon was successful but needed to be
+		 * cleared earlier in the case of unix extensions reconnect
+		 */
+		if (tcon->need_reconnect && tcon->unix_ext) {
+			cifs_dbg(FYI, "resetting caps for %s\n", tcon->tree_name);
+			tcon->need_reconnect = false;
+			reset_cifs_unix_caps(xid, tcon, NULL, NULL);
+		}
+	}
 	cifs_buf_release(smb_buffer);
 	return rc;
 }
-- 
2.43.0