Skip to content

Commit ba978e8

Browse files
sprasad-microsoftSteve French
authored andcommitted
cifs: cifs_ses_mark_for_reconnect should also update reconnect bits
Recent restructuring of cifs_reconnect introduced a helper func named cifs_ses_mark_for_reconnect, which updates the state of tcp session for all the channels of a session for reconnect. However, this does not update the session state and chans_need_reconnect bitmask. This change fixes that. Also, cifs_mark_tcp_sess_for_reconnect should mark set the bitmask for all channels when the whole session is marked for reconnect. Fixed that here too. Signed-off-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 47de760 commit ba978e8

File tree

6 files changed

+14
-29
lines changed

6 files changed

+14
-29
lines changed

fs/cifs/cifs_swn.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,11 @@ static int cifs_swn_resource_state_changed(struct cifs_swn_reg *swnreg, const ch
396396
switch (state) {
397397
case CIFS_SWN_RESOURCE_STATE_UNAVAILABLE:
398398
cifs_dbg(FYI, "%s: resource name '%s' become unavailable\n", __func__, name);
399-
cifs_ses_mark_for_reconnect(swnreg->tcon->ses);
399+
cifs_reconnect(swnreg->tcon->ses->server, true);
400400
break;
401401
case CIFS_SWN_RESOURCE_STATE_AVAILABLE:
402402
cifs_dbg(FYI, "%s: resource name '%s' become available\n", __func__, name);
403-
cifs_ses_mark_for_reconnect(swnreg->tcon->ses);
403+
cifs_reconnect(swnreg->tcon->ses->server, true);
404404
break;
405405
case CIFS_SWN_RESOURCE_STATE_UNKNOWN:
406406
cifs_dbg(FYI, "%s: resource name '%s' changed to unknown state\n", __func__, name);
@@ -498,10 +498,7 @@ static int cifs_swn_reconnect(struct cifs_tcon *tcon, struct sockaddr_storage *a
498498
goto unlock;
499499
}
500500

501-
spin_lock(&cifs_tcp_ses_lock);
502-
if (tcon->ses->server->tcpStatus != CifsExiting)
503-
tcon->ses->server->tcpStatus = CifsNeedReconnect;
504-
spin_unlock(&cifs_tcp_ses_lock);
501+
cifs_reconnect(tcon->ses->server, false);
505502

506503
unlock:
507504
mutex_unlock(&tcon->ses->server->srv_mutex);

fs/cifs/cifsproto.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ extern int SendReceiveBlockingLock(const unsigned int xid,
131131
struct smb_hdr *in_buf ,
132132
struct smb_hdr *out_buf,
133133
int *bytes_returned);
134+
void
135+
cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
136+
bool mark_smb_session);
134137
extern int cifs_reconnect(struct TCP_Server_Info *server,
135138
bool mark_smb_session);
136139
extern int checkSMB(char *buf, unsigned int len, struct TCP_Server_Info *srvr);

fs/cifs/connect.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static void cifs_resolve_server(struct work_struct *work)
168168
* @server needs to be previously set to CifsNeedReconnect.
169169
*
170170
*/
171-
static void
171+
void
172172
cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
173173
bool mark_smb_session)
174174
{
@@ -197,7 +197,10 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
197197
if (!mark_smb_session && cifs_chan_needs_reconnect(ses, server))
198198
goto next_session;
199199

200-
cifs_chan_set_need_reconnect(ses, server);
200+
if (mark_smb_session)
201+
CIFS_SET_ALL_CHANS_NEED_RECONNECT(ses);
202+
else
203+
cifs_chan_set_need_reconnect(ses, server);
201204

202205
/* If all channels need reconnect, then tcon needs reconnect */
203206
if (!mark_smb_session && !CIFS_ALL_CHANS_NEED_RECONNECT(ses))
@@ -4396,7 +4399,7 @@ static int tree_connect_dfs_target(const unsigned int xid, struct cifs_tcon *tco
43964399
*/
43974400
if (rc && server->current_fullpath != server->origin_fullpath) {
43984401
server->current_fullpath = server->origin_fullpath;
4399-
cifs_ses_mark_for_reconnect(tcon->ses);
4402+
cifs_reconnect(tcon->ses->server, true);
44004403
}
44014404

44024405
dfs_cache_free_tgts(tl);

fs/cifs/dfs_cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +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-
cifs_ses_mark_for_reconnect(tcon->ses);
1358+
cifs_reconnect(tcon->ses->server, true);
13591359
}
13601360

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

fs/cifs/netmisc.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +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-
spin_lock(&cifs_tcp_ses_lock);
900-
if (mid->server->tcpStatus != CifsExiting)
901-
mid->server->tcpStatus = CifsNeedReconnect;
902-
spin_unlock(&cifs_tcp_ses_lock);
899+
cifs_reconnect(mid->server, false);
903900
}
904901
}
905902

fs/cifs/sess.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -366,21 +366,6 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
366366
return rc;
367367
}
368368

369-
/* Mark all session channels for reconnect */
370-
void cifs_ses_mark_for_reconnect(struct cifs_ses *ses)
371-
{
372-
int i;
373-
374-
spin_lock(&cifs_tcp_ses_lock);
375-
spin_lock(&ses->chan_lock);
376-
for (i = 0; i < ses->chan_count; i++) {
377-
if (ses->chans[i].server->tcpStatus != CifsExiting)
378-
ses->chans[i].server->tcpStatus = CifsNeedReconnect;
379-
}
380-
spin_unlock(&ses->chan_lock);
381-
spin_unlock(&cifs_tcp_ses_lock);
382-
}
383-
384369
static __u32 cifs_ssetup_hdr(struct cifs_ses *ses,
385370
struct TCP_Server_Info *server,
386371
SESSION_SETUP_ANDX *pSMB)

0 commit comments

Comments
 (0)