Skip to contentSkip to conversation

cifs: do not query ifaces on smb1 mounts

PATCH Superseded Paulo Alcantara 3 participants 8 messages Jan 9, 2023 – Jan 11, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: do not query ifaces on smb1 mounts

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")
---
 fs/cifs/cifsglob.h |  1 +
 fs/cifs/connect.c  | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +1 -0
index cfdd5bf701a1..931e9d5b21f4 100644
@@ -1240,6 +1240,7 @@ struct cifs_tcon {
 #ifdef CONFIG_CIFS_DFS_UPCALL
 	struct list_head ulist; /* cache update list */
 #endif
+	bool			iface_query_poll:1;
 	struct delayed_work	query_interfaces; /* query interfaces workqueue job */
 };
 
fs/cifs/connect.c +12 -6
index d371259d6808..164beb365bfe 100644
@@ -2366,7 +2366,10 @@ cifs_put_tcon(struct cifs_tcon *tcon)
 	spin_unlock(&cifs_tcp_ses_lock);
 
 	/* cancel polling of interfaces */
-	cancel_delayed_work_sync(&tcon->query_interfaces);
+	if (tcon->iface_query_poll) {
+		tcon->iface_query_poll = false;
+		cancel_delayed_work_sync(&tcon->query_interfaces);
+	}
 
 	if (tcon->use_witness) {
 		int rc;
@@ -2606,11 +2609,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
 	INIT_LIST_HEAD(&tcon->pending_opens);
 	tcon->status = TID_GOOD;
 
-	/* schedule query interfaces poll */
-	INIT_DELAYED_WORK(&tcon->query_interfaces,
-			  smb2_query_server_interfaces);
-	queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-			   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	if (!is_smb1_server(ses->server)) {
+		/* schedule query interfaces poll */
+		tcon->iface_query_poll = true;
+		INIT_DELAYED_WORK(&tcon->query_interfaces,
+				  smb2_query_server_interfaces);
+		queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
+				   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	}
 
 	spin_lock(&cifs_tcp_ses_lock);
 	list_add(&tcon->tcon_list, &ses->tcon_list);
Signature · 1 line
2.39.0
reviewer
#1 lore raw
Quoted 20 lines · Paulo Alcantara

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")
---
  fs/cifs/cifsglob.h |  1 +
  fs/cifs/connect.c  | 18 ++++++++++++------
  2 files changed, 13 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index cfdd5bf701a1..931e9d5b21f4 100644

fs/cifs/cifsglob.h struct cifs_tcon { · line 1243

Quoted 4 lines
fs/cifs/cifsglob.h +1 -0
@@ -1240,6 +1240,7 @@ struct cifs_tcon {
  #ifdef CONFIG_CIFS_DFS_UPCALL
  	struct list_head ulist; /* cache update list */
  #endif
+	bool			iface_query_poll:1;

Why add such a special-case flag, instead of simply checking the dialect, or (betyter) the server's multichannel capability attribute?

It seems fragile and untestable to set a flag like this, especially in the tcon, which has nothing to do with supporting the multichannel fsctl.

Tom.

Quoted 39 lines
fs/cifs/cifsglob.h +0 -0
  	struct delayed_work	query_interfaces; /* query interfaces workqueue job */
  };
 
fs/cifs/connect.c +12 -6
index d371259d6808..164beb365bfe 100644
@@ -2366,7 +2366,10 @@ cifs_put_tcon(struct cifs_tcon *tcon)
  	spin_unlock(&cifs_tcp_ses_lock);
 
  	/* cancel polling of interfaces */
-	cancel_delayed_work_sync(&tcon->query_interfaces);
+	if (tcon->iface_query_poll) {
+		tcon->iface_query_poll = false;
+		cancel_delayed_work_sync(&tcon->query_interfaces);
+	}
 
  	if (tcon->use_witness) {
  		int rc;
@@ -2606,11 +2609,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
  	INIT_LIST_HEAD(&tcon->pending_opens);
  	tcon->status = TID_GOOD;
 
-	/* schedule query interfaces poll */
-	INIT_DELAYED_WORK(&tcon->query_interfaces,
-			  smb2_query_server_interfaces);
-	queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-			   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	if (!is_smb1_server(ses->server)) {
+		/* schedule query interfaces poll */
+		tcon->iface_query_poll = true;
+		INIT_DELAYED_WORK(&tcon->query_interfaces,
+				  smb2_query_server_interfaces);
+		queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
+				   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	}
 
  	spin_lock(&cifs_tcp_ses_lock);
  	list_add(&tcon->tcon_list, &ses->tcon_list);
#2 lore raw
Quoted 29 lines · Tom Talpey
Quoted 20 lines · Paulo Alcantara

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")
---
  fs/cifs/cifsglob.h |  1 +
  fs/cifs/connect.c  | 18 ++++++++++++------
  2 files changed, 13 insertions(+), 6 deletions(-)
fs/cifs/cifsglob.h +0 -0
index cfdd5bf701a1..931e9d5b21f4 100644

fs/cifs/cifsglob.h struct cifs_tcon { · line 1243

Quoted 4 lines
fs/cifs/cifsglob.h +1 -0
@@ -1240,6 +1240,7 @@ struct cifs_tcon {
  #ifdef CONFIG_CIFS_DFS_UPCALL
  	struct list_head ulist; /* cache update list */
  #endif
+	bool			iface_query_poll:1;

Why add such a special-case flag, instead of simply checking the dialect, or (betyter) the server's multichannel capability attribute?

Quoted 3 lines

It seems fragile and untestable to set a flag like this, especially in the tcon, which has nothing to do with supporting the multichannel fsctl.

Makes sense. I'll fix it in v2.

Thanks.

#3 lore raw

PATCH v2 1/1 cifs: do not query ifaces on smb1 mounts

In reply to Paulo Alcantara

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")

---
v1 -> v2:
remove cifs_tcon::iface_query_poll and then check version and server's capability multichannel

 fs/cifs/connect.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/cifs/connect.c +6 -3
index d371259d6808..b2a04b4e89a5 100644
@@ -2606,11 +2606,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
 	INIT_LIST_HEAD(&tcon->pending_opens);
 	tcon->status = TID_GOOD;
 
-	/* schedule query interfaces poll */
 	INIT_DELAYED_WORK(&tcon->query_interfaces,
 			  smb2_query_server_interfaces);
-	queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-			   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	if (ses->server->dialect >= SMB30_PROT_ID &&
+	    (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
+		/* schedule query interfaces poll */
+		queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
+				   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	}
 
 	spin_lock(&cifs_tcp_ses_lock);
 	list_add(&tcon->tcon_list, &ses->tcon_list);
Signature · 1 line
2.39.0
#4 lore raw

tentatively merged into cifs-2.6.git for-next pending testing and additional reviews

Quoted 45 lines · Paulo Alcantara

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")

---
v1 -> v2:
remove cifs_tcon::iface_query_poll and then check version and server's capability multichannel

 fs/cifs/connect.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
fs/cifs/connect.c +6 -4
index d371259d6808..b2a04b4e89a5 100644
@@ -2606,11 +2606,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
        INIT_LIST_HEAD(&tcon->pending_opens);
        tcon->status = TID_GOOD;
 
-       /* schedule query interfaces poll */
        INIT_DELAYED_WORK(&tcon->query_interfaces,
                          smb2_query_server_interfaces);
-       queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-                          (SMB_INTERFACE_POLL_INTERVAL * HZ));
+       if (ses->server->dialect >= SMB30_PROT_ID &&
+           (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
+               /* schedule query interfaces poll */
+               queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
+                                  (SMB_INTERFACE_POLL_INTERVAL * HZ));
+       }
 
        spin_lock(&cifs_tcp_ses_lock);
        list_add(&tcon->tcon_list, &ses->tcon_list);
--

2.39.0

Signature · 3 lines
Thanks,

Steve
reviewer Reviewed-by on v2 1/1
#5 lore raw
In reply to Paulo Alcantara
Quoted 24 lines · Paulo Alcantara

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")

---
v1 -> v2:
remove cifs_tcon::iface_query_poll and then check version and server's capability multichannel

  fs/cifs/connect.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
fs/cifs/connect.c +0 -0
index d371259d6808..b2a04b4e89a5 100644

fs/cifs/connect.c cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) · line 2611

Quoted 9 lines
fs/cifs/connect.c +1 -3
@@ -2606,11 +2606,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
  	INIT_LIST_HEAD(&tcon->pending_opens);
  	tcon->status = TID_GOOD;
 
-	/* schedule query interfaces poll */
  	INIT_DELAYED_WORK(&tcon->query_interfaces,
  			  smb2_query_server_interfaces);
-	queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-			   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	if (ses->server->dialect >= SMB30_PROT_ID &&

The dialect test is actually unnecessary, because the server global capability, indicating the support, is what's important. But it's harmless to be explicit, so...

LGTM.

Quoted 8 lines
fs/cifs/connect.c +5 -0
+	    (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
+		/* schedule query interfaces poll */
+		queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
+				   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	}
 
  	spin_lock(&cifs_tcp_ses_lock);
  	list_add(&tcon->tcon_list, &ses->tcon_list);
#6 lore raw
Quoted 29 lines · Tom Talpey
Quoted 28 lines · Paulo Alcantara

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")

---
v1 -> v2:
remove cifs_tcon::iface_query_poll and then check version and server's capability multichannel

  fs/cifs/connect.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)
fs/cifs/connect.c +0 -0
index d371259d6808..b2a04b4e89a5 100644
@@ -2606,11 +2606,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
  	INIT_LIST_HEAD(&tcon->pending_opens);
  	tcon->status = TID_GOOD;
  -	/* schedule query interfaces poll */
  	INIT_DELAYED_WORK(&tcon->query_interfaces,
Quoted 8 lines

fs/cifs/connect.c cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) · line 2611

Quoted 4 lines
fs/cifs/connect.c +1 -2
  			  smb2_query_server_interfaces);
-	queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-			   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	if (ses->server->dialect >= SMB30_PROT_ID &&

The dialect test is actually unnecessary, because the server global capability, indicating the support, is what's important. But it's harmless to be explicit, so..

The dialect test is still necessary, otherwise we'd end up mixing SMB2_GLOBAL_CAP_MULTI_CHANNEL with CAP_LARGE_FILES[1] and then scheduling the worker for smb1 mounts.

I quickly tested it and the global cap test passed for smb1 mount due to CAP_LARGE_FILES being set.

[1] https://git.cjr.nz/linux.git/tree/fs/cifs/cifspdu.h#n533

Quoted 12 lines

LGTM.

Quoted 7 lines
fs/cifs/connect.c +5 -0
+	    (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
+		/* schedule query interfaces poll */
+		queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
+				   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	}
    	spin_lock(&cifs_tcp_ses_lock);
  	list_add(&tcon->tcon_list, &ses->tcon_list);
reviewer
#7 lore raw
Quoted 39 lines · Paulo Alcantara
Quoted 29 lines · Tom Talpey
Quoted 28 lines · Paulo Alcantara

Users have reported the following error on every 600 seconds (SMB_INTERFACE_POLL_INTERVAL) when mounting SMB1 shares:

CIFS: VFS: \\srv\share error -5 on ioctl to get interface list

It's supported only by SMB2+, so do not query network interfaces on SMB1 mounts.

Fixes 6e1c1c08cdf3 ("cifs: periodically query network interfaces from server")

---
v1 -> v2:
remove cifs_tcon::iface_query_poll and then check version and server's capability multichannel

   fs/cifs/connect.c | 9 ++++++---
   1 file changed, 6 insertions(+), 3 deletions(-)
fs/cifs/connect.c +0 -0
index d371259d6808..b2a04b4e89a5 100644
@@ -2606,11 +2606,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
   	INIT_LIST_HEAD(&tcon->pending_opens);
   	tcon->status = TID_GOOD;
   -	/* schedule query interfaces poll */
   	INIT_DELAYED_WORK(&tcon->query_interfaces,
Quoted 8 lines

fs/cifs/connect.c cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx) · line 2611

Quoted 4 lines
fs/cifs/connect.c +1 -2
   			  smb2_query_server_interfaces);
-	queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
-			   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	if (ses->server->dialect >= SMB30_PROT_ID &&

The dialect test is actually unnecessary, because the server global capability, indicating the support, is what's important. But it's harmless to be explicit, so..

Quoted 1 line

The dialect test is still necessary, otherwise we'd end up mixing SMB2_GLOBAL_CAP_MULTI_CHANNEL with CAP_LARGE_FILES[1] and then scheduling the worker for smb1 mounts.

Oh, yuck.

OK.

Quoted 19 lines

I quickly tested it and the global cap test passed for smb1 mount due to CAP_LARGE_FILES being set.

[1] https://git.cjr.nz/linux.git/tree/fs/cifs/cifspdu.h#n533

Quoted 12 lines

LGTM.

Quoted 7 lines
fs/cifs/connect.c +5 -0
+	    (ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
+		/* schedule query interfaces poll */
+		queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
+				   (SMB_INTERFACE_POLL_INTERVAL * HZ));
+	}
     	spin_lock(&cifs_tcp_ses_lock);
   	list_add(&tcon->tcon_list, &ses->tcon_list);