Received: by 10.192.165.148 with SMTP id m20csp3561966imm; Mon, 23 Apr 2018 08:34:00 -0700 (PDT) X-Google-Smtp-Source: AIpwx49CuLSRLCAGybe0DSKgi2xvHGMt19N+fNgZ1kpb4Oll2hh7vDZIyNTKEz16uqUgAEk7Hu8+ X-Received: by 10.98.70.8 with SMTP id t8mr20460689pfa.185.1524497640676; Mon, 23 Apr 2018 08:34:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524497640; cv=none; d=google.com; s=arc-20160816; b=thKph0aoK2xw86JXZ3SnSSrwmR71qnp1eD9TE/78SbJPYHYjVE5eG6lqblmJOb6BfG UoLNgSYGdybZ/LwmNcEbUqS3nb2i5r86FDTf6M9ggUqWlov3X08ijOQY4bmXbGnuS6H/ +I7zCA9AskreTJRQ+1OyVoP0xBMY/0dDvZF2nnWcWJx2JD+DZBJl1Rt7OP1g6ei9CIal /RiSkcI+sZ+EWbWE2zIKvcXI2tG3q8yF4ptC6hEFHkvSfqQwpyZzkh/79fZVMp2M21hL OPnXSlB6YHd7a/OoV5c78h9Aa58V/NE76qM1piFMUeb2j1qfa/ADc1DoILmeOVAZN8XU G6uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=bDh5a8s9NYblPZJRL2cnQHZwQnl4Zdh/kXeFH4mHUVA=; b=o5UfHZmraNJz284+LrkFFPju8I6vCYCyvJH8ChJoK2/xL4hlE2gGz100Flx63DwoCt /zfQjfDXaqsJzlXuOc4/RqBzkTu1sub/365z6tK2j5pFGOmkokBeCOmhtlCtNSrCvmKL H24v24fcNgehIRBMrSyCDNYUotVP/PWCJDcQMfWZkxs0gNVmCkpzZexBK+AUQ6UTk5Xr vVWewjc31Sxbfq/ql9kMEl2xgf4H8TbOvs1zE2P7KmNaqQBgBRlaXZr2HPfPbmRY/3/u CM84tQJyK9QHRInxVTnTs2HeOfgAHi6gEbovE5cRYOk/4UjCdXx9vqvinAIjbiaXl5Ok vvxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M9Z7R8sQ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x124si10088965pgb.651.2018.04.23.08.33.45; Mon, 23 Apr 2018 08:34:00 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=M9Z7R8sQ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755713AbeDWPcQ (ORCPT + 99 others); Mon, 23 Apr 2018 11:32:16 -0400 Received: from mail-pg0-f66.google.com ([74.125.83.66]:35527 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755244AbeDWPcN (ORCPT ); Mon, 23 Apr 2018 11:32:13 -0400 Received: by mail-pg0-f66.google.com with SMTP id j11so8648385pgf.2; Mon, 23 Apr 2018 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=bDh5a8s9NYblPZJRL2cnQHZwQnl4Zdh/kXeFH4mHUVA=; b=M9Z7R8sQxrU8js6Dv5YUO6necB1bXOHphFCTisGvVr5L/dVY4FGGcRQmf3t+ekYdnu ZC1/ykDHGWmHd16I9CkyEzGhC4LX6W8OC3KYQ9RvEjkfWYQe3umJWWG0DfTuyyW4S7iT htmZ/WESiKPG4aRlagw4KsgNZF+bkHnHuNquaRLlc4PqEsjo90fe5L5X1Nt1XB3fbROQ zTIX10994A5ZUBRcef3/tCyf8Zrw8GPj0bdmVapKfDkAw1AIpAKO/NYpZ/NBZ/wnzTwO 9lUuP+9Cpf6b9Su2sBDbmWJN6ILtxtBfXA2jA8U+Zqyy+LJXpal9Gv6XrJDt2D5ZYwDX 9diQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=bDh5a8s9NYblPZJRL2cnQHZwQnl4Zdh/kXeFH4mHUVA=; b=OWKfHzC3AwRbr1QzPfOyLpA/vDEn90ssRO5znyFdDmZ4FrPQGUVKg0R/vZwHXMWtoL G4DEu7siDQGWPtosJWsYfqJ31jzX4Iuq6pK5cIIi6GRhb0Zf1SPGEgCKyIcmDaH/DJSC E7/wQ0oEHf37NUnXuk9P3PPxd+FhESI84rf1+MvhJx+F2sxnxJeZ5o++dGP2eCuqK0aN hGgik7K/8yeK8BFQFELfqHo+dnNGFW8TO2QMAyjw1AohaceSOCPX5/KOOcLf1aGHgGJk uW3RVgwypRkYbPwfu20x0utH/7CoRcGU9Ave7XjT83gfpsp5d1SI9q4CWAmDHeNeU5Hr 02Kw== X-Gm-Message-State: ALQs6tDqWejk3bK6OxnM70WFrF+nG62ivSbtlMgdbMSkFmX5hRKyQbV0 2IqB6ccrO6ZqRtVW0XzcbFAgjw4D9gApJyPrVUhCpaPn X-Received: by 10.101.83.139 with SMTP id x11mr17775760pgq.15.1524497532444; Mon, 23 Apr 2018 08:32:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.152.97 with HTTP; Mon, 23 Apr 2018 08:31:51 -0700 (PDT) In-Reply-To: <20180417191710.14855-3-longli@linuxonhyperv.com> References: <20180417191710.14855-1-longli@linuxonhyperv.com> <20180417191710.14855-3-longli@linuxonhyperv.com> From: Steve French Date: Mon, 23 Apr 2018 10:31:51 -0500 Message-ID: Subject: Re: [Patch v2 3/6] cifs: smbd: Avoid allocating iov on the stack To: Long Li Cc: CIFS , samba-technical , LKML , linux-rdma@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Didn't see any obvious problems, but can you fix the checkpatch warnings and resend to the list (I am more concerned about the last two warnings rather than the first one). $ scripts/checkpatch.pl 0001-cifs-smbd-Avoid-allocating-iov-on-the-stack.patch WARNING: line over 80 characters #60: FILE: fs/cifs/smbdirect.c:2106: + log_write(ERR, "expected the pdu length in 1st iov, but got 0x%lu\n", rqst->rq_iov[0].iov_len); ERROR: Prefixing 0x with decimal output is defective #60: FILE: fs/cifs/smbdirect.c:2106: + log_write(ERR, "expected the pdu length in 1st iov, but got 0x%lu\n", rqst->rq_iov[0].iov_len); WARNING: braces {} are not necessary for single statement blocks #69: FILE: fs/cifs/smbdirect.c:2112: + for (i = 0; i < rqst->rq_nvec-1; i++) { buflen += iov[i].iov_len; } total: 1 errors, 2 warnings, 65 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. 0001-cifs-smbd-Avoid-allocating-iov-on-the-stack.patch has style problems, please review. On Tue, Apr 17, 2018 at 2:17 PM, Long Li wrote: > 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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-cifs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Thanks, Steve