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>
This commit is contained in:
Jeff Layton 2011-04-29 06:52:43 -04:00 committed by Steve French
parent 2a2047bc94
commit 146f9f65bd

View file

@ -617,59 +617,59 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)
list_for_each_safe(tmp, tmp2, &server->pending_mid_q) { list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
mid_entry = list_entry(tmp, struct mid_q_entry, qhead); mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
if ((mid_entry->mid == smb_buffer->Mid) && if (mid_entry->mid != smb_buffer->Mid ||
(mid_entry->midState == MID_REQUEST_SUBMITTED) && mid_entry->midState != MID_REQUEST_SUBMITTED ||
(mid_entry->command == smb_buffer->Command)) { mid_entry->command != smb_buffer->Command) {
if (length == 0 && mid_entry = NULL;
check2ndT2(smb_buffer, server->maxBuf) > 0) { continue;
/* We have a multipart transact2 resp */ }
isMultiRsp = true;
if (mid_entry->resp_buf) { if (length == 0 &&
/* merge response - fix up 1st*/ check2ndT2(smb_buffer, server->maxBuf) > 0) {
if (coalesce_t2(smb_buffer, /* We have a multipart transact2 resp */
isMultiRsp = true;
if (mid_entry->resp_buf) {
/* merge response - fix up 1st*/
if (coalesce_t2(smb_buffer,
mid_entry->resp_buf)) { mid_entry->resp_buf)) {
mid_entry->multiRsp = mid_entry->multiRsp = true;
true; break;
break;
} else {
/* all parts received */
mid_entry->multiEnd =
true;
goto multi_t2_fnd;
}
} else { } else {
if (!isLargeBuf) { /* all parts received */
cERROR(1, "1st trans2 resp needs bigbuf"); mid_entry->multiEnd = true;
/* BB maybe we can fix this up, switch goto multi_t2_fnd;
to already allocated large buffer? */ }
} else { } else {
/* Have first buffer */ if (!isLargeBuf) {
mid_entry->resp_buf = /*
smb_buffer; * FIXME: switch to already
mid_entry->largeBuf = * allocated largebuf?
true; */
bigbuf = NULL; cERROR(1, "1st trans2 resp "
} "needs bigbuf");
} else {
/* Have first buffer */
mid_entry->resp_buf =
smb_buffer;
mid_entry->largeBuf = true;
bigbuf = NULL;
} }
break;
} }
mid_entry->resp_buf = smb_buffer;
mid_entry->largeBuf = isLargeBuf;
multi_t2_fnd:
if (length == 0)
mid_entry->midState =
MID_RESPONSE_RECEIVED;
else
mid_entry->midState =
MID_RESPONSE_MALFORMED;
#ifdef CONFIG_CIFS_STATS2
mid_entry->when_received = jiffies;
#endif
list_del_init(&mid_entry->qhead);
mid_entry->callback(mid_entry);
break; break;
} }
mid_entry = NULL; mid_entry->resp_buf = smb_buffer;
mid_entry->largeBuf = isLargeBuf;
multi_t2_fnd:
if (length == 0)
mid_entry->midState = MID_RESPONSE_RECEIVED;
else
mid_entry->midState = MID_RESPONSE_MALFORMED;
#ifdef CONFIG_CIFS_STATS2
mid_entry->when_received = jiffies;
#endif
list_del_init(&mid_entry->qhead);
mid_entry->callback(mid_entry);
break;
} }
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);