diff options
Diffstat (limited to 'fs/cifs/connect.c')
-rw-r--r-- | fs/cifs/connect.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 8af993f8d0cc..3dd2d23e0649 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -124,7 +124,7 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
124 | struct mid_q_entry *mid_entry; | 124 | struct mid_q_entry *mid_entry; |
125 | 125 | ||
126 | spin_lock(&GlobalMid_Lock); | 126 | spin_lock(&GlobalMid_Lock); |
127 | if ( kthread_should_stop() ) { | 127 | if (kthread_should_stop()) { |
128 | /* the demux thread will exit normally | 128 | /* the demux thread will exit normally |
129 | next time through the loop */ | 129 | next time through the loop */ |
130 | spin_unlock(&GlobalMid_Lock); | 130 | spin_unlock(&GlobalMid_Lock); |
@@ -151,9 +151,8 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
151 | } | 151 | } |
152 | list_for_each(tmp, &GlobalTreeConnectionList) { | 152 | list_for_each(tmp, &GlobalTreeConnectionList) { |
153 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); | 153 | tcon = list_entry(tmp, struct cifsTconInfo, cifsConnectionList); |
154 | if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) { | 154 | if ((tcon) && (tcon->ses) && (tcon->ses->server == server)) |
155 | tcon->tidStatus = CifsNeedReconnect; | 155 | tcon->tidStatus = CifsNeedReconnect; |
156 | } | ||
157 | } | 156 | } |
158 | read_unlock(&GlobalSMBSeslock); | 157 | read_unlock(&GlobalSMBSeslock); |
159 | /* do not want to be sending data on a socket we are freeing */ | 158 | /* do not want to be sending data on a socket we are freeing */ |
@@ -187,7 +186,7 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
187 | spin_unlock(&GlobalMid_Lock); | 186 | spin_unlock(&GlobalMid_Lock); |
188 | up(&server->tcpSem); | 187 | up(&server->tcpSem); |
189 | 188 | ||
190 | while ( (!kthread_should_stop()) && (server->tcpStatus != CifsGood)) { | 189 | while ((!kthread_should_stop()) && (server->tcpStatus != CifsGood)) { |
191 | try_to_freeze(); | 190 | try_to_freeze(); |
192 | if (server->protocolType == IPV6) { | 191 | if (server->protocolType == IPV6) { |
193 | rc = ipv6_connect(&server->addr.sockAddr6, | 192 | rc = ipv6_connect(&server->addr.sockAddr6, |
@@ -204,7 +203,7 @@ cifs_reconnect(struct TCP_Server_Info *server) | |||
204 | } else { | 203 | } else { |
205 | atomic_inc(&tcpSesReconnectCount); | 204 | atomic_inc(&tcpSesReconnectCount); |
206 | spin_lock(&GlobalMid_Lock); | 205 | spin_lock(&GlobalMid_Lock); |
207 | if ( !kthread_should_stop() ) | 206 | if (!kthread_should_stop()) |
208 | server->tcpStatus = CifsGood; | 207 | server->tcpStatus = CifsGood; |
209 | server->sequence_number = 0; | 208 | server->sequence_number = 0; |
210 | spin_unlock(&GlobalMid_Lock); | 209 | spin_unlock(&GlobalMid_Lock); |
@@ -358,11 +357,9 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
358 | length = tcpSesAllocCount.counter; | 357 | length = tcpSesAllocCount.counter; |
359 | write_unlock(&GlobalSMBSeslock); | 358 | write_unlock(&GlobalSMBSeslock); |
360 | complete(&cifsd_complete); | 359 | complete(&cifsd_complete); |
361 | if (length > 1) { | 360 | if (length > 1) |
362 | mempool_resize(cifs_req_poolp, | 361 | mempool_resize(cifs_req_poolp, length + cifs_min_rcv, |
363 | length + cifs_min_rcv, | 362 | GFP_KERNEL); |
364 | GFP_KERNEL); | ||
365 | } | ||
366 | 363 | ||
367 | set_freezable(); | 364 | set_freezable(); |
368 | while (!kthread_should_stop()) { | 365 | while (!kthread_should_stop()) { |
@@ -378,7 +375,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
378 | } | 375 | } |
379 | } else if (isLargeBuf) { | 376 | } else if (isLargeBuf) { |
380 | /* we are reusing a dirty large buf, clear its start */ | 377 | /* we are reusing a dirty large buf, clear its start */ |
381 | memset(bigbuf, 0, sizeof (struct smb_hdr)); | 378 | memset(bigbuf, 0, sizeof(struct smb_hdr)); |
382 | } | 379 | } |
383 | 380 | ||
384 | if (smallbuf == NULL) { | 381 | if (smallbuf == NULL) { |
@@ -391,7 +388,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) | |||
391 | } | 388 | } |
392 | /* beginning of smb buffer is cleared in our buf_get */ | 389 | /* beginning of smb buffer is cleared in our buf_get */ |
393 | } else /* if existing small buf clear beginning */ | 390 | } else /* if existing small buf clear beginning */ |
394 | memset(smallbuf, 0, sizeof (struct smb_hdr)); | 391 | memset(smallbuf, 0, sizeof(struct smb_hdr)); |
395 | 392 | ||
396 | isLargeBuf = FALSE; | 393 | isLargeBuf = FALSE; |
397 | isMultiRsp = FALSE; | 394 | isMultiRsp = FALSE; |
@@ -406,7 +403,7 @@ incomplete_rcv: | |||
406 | kernel_recvmsg(csocket, &smb_msg, | 403 | kernel_recvmsg(csocket, &smb_msg, |
407 | &iov, 1, pdu_length, 0 /* BB other flags? */); | 404 | &iov, 1, pdu_length, 0 /* BB other flags? */); |
408 | 405 | ||
409 | if ( kthread_should_stop() ) { | 406 | if (kthread_should_stop()) { |
410 | break; | 407 | break; |
411 | } else if (server->tcpStatus == CifsNeedReconnect) { | 408 | } else if (server->tcpStatus == CifsNeedReconnect) { |
412 | cFYI(1, ("Reconnect after server stopped responding")); | 409 | cFYI(1, ("Reconnect after server stopped responding")); |
@@ -505,7 +502,7 @@ incomplete_rcv: | |||
505 | 502 | ||
506 | /* else we have an SMB response */ | 503 | /* else we have an SMB response */ |
507 | if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || | 504 | if ((pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) || |
508 | (pdu_length < sizeof (struct smb_hdr) - 1 - 4)) { | 505 | (pdu_length < sizeof(struct smb_hdr) - 1 - 4)) { |
509 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", | 506 | cERROR(1, ("Invalid size SMB length %d pdu_length %d", |
510 | length, pdu_length+4)); | 507 | length, pdu_length+4)); |
511 | cifs_reconnect(server); | 508 | cifs_reconnect(server); |
@@ -529,7 +526,7 @@ incomplete_rcv: | |||
529 | total_read += length) { | 526 | total_read += length) { |
530 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, | 527 | length = kernel_recvmsg(csocket, &smb_msg, &iov, 1, |
531 | pdu_length - total_read, 0); | 528 | pdu_length - total_read, 0); |
532 | if ( kthread_should_stop() || | 529 | if (kthread_should_stop() || |
533 | (length == -EINTR)) { | 530 | (length == -EINTR)) { |
534 | /* then will exit */ | 531 | /* then will exit */ |
535 | reconnect = 2; | 532 | reconnect = 2; |
@@ -632,9 +629,9 @@ multi_t2_fnd: | |||
632 | /* Was previous buf put in mpx struct for multi-rsp? */ | 629 | /* Was previous buf put in mpx struct for multi-rsp? */ |
633 | if (!isMultiRsp) { | 630 | if (!isMultiRsp) { |
634 | /* smb buffer will be freed by user thread */ | 631 | /* smb buffer will be freed by user thread */ |
635 | if (isLargeBuf) { | 632 | if (isLargeBuf) |
636 | bigbuf = NULL; | 633 | bigbuf = NULL; |
637 | } else | 634 | else |
638 | smallbuf = NULL; | 635 | smallbuf = NULL; |
639 | } | 636 | } |
640 | wake_up_process(task_to_wake); | 637 | wake_up_process(task_to_wake); |
@@ -703,9 +700,8 @@ multi_t2_fnd: | |||
703 | list_for_each(tmp, &GlobalSMBSessionList) { | 700 | list_for_each(tmp, &GlobalSMBSessionList) { |
704 | ses = list_entry(tmp, struct cifsSesInfo, | 701 | ses = list_entry(tmp, struct cifsSesInfo, |
705 | cifsSessionList); | 702 | cifsSessionList); |
706 | if (ses->server == server) { | 703 | if (ses->server == server) |
707 | ses->status = CifsExiting; | 704 | ses->status = CifsExiting; |
708 | } | ||
709 | } | 705 | } |
710 | 706 | ||
711 | spin_lock(&GlobalMid_Lock); | 707 | spin_lock(&GlobalMid_Lock); |
@@ -715,9 +711,8 @@ multi_t2_fnd: | |||
715 | cFYI(1, ("Clearing Mid 0x%x - waking up ", | 711 | cFYI(1, ("Clearing Mid 0x%x - waking up ", |
716 | mid_entry->mid)); | 712 | mid_entry->mid)); |
717 | task_to_wake = mid_entry->tsk; | 713 | task_to_wake = mid_entry->tsk; |
718 | if (task_to_wake) { | 714 | if (task_to_wake) |
719 | wake_up_process(task_to_wake); | 715 | wake_up_process(task_to_wake); |
720 | } | ||
721 | } | 716 | } |
722 | } | 717 | } |
723 | spin_unlock(&GlobalMid_Lock); | 718 | spin_unlock(&GlobalMid_Lock); |
@@ -750,18 +745,15 @@ multi_t2_fnd: | |||
750 | list_for_each(tmp, &GlobalSMBSessionList) { | 745 | list_for_each(tmp, &GlobalSMBSessionList) { |
751 | ses = list_entry(tmp, struct cifsSesInfo, | 746 | ses = list_entry(tmp, struct cifsSesInfo, |
752 | cifsSessionList); | 747 | cifsSessionList); |
753 | if (ses->server == server) { | 748 | if (ses->server == server) |
754 | ses->server = NULL; | 749 | ses->server = NULL; |
755 | } | ||
756 | } | 750 | } |
757 | write_unlock(&GlobalSMBSeslock); | 751 | write_unlock(&GlobalSMBSeslock); |
758 | 752 | ||
759 | kfree(server); | 753 | kfree(server); |
760 | if (length > 0) { | 754 | if (length > 0) |
761 | mempool_resize(cifs_req_poolp, | 755 | mempool_resize(cifs_req_poolp, length + cifs_min_rcv, |
762 | length + cifs_min_rcv, | 756 | GFP_KERNEL); |
763 | GFP_KERNEL); | ||
764 | } | ||
765 | 757 | ||
766 | return 0; | 758 | return 0; |
767 | } | 759 | } |