Skip to content

Commit dd3cd87

Browse files
sprasad-microsoftSteve French
authored and
Steve French
committed
cifs: use new enum for ses_status
ses->status today shares statusEnum with server->tcpStatus. This has been confusing, and tcon->status has deviated to use a new enum. Follow suit and use new enum for ses_status as well. Signed-off-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 1a6a41d commit dd3cd87

File tree

8 files changed

+39
-32
lines changed

8 files changed

+39
-32
lines changed

fs/cifs/cifs_debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
387387
(ses->serverNOS == NULL)) {
388388
seq_printf(m, "\n\t%d) Address: %s Uses: %d Capability: 0x%x\tSession Status: %d ",
389389
i, ses->ip_addr, ses->ses_count,
390-
ses->capabilities, ses->status);
390+
ses->capabilities, ses->ses_status);
391391
if (ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST)
392392
seq_printf(m, "Guest ");
393393
else if (ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
@@ -399,7 +399,7 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
399399
"\n\tSMB session status: %d ",
400400
i, ses->ip_addr, ses->serverDomain,
401401
ses->ses_count, ses->serverOS, ses->serverNOS,
402-
ses->capabilities, ses->status);
402+
ses->capabilities, ses->ses_status);
403403
}
404404

405405
seq_printf(m, "\n\tSecurity type: %s ",

fs/cifs/cifsglob.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,23 @@
106106
* CIFS vfs client Status information (based on what we know.)
107107
*/
108108

109-
/* associated with each tcp and smb session */
109+
/* associated with each connection */
110110
enum statusEnum {
111111
CifsNew = 0,
112112
CifsGood,
113113
CifsExiting,
114114
CifsNeedReconnect,
115115
CifsNeedNegotiate,
116116
CifsInNegotiate,
117-
CifsNeedSessSetup,
118-
CifsInSessSetup,
117+
};
118+
119+
/* associated with each smb session */
120+
enum ses_status_enum {
121+
SES_NEW = 0,
122+
SES_GOOD,
123+
SES_EXITING,
124+
SES_NEED_RECON,
125+
SES_IN_SETUP
119126
};
120127

121128
/* associated with each tree connection to the server */
@@ -930,7 +937,7 @@ struct cifs_ses {
930937
struct mutex session_mutex;
931938
struct TCP_Server_Info *server; /* pointer to server info */
932939
int ses_count; /* reference counter */
933-
enum statusEnum status; /* updates protected by cifs_tcp_ses_lock */
940+
enum ses_status_enum ses_status; /* updates protected by cifs_tcp_ses_lock */
934941
unsigned overrideSecFlg; /* if non-zero override global sec flags */
935942
char *serverOS; /* name of operating system underlying server */
936943
char *serverNOS; /* name of network operating system of server */

fs/cifs/cifssmb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ cifs_mark_open_files_invalid(struct cifs_tcon *tcon)
7575

7676
/* only send once per connect */
7777
spin_lock(&cifs_tcp_ses_lock);
78-
if ((tcon->ses->status != CifsGood) || (tcon->status != TID_NEED_RECON)) {
78+
if ((tcon->ses->ses_status != SES_GOOD) || (tcon->status != TID_NEED_RECON)) {
7979
spin_unlock(&cifs_tcp_ses_lock);
8080
return;
8181
}

fs/cifs/connect.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
241241
if (!mark_smb_session && !CIFS_ALL_CHANS_NEED_RECONNECT(ses))
242242
goto next_session;
243243

244-
ses->status = CifsNeedReconnect;
244+
ses->ses_status = SES_NEED_RECON;
245245

246246
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
247247
tcon->need_reconnect = true;
@@ -1828,7 +1828,7 @@ cifs_find_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
18281828

18291829
spin_lock(&cifs_tcp_ses_lock);
18301830
list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) {
1831-
if (ses->status == CifsExiting)
1831+
if (ses->ses_status == SES_EXITING)
18321832
continue;
18331833
if (!match_session(ses, ctx))
18341834
continue;
@@ -1848,7 +1848,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
18481848
cifs_dbg(FYI, "%s: ses_count=%d\n", __func__, ses->ses_count);
18491849

18501850
spin_lock(&cifs_tcp_ses_lock);
1851-
if (ses->status == CifsExiting) {
1851+
if (ses->ses_status == SES_EXITING) {
18521852
spin_unlock(&cifs_tcp_ses_lock);
18531853
return;
18541854
}
@@ -1864,13 +1864,13 @@ void cifs_put_smb_ses(struct cifs_ses *ses)
18641864
/* ses_count can never go negative */
18651865
WARN_ON(ses->ses_count < 0);
18661866

1867-
if (ses->status == CifsGood)
1868-
ses->status = CifsExiting;
1867+
if (ses->ses_status == SES_GOOD)
1868+
ses->ses_status = SES_EXITING;
18691869
spin_unlock(&cifs_tcp_ses_lock);
18701870

18711871
cifs_free_ipc(ses);
18721872

1873-
if (ses->status == CifsExiting && server->ops->logoff) {
1873+
if (ses->ses_status == SES_EXITING && server->ops->logoff) {
18741874
xid = get_xid();
18751875
rc = server->ops->logoff(xid, ses);
18761876
if (rc)
@@ -2090,7 +2090,7 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx)
20902090
ses = cifs_find_smb_ses(server, ctx);
20912091
if (ses) {
20922092
cifs_dbg(FYI, "Existing smb sess found (status=%d)\n",
2093-
ses->status);
2093+
ses->ses_status);
20942094

20952095
spin_lock(&ses->chan_lock);
20962096
if (cifs_chan_needs_reconnect(ses, server)) {
@@ -4001,11 +4001,13 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
40014001
spin_unlock(&ses->chan_lock);
40024002

40034003
spin_lock(&cifs_tcp_ses_lock);
4004-
if (ses->status == CifsExiting) {
4004+
if (ses->ses_status == SES_EXITING) {
40054005
spin_unlock(&cifs_tcp_ses_lock);
40064006
return 0;
40074007
}
4008-
ses->status = CifsInSessSetup;
4008+
4009+
if (!is_binding)
4010+
ses->ses_status = SES_IN_SETUP;
40094011
spin_unlock(&cifs_tcp_ses_lock);
40104012

40114013
if (!is_binding) {
@@ -4031,15 +4033,13 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
40314033
if (rc) {
40324034
cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc);
40334035
spin_lock(&cifs_tcp_ses_lock);
4034-
if (ses->status == CifsInSessSetup)
4035-
ses->status = CifsNeedSessSetup;
4036+
if (ses->ses_status == SES_IN_SETUP)
4037+
ses->ses_status = SES_NEED_RECON;
40364038
spin_unlock(&cifs_tcp_ses_lock);
40374039
} else {
40384040
spin_lock(&cifs_tcp_ses_lock);
4039-
if (ses->status == CifsInSessSetup)
4040-
ses->status = CifsGood;
4041-
/* Even if one channel is active, session is in good state */
4042-
ses->status = CifsGood;
4041+
if (ses->ses_status == SES_IN_SETUP)
4042+
ses->ses_status = SES_GOOD;
40434043
spin_unlock(&cifs_tcp_ses_lock);
40444044

40454045
spin_lock(&ses->chan_lock);
@@ -4509,7 +4509,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
45094509

45104510
/* only send once per connect */
45114511
spin_lock(&cifs_tcp_ses_lock);
4512-
if (tcon->ses->status != CifsGood ||
4512+
if (tcon->ses->ses_status != SES_GOOD ||
45134513
(tcon->status != TID_NEW &&
45144514
tcon->status != TID_NEED_TCON)) {
45154515
spin_unlock(&cifs_tcp_ses_lock);
@@ -4577,7 +4577,7 @@ int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, const stru
45774577

45784578
/* only send once per connect */
45794579
spin_lock(&cifs_tcp_ses_lock);
4580-
if (tcon->ses->status != CifsGood ||
4580+
if (tcon->ses->ses_status != SES_GOOD ||
45814581
(tcon->status != TID_NEW &&
45824582
tcon->status != TID_NEED_TCON)) {
45834583
spin_unlock(&cifs_tcp_ses_lock);

fs/cifs/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ sesInfoAlloc(void)
6969
ret_buf = kzalloc(sizeof(struct cifs_ses), GFP_KERNEL);
7070
if (ret_buf) {
7171
atomic_inc(&sesInfoAllocCount);
72-
ret_buf->status = CifsNew;
72+
ret_buf->ses_status = SES_NEW;
7373
++ret_buf->ses_count;
7474
INIT_LIST_HEAD(&ret_buf->smb_ses_list);
7575
INIT_LIST_HEAD(&ret_buf->tcon_list);

fs/cifs/smb2pdu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,
179179
}
180180
}
181181
spin_unlock(&cifs_tcp_ses_lock);
182-
if ((!tcon->ses) || (tcon->ses->status == CifsExiting) ||
182+
if ((!tcon->ses) || (tcon->ses->ses_status == SES_EXITING) ||
183183
(!tcon->ses->server) || !server)
184184
return -EIO;
185185

fs/cifs/smb2transport.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
780780
return -EAGAIN;
781781
}
782782

783-
if (ses->status == CifsNew) {
783+
if (ses->ses_status == SES_NEW) {
784784
if ((shdr->Command != SMB2_SESSION_SETUP) &&
785785
(shdr->Command != SMB2_NEGOTIATE)) {
786786
spin_unlock(&cifs_tcp_ses_lock);
@@ -789,7 +789,7 @@ smb2_get_mid_entry(struct cifs_ses *ses, struct TCP_Server_Info *server,
789789
/* else ok - we are setting up session */
790790
}
791791

792-
if (ses->status == CifsExiting) {
792+
if (ses->ses_status == SES_EXITING) {
793793
if (shdr->Command != SMB2_LOGOFF) {
794794
spin_unlock(&cifs_tcp_ses_lock);
795795
return -EAGAIN;

fs/cifs/transport.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
726726
struct mid_q_entry **ppmidQ)
727727
{
728728
spin_lock(&cifs_tcp_ses_lock);
729-
if (ses->status == CifsNew) {
729+
if (ses->ses_status == SES_NEW) {
730730
if ((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) &&
731731
(in_buf->Command != SMB_COM_NEGOTIATE)) {
732732
spin_unlock(&cifs_tcp_ses_lock);
@@ -735,7 +735,7 @@ static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
735735
/* else ok - we are setting up session */
736736
}
737737

738-
if (ses->status == CifsExiting) {
738+
if (ses->ses_status == SES_EXITING) {
739739
/* check if SMB session is bad because we are setting it up */
740740
if (in_buf->Command != SMB_COM_LOGOFF_ANDX) {
741741
spin_unlock(&cifs_tcp_ses_lock);
@@ -1187,7 +1187,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
11871187
* Compounding is never used during session establish.
11881188
*/
11891189
spin_lock(&cifs_tcp_ses_lock);
1190-
if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP)) {
1190+
if ((ses->ses_status == SES_NEW) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP)) {
11911191
spin_unlock(&cifs_tcp_ses_lock);
11921192

11931193
mutex_lock(&server->srv_mutex);
@@ -1260,7 +1260,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
12601260
* Compounding is never used during session establish.
12611261
*/
12621262
spin_lock(&cifs_tcp_ses_lock);
1263-
if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP)) {
1263+
if ((ses->ses_status == SES_NEW) || (optype & CIFS_NEG_OP) || (optype & CIFS_SESS_OP)) {
12641264
struct kvec iov = {
12651265
.iov_base = resp_iov[0].iov_base,
12661266
.iov_len = resp_iov[0].iov_len

0 commit comments

Comments
 (0)