From patchwork Sat Aug 20 01:55:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1082172 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7K1tjDf012305 for ; Sat, 20 Aug 2011 01:55:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754318Ab1HTBzy (ORCPT ); Fri, 19 Aug 2011 21:55:54 -0400 Received: from mail-gw0-f46.google.com ([74.125.83.46]:33213 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754247Ab1HTBzy (ORCPT ); Fri, 19 Aug 2011 21:55:54 -0400 Received: by mail-gw0-f46.google.com with SMTP id a12so2026366gwa.19 for ; Fri, 19 Aug 2011 18:55:54 -0700 (PDT) Received: by 10.90.247.7 with SMTP id u7mr40284agh.15.1313805354089; Fri, 19 Aug 2011 18:55:54 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-075-177-182-191.nc.res.rr.com [75.177.182.191]) by mx.google.com with ESMTPS id b5sm3122509anm.21.2011.08.19.18.55.53 (version=SSLv3 cipher=OTHER); Fri, 19 Aug 2011 18:55:53 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: piastryyy@gmail.com, linux-cifs@vger.kernel.org Subject: [PATCH 12/14] cifs: find mid earlier in receive codepath Date: Fri, 19 Aug 2011 21:55:37 -0400 Message-Id: <1313805339-1233-13-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1313805339-1233-1-git-send-email-jlayton@redhat.com> References: <1313805339-1233-1-git-send-email-jlayton@redhat.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 20 Aug 2011 01:55:55 +0000 (UTC) In order to receive directly into a preallocated buffer, we need to ID the mid earlier, before the bulk of the response is read. Call the mid finding routine as soon as we're able to read the mid. Signed-off-by: Jeff Layton --- fs/cifs/connect.c | 24 +++++++++--------------- 1 files changed, 9 insertions(+), 15 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 4b727c2..18171cf 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -555,16 +555,10 @@ dequeue_mid(struct mid_q_entry *mid, int malformed) spin_unlock(&GlobalMid_Lock); } -static struct mid_q_entry * -find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, - int malformed) +static void +handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server, + struct smb_hdr *buf, int malformed) { - struct mid_q_entry *mid = NULL; - - mid = find_mid(server, buf); - if (!mid) - return mid; - if (malformed == 0 && check2ndT2(buf) > 0) { mid->multiRsp = true; if (mid->resp_buf) { @@ -572,11 +566,11 @@ find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, malformed = coalesce_t2(buf, mid->resp_buf); if (malformed > 0) { malformed = 0; - return mid; + return; } /* All parts received or packet is malformed. */ mid->multiEnd = true; - goto multi_t2_fnd; + return dequeue_mid(mid, malformed); } if (!server->large_buf) { /*FIXME: switch to already allocated largebuf?*/ @@ -587,7 +581,7 @@ find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, mid->largeBuf = true; server->bigbuf = NULL; } - return mid; + return; } mid->resp_buf = buf; mid->largeBuf = server->large_buf; @@ -599,9 +593,7 @@ find_cifs_mid(struct TCP_Server_Info *server, struct smb_hdr *buf, else server->smallbuf = NULL; } -multi_t2_fnd: dequeue_mid(mid, malformed); - return mid; } static void clean_demultiplex_info(struct TCP_Server_Info *server) @@ -762,6 +754,8 @@ cifs_demultiplex_thread(void *p) continue; server->total_read += length; + mid_entry = find_mid(server, smb_buffer); + if (pdu_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { cERROR(1, "SMB response too long (%u bytes)", pdu_length); @@ -806,8 +800,8 @@ cifs_demultiplex_thread(void *p) server->lstrp = jiffies; - mid_entry = find_cifs_mid(server, smb_buffer, length); if (mid_entry != NULL) { + handle_mid(mid_entry, server, smb_buffer, length); if (!mid_entry->multiRsp || mid_entry->multiEnd) mid_entry->callback(mid_entry); } else if (length != 0) {