diff mbox series

[1/2] cifs: fix potential race with cifsd thread

Message ID 20220331180151.5301-1-pc@cjr.nz (mailing list archive)
State New, archived
Headers show
Series [1/2] cifs: fix potential race with cifsd thread | expand

Commit Message

Paulo Alcantara March 31, 2022, 6:01 p.m. UTC
To avoid racing with demultiplex thread while it is handling data on
socket, use cifs_signal_cifsd_for_reconnect() helper for marking
current server to reconnect and let the demultiplex thread handle the
rest.

Fixes: dca65818c80c ("cifs: use a different reconnect helper for non-cifsd threads")
Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
---
 fs/cifs/connect.c | 2 +-
 fs/cifs/netmisc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Shyam Prasad N April 1, 2022, 3:23 a.m. UTC | #1
On Fri, Apr 1, 2022 at 4:38 AM Paulo Alcantara <pc@cjr.nz> wrote:
>
> To avoid racing with demultiplex thread while it is handling data on
> socket, use cifs_signal_cifsd_for_reconnect() helper for marking
> current server to reconnect and let the demultiplex thread handle the
> rest.
>
> Fixes: dca65818c80c ("cifs: use a different reconnect helper for non-cifsd threads")
> Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
> ---
>  fs/cifs/connect.c | 2 +-
>  fs/cifs/netmisc.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index ee3b7c15e884..3ca06bd88b6e 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -4465,7 +4465,7 @@ static int tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *tco
>          */
>         if (rc && server->current_fullpath != server->origin_fullpath) {
>                 server->current_fullpath = server->origin_fullpath;
> -               cifs_reconnect(tcon->ses->server, true);
> +               cifs_signal_cifsd_for_reconnect(server, true);
>         }
>
>         dfs_cache_free_tgts(tl);
> diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
> index ebe236b9d9f5..235aa1b395eb 100644
> --- a/fs/cifs/netmisc.c
> +++ b/fs/cifs/netmisc.c
> @@ -896,7 +896,7 @@ map_and_check_smb_error(struct mid_q_entry *mid, bool logErr)
>                 if (class == ERRSRV && code == ERRbaduid) {
>                         cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
>                                 code);
> -                       cifs_reconnect(mid->server, false);
> +                       cifs_signal_cifsd_for_reconnect(mid->server, false);
>                 }
>         }
>
> --
> 2.35.1
>

Oh. Did I miss these?
Looks good to me.

Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Paulo Alcantara April 1, 2022, 4:30 p.m. UTC | #2
Shyam Prasad N <nspmangalore@gmail.com> writes:

> Oh. Did I miss these?

Yep :-)
diff mbox series

Patch

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index ee3b7c15e884..3ca06bd88b6e 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -4465,7 +4465,7 @@  static int tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *tco
 	 */
 	if (rc && server->current_fullpath != server->origin_fullpath) {
 		server->current_fullpath = server->origin_fullpath;
-		cifs_reconnect(tcon->ses->server, true);
+		cifs_signal_cifsd_for_reconnect(server, true);
 	}
 
 	dfs_cache_free_tgts(tl);
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c
index ebe236b9d9f5..235aa1b395eb 100644
--- a/fs/cifs/netmisc.c
+++ b/fs/cifs/netmisc.c
@@ -896,7 +896,7 @@  map_and_check_smb_error(struct mid_q_entry *mid, bool logErr)
 		if (class == ERRSRV && code == ERRbaduid) {
 			cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
 				code);
-			cifs_reconnect(mid->server, false);
+			cifs_signal_cifsd_for_reconnect(mid->server, false);
 		}
 	}