diff options
author | Jeff Layton <jlayton@redhat.com> | 2011-10-19 15:29:13 -0400 |
---|---|---|
committer | Jeff Layton <jlayton@redhat.com> | 2011-10-19 15:29:13 -0400 |
commit | ffc00e27aa5d343eb71068c185cdbd65871ccdce (patch) | |
tree | a643034e084097d4b41b5c7f9511f5e262133985 /fs/cifs | |
parent | ea1f4502fc939b64807f9ab0eca259321047fe83 (diff) |
cifs: eliminate is_multi_rsp parm to find_cifs_mid
Change find_cifs_mid to only return NULL if a mid could not be found.
If we got part of a multi-part T2 response, then coalesce it and still
return the mid. The caller can determine the T2 receive status from
the flags in the mid.
With this change, there is no need to pass a pointer to "length" as
well so just pass by value. If a mid is found, then we can just mark
it as malformed. If one isn't found, then the value of "length" won't
change anyway.
Reviewed-and-Tested-by: Pavel Shilovsky <piastry@etersoft.ru>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/connect.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 0f69b311d3fc..8d5a61561909 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -576,8 +576,7 @@ dequeue_mid(struct mid_q_entry *mid, int malformed) | |||
576 | 576 | ||
577 | static struct mid_q_entry * | 577 | static struct mid_q_entry * |
578 | find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, | 578 | find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, |
579 | int *malformed, bool is_large_buf, bool *is_multi_rsp, | 579 | int malformed, bool is_large_buf, char **bigbuf) |
580 | char **bigbuf) | ||
581 | { | 580 | { |
582 | struct mid_q_entry *mid = NULL; | 581 | struct mid_q_entry *mid = NULL; |
583 | 582 | ||
@@ -585,17 +584,14 @@ find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, | |||
585 | if (!mid) | 584 | if (!mid) |
586 | return mid; | 585 | return mid; |
587 | 586 | ||
588 | if (*malformed == 0 && check2ndT2(buf) > 0) { | 587 | if (malformed == 0 && check2ndT2(buf) > 0) { |
589 | /* We have a multipart transact2 resp */ | 588 | mid->multiRsp = true; |
590 | *is_multi_rsp = true; | ||
591 | if (mid->resp_buf) { | 589 | if (mid->resp_buf) { |
592 | /* merge response - fix up 1st*/ | 590 | /* merge response - fix up 1st*/ |
593 | *malformed = coalesce_t2(buf, mid->resp_buf); | 591 | malformed = coalesce_t2(buf, mid->resp_buf); |
594 | if (*malformed > 0) { | 592 | if (malformed > 0) |
595 | *malformed = 0; | 593 | return mid; |
596 | mid->multiRsp = true; | 594 | |
597 | return NULL; | ||
598 | } | ||
599 | /* All parts received or packet is malformed. */ | 595 | /* All parts received or packet is malformed. */ |
600 | mid->multiEnd = true; | 596 | mid->multiEnd = true; |
601 | goto multi_t2_fnd; | 597 | goto multi_t2_fnd; |
@@ -614,7 +610,7 @@ find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, | |||
614 | mid->resp_buf = buf; | 610 | mid->resp_buf = buf; |
615 | mid->largeBuf = is_large_buf; | 611 | mid->largeBuf = is_large_buf; |
616 | multi_t2_fnd: | 612 | multi_t2_fnd: |
617 | dequeue_mid(mid, *malformed); | 613 | dequeue_mid(mid, malformed); |
618 | return mid; | 614 | return mid; |
619 | } | 615 | } |
620 | 616 | ||
@@ -725,7 +721,6 @@ cifs_demultiplex_thread(void *p) | |||
725 | struct task_struct *task_to_wake = NULL; | 721 | struct task_struct *task_to_wake = NULL; |
726 | struct mid_q_entry *mid_entry; | 722 | struct mid_q_entry *mid_entry; |
727 | bool isLargeBuf = false; | 723 | bool isLargeBuf = false; |
728 | bool isMultiRsp = false; | ||
729 | 724 | ||
730 | current->flags |= PF_MEMALLOC; | 725 | current->flags |= PF_MEMALLOC; |
731 | cFYI(1, "Demultiplex PID: %d", task_pid_nr(current)); | 726 | cFYI(1, "Demultiplex PID: %d", task_pid_nr(current)); |
@@ -745,7 +740,6 @@ cifs_demultiplex_thread(void *p) | |||
745 | continue; | 740 | continue; |
746 | 741 | ||
747 | isLargeBuf = false; | 742 | isLargeBuf = false; |
748 | isMultiRsp = false; | ||
749 | smb_buffer = (struct smb_hdr *)smallbuf; | 743 | smb_buffer = (struct smb_hdr *)smallbuf; |
750 | buf = smallbuf; | 744 | buf = smallbuf; |
751 | pdu_length = 4; /* enough to get RFC1001 header */ | 745 | pdu_length = 4; /* enough to get RFC1001 header */ |
@@ -823,23 +817,25 @@ cifs_demultiplex_thread(void *p) | |||
823 | 817 | ||
824 | server->lstrp = jiffies; | 818 | server->lstrp = jiffies; |
825 | 819 | ||
826 | mid_entry = find_cifs_mid(server, smb_buffer, &length, | 820 | mid_entry = find_cifs_mid(server, smb_buffer, length, |
827 | isLargeBuf, &isMultiRsp, &bigbuf); | 821 | isLargeBuf, &bigbuf); |
828 | if (mid_entry != NULL) { | 822 | if (mid_entry != NULL) { |
829 | mid_entry->callback(mid_entry); | 823 | if (mid_entry->multiRsp && !mid_entry->multiEnd) |
824 | continue; | ||
825 | |||
830 | /* Was previous buf put in mpx struct for multi-rsp? */ | 826 | /* Was previous buf put in mpx struct for multi-rsp? */ |
831 | if (!isMultiRsp) { | 827 | if (!mid_entry->multiRsp) { |
832 | /* smb buffer will be freed by user thread */ | 828 | /* smb buffer will be freed by user thread */ |
833 | if (isLargeBuf) | 829 | if (isLargeBuf) |
834 | bigbuf = NULL; | 830 | bigbuf = NULL; |
835 | else | 831 | else |
836 | smallbuf = NULL; | 832 | smallbuf = NULL; |
837 | } | 833 | } |
834 | mid_entry->callback(mid_entry); | ||
838 | } else if (length != 0) { | 835 | } else if (length != 0) { |
839 | /* response sanity checks failed */ | 836 | /* response sanity checks failed */ |
840 | continue; | 837 | continue; |
841 | } else if (!is_valid_oplock_break(smb_buffer, server) && | 838 | } else if (!is_valid_oplock_break(smb_buffer, server)) { |
842 | !isMultiRsp) { | ||
843 | cERROR(1, "No task to wake, unknown frame received! " | 839 | cERROR(1, "No task to wake, unknown frame received! " |
844 | "NumMids %d", atomic_read(&midCount)); | 840 | "NumMids %d", atomic_read(&midCount)); |
845 | cifs_dump_mem("Received Data is: ", buf, | 841 | cifs_dump_mem("Received Data is: ", buf, |