Skip to content

Commit 5a5dcfd

Browse files
committed
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
2 parents 73b193f + 7cd1cc4 commit 5a5dcfd

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

fs/cifs/cifsfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,5 @@ extern const struct export_operations cifs_export_ops;
153153
#endif /* CONFIG_CIFS_NFSD_EXPORT */
154154

155155
#define SMB3_PRODUCT_BUILD 35
156-
#define CIFS_VERSION "2.35"
156+
#define CIFS_VERSION "2.36"
157157
#endif /* _CIFSFS_H */

fs/cifs/connect.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,7 @@ static int reconnect_target_unlocked(struct TCP_Server_Info *server, struct dfs_
453453
return rc;
454454
}
455455

456-
static int
457-
reconnect_dfs_server(struct TCP_Server_Info *server,
458-
bool mark_smb_session)
456+
static int reconnect_dfs_server(struct TCP_Server_Info *server)
459457
{
460458
int rc = 0;
461459
const char *refpath = server->current_fullpath + 1;
@@ -479,7 +477,12 @@ reconnect_dfs_server(struct TCP_Server_Info *server,
479477
if (!cifs_tcp_ses_needs_reconnect(server, num_targets))
480478
return 0;
481479

482-
cifs_mark_tcp_ses_conns_for_reconnect(server, mark_smb_session);
480+
/*
481+
* Unconditionally mark all sessions & tcons for reconnect as we might be connecting to a
482+
* different server or share during failover. It could be improved by adding some logic to
483+
* only do that in case it connects to a different server or share, though.
484+
*/
485+
cifs_mark_tcp_ses_conns_for_reconnect(server, true);
483486

484487
cifs_abort_connection(server);
485488

@@ -537,7 +540,7 @@ int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session)
537540
}
538541
spin_unlock(&cifs_tcp_ses_lock);
539542

540-
return reconnect_dfs_server(server, mark_smb_session);
543+
return reconnect_dfs_server(server);
541544
}
542545
#else
543546
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
44654468
*/
44664469
if (rc && server->current_fullpath != server->origin_fullpath) {
44674470
server->current_fullpath = server->origin_fullpath;
4468-
cifs_reconnect(tcon->ses->server, true);
4471+
cifs_signal_cifsd_for_reconnect(server, true);
44694472
}
44704473

44714474
dfs_cache_free_tgts(tl);

fs/cifs/netmisc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ map_and_check_smb_error(struct mid_q_entry *mid, bool logErr)
896896
if (class == ERRSRV && code == ERRbaduid) {
897897
cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
898898
code);
899-
cifs_reconnect(mid->server, false);
899+
cifs_signal_cifsd_for_reconnect(mid->server, false);
900900
}
901901
}
902902

fs/cifs/smb2misc.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,18 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
150150
struct smb2_transform_hdr *thdr =
151151
(struct smb2_transform_hdr *)buf;
152152
struct cifs_ses *ses = NULL;
153+
struct cifs_ses *iter;
153154

154155
/* decrypt frame now that it is completely read in */
155156
spin_lock(&cifs_tcp_ses_lock);
156-
list_for_each_entry(ses, &srvr->smb_ses_list, smb_ses_list) {
157-
if (ses->Suid == le64_to_cpu(thdr->SessionId))
157+
list_for_each_entry(iter, &srvr->smb_ses_list, smb_ses_list) {
158+
if (iter->Suid == le64_to_cpu(thdr->SessionId)) {
159+
ses = iter;
158160
break;
161+
}
159162
}
160163
spin_unlock(&cifs_tcp_ses_lock);
161-
if (list_entry_is_head(ses, &srvr->smb_ses_list,
162-
smb_ses_list)) {
164+
if (!ses) {
163165
cifs_dbg(VFS, "no decryption - session id not found\n");
164166
return 1;
165167
}

0 commit comments

Comments
 (0)