cifs: refactor mid finding loop in cifs_demultiplex_thread

...to reduce the extreme indentation. This should introduce no
behavioral changes.

Cc: stable@kernel.org
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>

authored by Jeff Layton and committed by Steve French 146f9f65 2a2047bc

+47 -47
+47 -47
fs/cifs/connect.c
··· 617 617 list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { 618 618 mid_entry = list_entry(tmp, struct mid_q_entry, qhead); 619 619 620 - if ((mid_entry->mid == smb_buffer->Mid) && 621 - (mid_entry->midState == MID_REQUEST_SUBMITTED) && 622 - (mid_entry->command == smb_buffer->Command)) { 623 - if (length == 0 && 624 - check2ndT2(smb_buffer, server->maxBuf) > 0) { 625 - /* We have a multipart transact2 resp */ 626 - isMultiRsp = true; 627 - if (mid_entry->resp_buf) { 628 - /* merge response - fix up 1st*/ 629 - if (coalesce_t2(smb_buffer, 620 + if (mid_entry->mid != smb_buffer->Mid || 621 + mid_entry->midState != MID_REQUEST_SUBMITTED || 622 + mid_entry->command != smb_buffer->Command) { 623 + mid_entry = NULL; 624 + continue; 625 + } 626 + 627 + if (length == 0 && 628 + check2ndT2(smb_buffer, server->maxBuf) > 0) { 629 + /* We have a multipart transact2 resp */ 630 + isMultiRsp = true; 631 + if (mid_entry->resp_buf) { 632 + /* merge response - fix up 1st*/ 633 + if (coalesce_t2(smb_buffer, 630 634 mid_entry->resp_buf)) { 631 - mid_entry->multiRsp = 632 - true; 633 - break; 634 - } else { 635 - /* all parts received */ 636 - mid_entry->multiEnd = 637 - true; 638 - goto multi_t2_fnd; 639 - } 635 + mid_entry->multiRsp = true; 636 + break; 640 637 } else { 641 - if (!isLargeBuf) { 642 - cERROR(1, "1st trans2 resp needs bigbuf"); 643 - /* BB maybe we can fix this up, switch 644 - to already allocated large buffer? */ 645 - } else { 646 - /* Have first buffer */ 647 - mid_entry->resp_buf = 648 - smb_buffer; 649 - mid_entry->largeBuf = 650 - true; 651 - bigbuf = NULL; 652 - } 638 + /* all parts received */ 639 + mid_entry->multiEnd = true; 640 + goto multi_t2_fnd; 653 641 } 654 - break; 642 + } else { 643 + if (!isLargeBuf) { 644 + /* 645 + * FIXME: switch to already 646 + * allocated largebuf? 647 + */ 648 + cERROR(1, "1st trans2 resp " 649 + "needs bigbuf"); 650 + } else { 651 + /* Have first buffer */ 652 + mid_entry->resp_buf = 653 + smb_buffer; 654 + mid_entry->largeBuf = true; 655 + bigbuf = NULL; 656 + } 655 657 } 656 - mid_entry->resp_buf = smb_buffer; 657 - mid_entry->largeBuf = isLargeBuf; 658 - multi_t2_fnd: 659 - if (length == 0) 660 - mid_entry->midState = 661 - MID_RESPONSE_RECEIVED; 662 - else 663 - mid_entry->midState = 664 - MID_RESPONSE_MALFORMED; 665 - #ifdef CONFIG_CIFS_STATS2 666 - mid_entry->when_received = jiffies; 667 - #endif 668 - list_del_init(&mid_entry->qhead); 669 - mid_entry->callback(mid_entry); 670 658 break; 671 659 } 672 - mid_entry = NULL; 660 + mid_entry->resp_buf = smb_buffer; 661 + mid_entry->largeBuf = isLargeBuf; 662 + multi_t2_fnd: 663 + if (length == 0) 664 + mid_entry->midState = MID_RESPONSE_RECEIVED; 665 + else 666 + mid_entry->midState = MID_RESPONSE_MALFORMED; 667 + #ifdef CONFIG_CIFS_STATS2 668 + mid_entry->when_received = jiffies; 669 + #endif 670 + list_del_init(&mid_entry->qhead); 671 + mid_entry->callback(mid_entry); 672 + break; 673 673 } 674 674 spin_unlock(&GlobalMid_Lock); 675 675