Commit 5a5dcfd1 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag '5.18-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs client fixes from Steve French:

 - reconnect fixes: one for DFS and one to avoid a reconnect race

 - small change to deal with upcoming behavior change of list iterators

* tag '5.18-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: update internal module number
  cifs: force new session setup and tcon for dfs
  cifs: remove check of list iterator against head past the loop body
  cifs: fix potential race with cifsd thread
parents 73b193f2 7cd1cc41
...@@ -153,5 +153,5 @@ extern const struct export_operations cifs_export_ops; ...@@ -153,5 +153,5 @@ extern const struct export_operations cifs_export_ops;
#endif /* CONFIG_CIFS_NFSD_EXPORT */ #endif /* CONFIG_CIFS_NFSD_EXPORT */
#define SMB3_PRODUCT_BUILD 35 #define SMB3_PRODUCT_BUILD 35
#define CIFS_VERSION "2.35" #define CIFS_VERSION "2.36"
#endif /* _CIFSFS_H */ #endif /* _CIFSFS_H */
...@@ -453,9 +453,7 @@ static int reconnect_target_unlocked(struct TCP_Server_Info *server, struct dfs_ ...@@ -453,9 +453,7 @@ static int reconnect_target_unlocked(struct TCP_Server_Info *server, struct dfs_
return rc; return rc;
} }
static int static int reconnect_dfs_server(struct TCP_Server_Info *server)
reconnect_dfs_server(struct TCP_Server_Info *server,
bool mark_smb_session)
{ {
int rc = 0; int rc = 0;
const char *refpath = server->current_fullpath + 1; const char *refpath = server->current_fullpath + 1;
...@@ -479,7 +477,12 @@ reconnect_dfs_server(struct TCP_Server_Info *server, ...@@ -479,7 +477,12 @@ reconnect_dfs_server(struct TCP_Server_Info *server,
if (!cifs_tcp_ses_needs_reconnect(server, num_targets)) if (!cifs_tcp_ses_needs_reconnect(server, num_targets))
return 0; return 0;
cifs_mark_tcp_ses_conns_for_reconnect(server, mark_smb_session); /*
* Unconditionally mark all sessions & tcons for reconnect as we might be connecting to a
* different server or share during failover. It could be improved by adding some logic to
* only do that in case it connects to a different server or share, though.
*/
cifs_mark_tcp_ses_conns_for_reconnect(server, true);
cifs_abort_connection(server); cifs_abort_connection(server);
...@@ -537,7 +540,7 @@ int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session) ...@@ -537,7 +540,7 @@ int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session)
} }
spin_unlock(&cifs_tcp_ses_lock); spin_unlock(&cifs_tcp_ses_lock);
return reconnect_dfs_server(server, mark_smb_session); return reconnect_dfs_server(server);
} }
#else #else
int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session) int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session)
...@@ -4465,7 +4468,7 @@ static int tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *tco ...@@ -4465,7 +4468,7 @@ static int tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *tco
*/ */
if (rc && server->current_fullpath != server->origin_fullpath) { if (rc && server->current_fullpath != server->origin_fullpath) {
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); dfs_cache_free_tgts(tl);
......
...@@ -896,7 +896,7 @@ map_and_check_smb_error(struct mid_q_entry *mid, bool logErr) ...@@ -896,7 +896,7 @@ map_and_check_smb_error(struct mid_q_entry *mid, bool logErr)
if (class == ERRSRV && code == ERRbaduid) { if (class == ERRSRV && code == ERRbaduid) {
cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n", cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
code); code);
cifs_reconnect(mid->server, false); cifs_signal_cifsd_for_reconnect(mid->server, false);
} }
} }
......
...@@ -150,16 +150,18 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr) ...@@ -150,16 +150,18 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
struct smb2_transform_hdr *thdr = struct smb2_transform_hdr *thdr =
(struct smb2_transform_hdr *)buf; (struct smb2_transform_hdr *)buf;
struct cifs_ses *ses = NULL; struct cifs_ses *ses = NULL;
struct cifs_ses *iter;
/* decrypt frame now that it is completely read in */ /* decrypt frame now that it is completely read in */
spin_lock(&cifs_tcp_ses_lock); spin_lock(&cifs_tcp_ses_lock);
list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) { list_for_each_entry(iter, &srvr->smb_ses_list, smb_ses_list) {
if (ses->Suid == le64_to_cpu(thdr->SessionId)) if (iter->Suid == le64_to_cpu(thdr->SessionId)) {
ses = iter;
break; break;
} }
}
spin_unlock(&cifs_tcp_ses_lock); spin_unlock(&cifs_tcp_ses_lock);
if (list_entry_is_head(ses, &srvr->smb_ses_list, if (!ses) {
smb_ses_list)) {
cifs_dbg(VFS, "no decryption - session id not found\n"); cifs_dbg(VFS, "no decryption - session id not found\n");
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment