Received: by 10.192.165.156 with SMTP id m28csp415423imm; Tue, 17 Apr 2018 12:20:20 -0700 (PDT) X-Google-Smtp-Source: AIpwx480U5BsdbYCOKvL4mjOsDqUayNu6w3beM419zK68tbDXqd3Xbi56va8WpYZmrSeNudAs0X6 X-Received: by 10.98.64.201 with SMTP id f70mr3067010pfd.67.1523992820392; Tue, 17 Apr 2018 12:20:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523992820; cv=none; d=google.com; s=arc-20160816; b=ShawK02TyxapyH2yJ1Tl7fNQYIGLvM9j3HuRVHWP99amzdlbNjvPKnDErtxgYyz3Nm Z3fjNjBYJH0DQXLsJACw79ETi6nk0x9ffOiJETNf9JZpx47814zoP/my5zLbpR65nO5w 5JKXxM8dDrveYjEZXEwRyIqvzsRC4SJL+/zxPGCiotEZsRxZ52pApRZE1cPv3LqQEi5q dh7jYEAGyfvBFixCLDo4E575Uv+DXkkQZaEPI6ygGuUJwDXH5n0FmkNV4Qp1GtDUoqP1 LIJbr5IxlRY9EFJAYlvr2gt6kf+POr+rtPjIJyaugUjKaXsf5SiteUPnn1aC9Oe9IeuA XbpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=JbHCDR1Sw3WKD89WLOCCztpfeJdxP59eJp0SYZugH4M=; b=JKHJF9nloglPRuKOy8cIQ6opQKn8L8iHL6sqWHy37H7SjWgXBd00Zit9v3ug8gXRMj 9fk/tFQ5VdWwZnBnDF6BHtojb0bPebNL6U1W1broUhsqyUJcxjRKDPQF5z62ZnFuteow s/FqIpjT5tO7QHWRsJaQvPoMF1xXXtFgl45wQA9yFDK4ddlcIUC/OnZBI6Qp4BMc4e8o UgWTrHkwIVsUTnh2neCmaxS8nE2QXQEpxcpVglFg3TFtpFP+ZlsMoRxi84YN1tQtFLvp pyyaaCnc8yaJCVVhjXDLMR/IvhmkI4LY8GctkCGs0d7OqqCINooKV1OSGb45kIKgyH95 RL6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j23si7406603pfn.63.2018.04.17.12.20.06; Tue, 17 Apr 2018 12:20:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752762AbeDQTS2 (ORCPT + 99 others); Tue, 17 Apr 2018 15:18:28 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:53542 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbeDQTSZ (ORCPT ); Tue, 17 Apr 2018 15:18:25 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id 8W6OfBbHeRnIx8W6OfCpKS; Tue, 17 Apr 2018 12:17:23 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.89_1) (envelope-from ) id 1f8W6O-0003sV-9e; Tue, 17 Apr 2018 12:17:16 -0700 From: Long Li To: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Cc: Long Li , stable@vger.kernel.org Subject: [Patch v2 3/6] cifs: smbd: Avoid allocating iov on the stack Date: Tue, 17 Apr 2018 12:17:07 -0700 Message-Id: <20180417191710.14855-3-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180417191710.14855-1-longli@linuxonhyperv.com> References: <20180417191710.14855-1-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfFFyrHmGPBnp8v7gnOzs6TL6+PTuEYW9qQRTRaOW6pLf3JLYL3h7jsKrSwLAQzC8YqNzE9CGqmTR/njE8fC6VlaoYodhbiyOhurJ7kpsxknr1P4Jozj4 TI6M7fL0Qwu8qWHnOmA2z+p/iVzjjNpolxiOqFq2B7CG4rLvnd1x1g0rgplXJCTb5rz3Khx5iTmtSPdyJtPnUkvR5IeEA4fMVmwZhcK36z9K1liePqlnnFgh YKDc6X4LU5Vb3AeVwUIau164vBT6hecDdW/8N1CtAfux16UKu9Piloe2lu998QsUDdLblXvGSSGmO8dpkDn92mpNh0iDykHYawVP77gjquesMPe2kmaD3kKS 0zk6+njtwVzTCIX69y6qLqfBWsWLjvBlDUeqJyf73+gggsE1S0ZyIoxiMm8qGKvcXwJ18G7nuYoKap03O6qa2n19n3tXIi3nAKIFxQ9QyF6CjwJL0vw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Long Li It's not necessary to allocate another iov when going through the buffers in smbd_send() through RDMA send. Remove it to reduce stack size. Signed-off-by: Long Li Cc: stable@vger.kernel.org --- fs/cifs/smbdirect.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/fs/cifs/smbdirect.c b/fs/cifs/smbdirect.c index b5c6c0d..f575e9a 100644 --- a/fs/cifs/smbdirect.c +++ b/fs/cifs/smbdirect.c @@ -2088,7 +2088,7 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst) int start, i, j; int max_iov_size = info->max_send_size - sizeof(struct smbd_data_transfer); - struct kvec iov[SMBDIRECT_MAX_SGE]; + struct kvec *iov; int rc; info->smbd_send_pending++; @@ -2099,32 +2099,20 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst) } /* - * This usually means a configuration error - * We use RDMA read/write for packet size > rdma_readwrite_threshold - * as long as it's properly configured we should never get into this - * situation - */ - if (rqst->rq_nvec + rqst->rq_npages > SMBDIRECT_MAX_SGE) { - log_write(ERR, "maximum send segment %x exceeding %x\n", - rqst->rq_nvec + rqst->rq_npages, SMBDIRECT_MAX_SGE); - rc = -EINVAL; - goto done; - } - - /* - * Remove the RFC1002 length defined in MS-SMB2 section 2.1 - * It is used only for TCP transport + * Skip the RFC1002 length defined in MS-SMB2 section 2.1 + * It is used only for TCP transport in the iov[0] * In future we may want to add a transport layer under protocol * layer so this will only be issued to TCP transport */ - iov[0].iov_base = (char *)rqst->rq_iov[0].iov_base + 4; - iov[0].iov_len = rqst->rq_iov[0].iov_len - 4; - buflen += iov[0].iov_len; + + if (rqst->rq_iov[0].iov_len != 4) { + log_write(ERR, "expected the pdu length in 1st iov, but got 0x%lu\n", rqst->rq_iov[0].iov_len); + return -EINVAL; + } + iov = &rqst->rq_iov[1]; /* total up iov array first */ - for (i = 1; i < rqst->rq_nvec; i++) { - iov[i].iov_base = rqst->rq_iov[i].iov_base; - iov[i].iov_len = rqst->rq_iov[i].iov_len; + for (i = 0; i < rqst->rq_nvec-1; i++) { buflen += iov[i].iov_len; } @@ -2197,14 +2185,14 @@ int smbd_send(struct smbd_connection *info, struct smb_rqst *rqst) goto done; } i++; - if (i == rqst->rq_nvec) + if (i == rqst->rq_nvec-1) break; } start = i; buflen = 0; } else { i++; - if (i == rqst->rq_nvec) { + if (i == rqst->rq_nvec-1) { /* send out all remaining vecs */ remaining_data_length -= buflen; log_write(INFO, -- 2.7.4