Skip to content

Commit b38bfc7

Browse files
committed
Merge tag '5.16-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6
Pull cifs fixes from Steve French: "Three small cifs/smb3 fixes: two to address minor coverity issues and one cleanup" * tag '5.16-rc1-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: cifs: introduce cifs_ses_mark_for_reconnect() helper cifs: protect srv_count with cifs_tcp_ses_lock cifs: move debug print out of spinlock
2 parents a90af8f + 8ae87bb commit b38bfc7

File tree

5 files changed

+21
-34
lines changed

5 files changed

+21
-34
lines changed

fs/cifs/cifs_swn.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -393,26 +393,14 @@ static void cifs_put_swn_reg(struct cifs_swn_reg *swnreg)
393393

394394
static int cifs_swn_resource_state_changed(struct cifs_swn_reg *swnreg, const char *name, int state)
395395
{
396-
int i;
397-
398396
switch (state) {
399397
case CIFS_SWN_RESOURCE_STATE_UNAVAILABLE:
400398
cifs_dbg(FYI, "%s: resource name '%s' become unavailable\n", __func__, name);
401-
for (i = 0; i < swnreg->tcon->ses->chan_count; i++) {
402-
spin_lock(&GlobalMid_Lock);
403-
if (swnreg->tcon->ses->chans[i].server->tcpStatus != CifsExiting)
404-
swnreg->tcon->ses->chans[i].server->tcpStatus = CifsNeedReconnect;
405-
spin_unlock(&GlobalMid_Lock);
406-
}
399+
cifs_ses_mark_for_reconnect(swnreg->tcon->ses);
407400
break;
408401
case CIFS_SWN_RESOURCE_STATE_AVAILABLE:
409402
cifs_dbg(FYI, "%s: resource name '%s' become available\n", __func__, name);
410-
for (i = 0; i < swnreg->tcon->ses->chan_count; i++) {
411-
spin_lock(&GlobalMid_Lock);
412-
if (swnreg->tcon->ses->chans[i].server->tcpStatus != CifsExiting)
413-
swnreg->tcon->ses->chans[i].server->tcpStatus = CifsNeedReconnect;
414-
spin_unlock(&GlobalMid_Lock);
415-
}
403+
cifs_ses_mark_for_reconnect(swnreg->tcon->ses);
416404
break;
417405
case CIFS_SWN_RESOURCE_STATE_UNKNOWN:
418406
cifs_dbg(FYI, "%s: resource name '%s' changed to unknown state\n", __func__, name);

fs/cifs/cifsproto.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,7 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses)
599599
bool is_server_using_iface(struct TCP_Server_Info *server,
600600
struct cifs_server_iface *iface);
601601
bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface);
602+
void cifs_ses_mark_for_reconnect(struct cifs_ses *ses);
602603

603604
void extract_unc_hostname(const char *unc, const char **h, size_t *len);
604605
int copy_path_name(char *dst, const char *src);

fs/cifs/connect.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,8 +1452,10 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
14521452
tcp_ses->max_in_flight = 0;
14531453
tcp_ses->credits = 1;
14541454
if (primary_server) {
1455+
spin_lock(&cifs_tcp_ses_lock);
14551456
++primary_server->srv_count;
14561457
tcp_ses->primary_server = primary_server;
1458+
spin_unlock(&cifs_tcp_ses_lock);
14571459
}
14581460
init_waitqueue_head(&tcp_ses->response_q);
14591461
init_waitqueue_head(&tcp_ses->request_q);
@@ -4111,18 +4113,6 @@ cifs_prune_tlinks(struct work_struct *work)
41114113
}
41124114

41134115
#ifdef CONFIG_CIFS_DFS_UPCALL
4114-
static void mark_tcon_tcp_ses_for_reconnect(struct cifs_tcon *tcon)
4115-
{
4116-
int i;
4117-
4118-
for (i = 0; i < tcon->ses->chan_count; i++) {
4119-
spin_lock(&GlobalMid_Lock);
4120-
if (tcon->ses->chans[i].server->tcpStatus != CifsExiting)
4121-
tcon->ses->chans[i].server->tcpStatus = CifsNeedReconnect;
4122-
spin_unlock(&GlobalMid_Lock);
4123-
}
4124-
}
4125-
41264116
/* Update dfs referral path of superblock */
41274117
static int update_server_fullpath(struct TCP_Server_Info *server, struct cifs_sb_info *cifs_sb,
41284118
const char *target)
@@ -4299,7 +4289,7 @@ static int tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *tco
42994289
*/
43004290
if (rc && server->current_fullpath != server->origin_fullpath) {
43014291
server->current_fullpath = server->origin_fullpath;
4302-
mark_tcon_tcp_ses_for_reconnect(tcon);
4292+
cifs_ses_mark_for_reconnect(tcon->ses);
43034293
}
43044294

43054295
dfs_cache_free_tgts(tl);

fs/cifs/dfs_cache.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,12 +1355,7 @@ static void mark_for_reconnect_if_needed(struct cifs_tcon *tcon, struct dfs_cach
13551355
}
13561356

13571357
cifs_dbg(FYI, "%s: no cached or matched targets. mark dfs share for reconnect.\n", __func__);
1358-
for (i = 0; i < tcon->ses->chan_count; i++) {
1359-
spin_lock(&GlobalMid_Lock);
1360-
if (tcon->ses->chans[i].server->tcpStatus != CifsExiting)
1361-
tcon->ses->chans[i].server->tcpStatus = CifsNeedReconnect;
1362-
spin_unlock(&GlobalMid_Lock);
1363-
}
1358+
cifs_ses_mark_for_reconnect(tcon->ses);
13641359
}
13651360

13661361
/* Refresh dfs referral of tcon and mark it for reconnect if needed */

fs/cifs/sess.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses)
9595
}
9696

9797
if (!(ses->server->capabilities & SMB2_GLOBAL_CAP_MULTI_CHANNEL)) {
98-
cifs_dbg(VFS, "server %s does not support multichannel\n", ses->server->hostname);
9998
ses->chan_max = 1;
10099
spin_unlock(&ses->chan_lock);
100+
cifs_dbg(VFS, "server %s does not support multichannel\n", ses->server->hostname);
101101
return 0;
102102
}
103103
spin_unlock(&ses->chan_lock);
@@ -318,6 +318,19 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
318318
return rc;
319319
}
320320

321+
/* Mark all session channels for reconnect */
322+
void cifs_ses_mark_for_reconnect(struct cifs_ses *ses)
323+
{
324+
int i;
325+
326+
for (i = 0; i < ses->chan_count; i++) {
327+
spin_lock(&GlobalMid_Lock);
328+
if (ses->chans[i].server->tcpStatus != CifsExiting)
329+
ses->chans[i].server->tcpStatus = CifsNeedReconnect;
330+
spin_unlock(&GlobalMid_Lock);
331+
}
332+
}
333+
321334
static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, SESSION_SETUP_ANDX *pSMB)
322335
{
323336
__u32 capabilities = 0;

0 commit comments

Comments
 (0)