浏览代码

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>
Jeff Layton 13 年之前
父节点
当前提交
ffc00e27aa
共有 1 个文件被更改,包括 16 次插入20 次删除
  1. 16 20
      fs/cifs/connect.c

+ 16 - 20
fs/cifs/connect.c

@@ -576,8 +576,7 @@ dequeue_mid(struct mid_q_entry *mid, int malformed)
 
 
 static struct mid_q_entry *
 static struct mid_q_entry *
 find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf,
 find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf,
-	      int *malformed, bool is_large_buf, bool *is_multi_rsp,
-	      char **bigbuf)
+	      int malformed, bool is_large_buf, char **bigbuf)
 {
 {
 	struct mid_q_entry *mid = NULL;
 	struct mid_q_entry *mid = NULL;
 
 
@@ -585,17 +584,14 @@ find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf,
 	if (!mid)
 	if (!mid)
 		return mid;
 		return mid;
 
 
-	if (*malformed == 0 && check2ndT2(buf) > 0) {
-		/* We have a multipart transact2 resp */
-		*is_multi_rsp = true;
+	if (malformed == 0 && check2ndT2(buf) > 0) {
+		mid->multiRsp = true;
 		if (mid->resp_buf) {
 		if (mid->resp_buf) {
 			/* merge response - fix up 1st*/
 			/* merge response - fix up 1st*/
-			*malformed = coalesce_t2(buf, mid->resp_buf);
-			if (*malformed > 0) {
-				*malformed = 0;
-				mid->multiRsp = true;
-				return NULL;
-			}
+			malformed = coalesce_t2(buf, mid->resp_buf);
+			if (malformed > 0)
+				return mid;
+
 			/* All parts received or packet is malformed. */
 			/* All parts received or packet is malformed. */
 			mid->multiEnd = true;
 			mid->multiEnd = true;
 			goto multi_t2_fnd;
 			goto multi_t2_fnd;
@@ -614,7 +610,7 @@ find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf,
 	mid->resp_buf = buf;
 	mid->resp_buf = buf;
 	mid->largeBuf = is_large_buf;
 	mid->largeBuf = is_large_buf;
 multi_t2_fnd:
 multi_t2_fnd:
-	dequeue_mid(mid, *malformed);
+	dequeue_mid(mid, malformed);
 	return mid;
 	return mid;
 }
 }
 
 
@@ -725,7 +721,6 @@ cifs_demultiplex_thread(void *p)
 	struct task_struct *task_to_wake = NULL;
 	struct task_struct *task_to_wake = NULL;
 	struct mid_q_entry *mid_entry;
 	struct mid_q_entry *mid_entry;
 	bool isLargeBuf = false;
 	bool isLargeBuf = false;
-	bool isMultiRsp = false;
 
 
 	current->flags |= PF_MEMALLOC;
 	current->flags |= PF_MEMALLOC;
 	cFYI(1, "Demultiplex PID: %d", task_pid_nr(current));
 	cFYI(1, "Demultiplex PID: %d", task_pid_nr(current));
@@ -745,7 +740,6 @@ cifs_demultiplex_thread(void *p)
 			continue;
 			continue;
 
 
 		isLargeBuf = false;
 		isLargeBuf = false;
-		isMultiRsp = false;
 		smb_buffer = (struct smb_hdr *)smallbuf;
 		smb_buffer = (struct smb_hdr *)smallbuf;
 		buf = smallbuf;
 		buf = smallbuf;
 		pdu_length = 4; /* enough to get RFC1001 header */
 		pdu_length = 4; /* enough to get RFC1001 header */
@@ -823,23 +817,25 @@ cifs_demultiplex_thread(void *p)
 
 
 		server->lstrp = jiffies;
 		server->lstrp = jiffies;
 
 
-		mid_entry = find_cifs_mid(server, smb_buffer, &length,
-					  isLargeBuf, &isMultiRsp, &bigbuf);
+		mid_entry = find_cifs_mid(server, smb_buffer, length,
+					  isLargeBuf, &bigbuf);
 		if (mid_entry != NULL) {
 		if (mid_entry != NULL) {
-			mid_entry->callback(mid_entry);
+			if (mid_entry->multiRsp && !mid_entry->multiEnd)
+				continue;
+
 			/* Was previous buf put in mpx struct for multi-rsp? */
 			/* Was previous buf put in mpx struct for multi-rsp? */
-			if (!isMultiRsp) {
+			if (!mid_entry->multiRsp) {
 				/* smb buffer will be freed by user thread */
 				/* smb buffer will be freed by user thread */
 				if (isLargeBuf)
 				if (isLargeBuf)
 					bigbuf = NULL;
 					bigbuf = NULL;
 				else
 				else
 					smallbuf = NULL;
 					smallbuf = NULL;
 			}
 			}
+			mid_entry->callback(mid_entry);
 		} else if (length != 0) {
 		} else if (length != 0) {
 			/* response sanity checks failed */
 			/* response sanity checks failed */
 			continue;
 			continue;
-		} else if (!is_valid_oplock_break(smb_buffer, server) &&
-			   !isMultiRsp) {
+		} else if (!is_valid_oplock_break(smb_buffer, server)) {
 			cERROR(1, "No task to wake, unknown frame received! "
 			cERROR(1, "No task to wake, unknown frame received! "
 				   "NumMids %d", atomic_read(&midCount));
 				   "NumMids %d", atomic_read(&midCount));
 			cifs_dump_mem("Received Data is: ", buf,
 			cifs_dump_mem("Received Data is: ", buf,