aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifssmb.c
diff options
context:
space:
mode:
authorSteve French <sfrench@us.ibm.com>2008-11-13 14:45:32 -0500
committerSteve French <sfrench@us.ibm.com>2008-11-13 14:45:32 -0500
commit3b7952109361c684caf0c50474da8662ecc81019 (patch)
tree402062ed63236ef245d8d65010d8f06520df8453 /fs/cifs/cifssmb.c
parentc527c8a7ffa18400c2c1488f7ab5aff5e83f3c8e (diff)
[CIFS] Fix cifs reconnection flags
In preparation for Jeff's big umount/mount fixes to remove the possibility of various races in cifs mount and linked list handling of sessions, sockets and tree connections, this patch cleans up some repetitive code in cifs_mount, and addresses a problem with ses->status and tcon->tidStatus in which we were overloading the "need_reconnect" state with other status in that field. So the "need_reconnect" flag has been broken out from those two state fields (need reconnect was not mutually exclusive from some of the other possible tid and ses states). In addition, a few exit cases in cifs_mount were cleaned up, and a problem with a tcon flag (for lease support) was not being set consistently for the 2nd mount of the same share CC: Jeff Layton <jlayton@redhat.com> CC: Shirish Pargaonkar <shirishp@us.ibm.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/cifssmb.c')
-rw-r--r--fs/cifs/cifssmb.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index d5eac48fc415..7f0651b69573 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -190,10 +190,10 @@ small_smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
190 /* need to prevent multiple threads trying to 190 /* need to prevent multiple threads trying to
191 simultaneously reconnect the same SMB session */ 191 simultaneously reconnect the same SMB session */
192 down(&tcon->ses->sesSem); 192 down(&tcon->ses->sesSem);
193 if (tcon->ses->status == CifsNeedReconnect) 193 if (tcon->ses->need_reconnect)
194 rc = cifs_setup_session(0, tcon->ses, 194 rc = cifs_setup_session(0, tcon->ses,
195 nls_codepage); 195 nls_codepage);
196 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { 196 if (!rc && (tcon->need_reconnect)) {
197 mark_open_files_invalid(tcon); 197 mark_open_files_invalid(tcon);
198 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 198 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
199 tcon, nls_codepage); 199 tcon, nls_codepage);
@@ -295,7 +295,7 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
295 check for tcp and smb session status done differently 295 check for tcp and smb session status done differently
296 for those three - in the calling routine */ 296 for those three - in the calling routine */
297 if (tcon) { 297 if (tcon) {
298 if (tcon->tidStatus == CifsExiting) { 298 if (tcon->need_reconnect) {
299 /* only tree disconnect, open, and write, 299 /* only tree disconnect, open, and write,
300 (and ulogoff which does not have tcon) 300 (and ulogoff which does not have tcon)
301 are allowed as we start force umount */ 301 are allowed as we start force umount */
@@ -337,10 +337,10 @@ smb_init(int smb_command, int wct, struct cifsTconInfo *tcon,
337 /* need to prevent multiple threads trying to 337 /* need to prevent multiple threads trying to
338 simultaneously reconnect the same SMB session */ 338 simultaneously reconnect the same SMB session */
339 down(&tcon->ses->sesSem); 339 down(&tcon->ses->sesSem);
340 if (tcon->ses->status == CifsNeedReconnect) 340 if (tcon->ses->need_reconnect)
341 rc = cifs_setup_session(0, tcon->ses, 341 rc = cifs_setup_session(0, tcon->ses,
342 nls_codepage); 342 nls_codepage);
343 if (!rc && (tcon->tidStatus == CifsNeedReconnect)) { 343 if (!rc && (tcon->need_reconnect)) {
344 mark_open_files_invalid(tcon); 344 mark_open_files_invalid(tcon);
345 rc = CIFSTCon(0, tcon->ses, tcon->treeName, 345 rc = CIFSTCon(0, tcon->ses, tcon->treeName,
346 tcon, nls_codepage); 346 tcon, nls_codepage);
@@ -759,7 +759,7 @@ CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon)
759 759
760 /* No need to return error on this operation if tid invalidated and 760 /* No need to return error on this operation if tid invalidated and
761 closed on server already e.g. due to tcp session crashing */ 761 closed on server already e.g. due to tcp session crashing */
762 if (tcon->tidStatus == CifsNeedReconnect) { 762 if (tcon->need_reconnect) {
763 up(&tcon->tconSem); 763 up(&tcon->tconSem);
764 return 0; 764 return 0;
765 } 765 }
@@ -806,32 +806,36 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
806 up(&ses->sesSem); 806 up(&ses->sesSem);
807 return -EBUSY; 807 return -EBUSY;
808 } 808 }
809
810 if (ses->server == NULL)
811 return -EIO;
812
813 if (ses->need_reconnect)
814 goto session_already_dead; /* no need to send SMBlogoff if uid
815 already closed due to reconnect */
809 rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB); 816 rc = small_smb_init(SMB_COM_LOGOFF_ANDX, 2, NULL, (void **)&pSMB);
810 if (rc) { 817 if (rc) {
811 up(&ses->sesSem); 818 up(&ses->sesSem);
812 return rc; 819 return rc;
813 } 820 }
814 821
815 if (ses->server) { 822 pSMB->hdr.Mid = GetNextMid(ses->server);
816 pSMB->hdr.Mid = GetNextMid(ses->server);
817 823
818 if (ses->server->secMode & 824 if (ses->server->secMode &
819 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) 825 (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
820 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE; 826 pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
821 }
822 827
823 pSMB->hdr.Uid = ses->Suid; 828 pSMB->hdr.Uid = ses->Suid;
824 829
825 pSMB->AndXCommand = 0xFF; 830 pSMB->AndXCommand = 0xFF;
826 rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0); 831 rc = SendReceiveNoRsp(xid, ses, (struct smb_hdr *) pSMB, 0);
827 if (ses->server) { 832session_already_dead:
828 atomic_dec(&ses->server->socketUseCount); 833 atomic_dec(&ses->server->socketUseCount);
829 if (atomic_read(&ses->server->socketUseCount) == 0) { 834 if (atomic_read(&ses->server->socketUseCount) == 0) {
830 spin_lock(&GlobalMid_Lock); 835 spin_lock(&GlobalMid_Lock);
831 ses->server->tcpStatus = CifsExiting; 836 ses->server->tcpStatus = CifsExiting;
832 spin_unlock(&GlobalMid_Lock); 837 spin_unlock(&GlobalMid_Lock);
833 rc = -ESHUTDOWN; 838 rc = -ESHUTDOWN;
834 }
835 } 839 }
836 up(&ses->sesSem); 840 up(&ses->sesSem);
837 841