Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2108451imu; Sun, 16 Dec 2018 17:12:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/X/DKv17gEZTYX2fbflOJa//tebx8+2J8NOIyo5+wp4kIuTX4eFfuJ8AaxIsJgkmQcXjz4t X-Received: by 2002:a17:902:a710:: with SMTP id w16mr10709372plq.95.1545009174605; Sun, 16 Dec 2018 17:12:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545009174; cv=none; d=google.com; s=arc-20160816; b=ZTPiHy5Wegpk5UDLVN4GmFHUIqRKAXYH+nIM1GuZVHOSlOMe0wdT9k/emPdA0FAZly arnWGe/su0aSlw7Wcyxzldg+IGMjnXEnDBb4n05US2NBrXe3SaM2OsBySQjLo79D9Knm YSxCVC7YaE2j96qDlQVzdsL/w3UticBglGVPl0PQ5Kleu78Vcsg0X+BDtHGg606m65f1 9Jdb9nOStV3Ge7jUoIvxHksqbMNqYRMMLXqZN1Cuo8d9FJRiZ7Hp1Ts2NpRVkDjNYkDo 68IH2k3nasvXQymxaFMVAxsxQnCmulW8FPC+MIWQbGgDITMPP573zsKHT62mPpplkHzQ vrUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=kZfzqrdlmUEK7uy4IJXAZ/6CppMnpHEst4Rv/O6u1lw=; b=u/u9A7JzsxVjzUjpJvvv+S2EiFlDm1tz9W/K/cyRAer33l0Fi9SioduzFT+WCv4OtJ jjTKHnOCjOCBIKwLbmoA1yyD/8jjDS3HPHkLwzAzm5zUWHvnc2z0AwDbi5ICkw6SkfSc Urle+PXITwoMcX26Hv0S5b4vka6tuW2n7H9NqvEwavcPJu28f/saZTmWftZIMDvpTVg9 uP70iBrW4SJuBR2KbQlm0U3pYMJ6YLDTUiB5edrsjGcPfJTHfi1j495M6cG/tJA1gWFn aualv18h+3nPLDoZp/LmTTBMwtb3Ot2kEAwRK4D0ngdzKP7QK/1SIDL3k55Phvg5q2yc 2jEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HoZ6xO0T; 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 p8si9587450pls.83.2018.12.16.17.12.39; Sun, 16 Dec 2018 17:12:54 -0800 (PST) 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=HoZ6xO0T; 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 S1731258AbeLQBKk (ORCPT + 99 others); Sun, 16 Dec 2018 20:10:40 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37226 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726262AbeLQBKj (ORCPT ); Sun, 16 Dec 2018 20:10:39 -0500 Received: by mail-pf1-f196.google.com with SMTP id y126so5497785pfb.4; Sun, 16 Dec 2018 17:10:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kZfzqrdlmUEK7uy4IJXAZ/6CppMnpHEst4Rv/O6u1lw=; b=HoZ6xO0TmJkMuYWappGU74V8CCcEoWsxQR73deX2XER6R0cbTwrA2fk6/Q07XhH+Pp tI+KifVHFMIGxDGBcsxujSagFekNiZxjfh20maEhUOcd01qYRjJ9ZUKPjDKwqsQlIRf7 +l4hb2toJ0fnWXZxXZTL+X7nUzKZ7NJNYcuFpHXjg/1FB91q0uculMurol/RFPl0vUGu T+j/RA3w3r9Ebjrd8hE+JTEGqpUNIKpTvYaI+pUH216obPcIK7ybzPdwqdnAvwGNOs1h azbwP6qeQyPpA9JYCn3JjDxM7jaKeWDj9h7VWXX0Ed7VNPV0xBMPWin9hrzrfcV4xoeX 4Yyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=kZfzqrdlmUEK7uy4IJXAZ/6CppMnpHEst4Rv/O6u1lw=; b=Fr3/EWNzefc0sceJgBrxWqWAblZZY6resXtdPNqIO744EGhNIiON+VnJv5qD4ANG9M 9CW9YaVfaa8oa4gbvCNZL0qXXfhnzbntGdYj6Fb/VUZlzyTBL9DN7NhEy730kF5kmBLB 6QUHOzAvOFY1K4OwMadLxroZ/i/R1WRyVrqfRjwl+MvpH72WOntYDwfDa8YufjuXN3UK 06oMsA7beyhyVwR4pG+9x5h8FZ0r3gqbWdkjak2vm8J4aBzOR9kLGEde3WVrUtPfxHBy HZih1gi0ul1qp6WmfuAZIZohCbV5Ny83x/z327SAGvz4HrznTmk3R/k/9J5CBD++iEyB iqdg== X-Gm-Message-State: AA+aEWY/TPDCaiXRMZNg8t3JoLwaoAJnpcIGUiOFTka3MRM3G3Lu/TeA put4HZmpooGGvgt7pXZ94idyV746 X-Received: by 2002:a62:4549:: with SMTP id s70mr10871062pfa.233.1545009038309; Sun, 16 Dec 2018 17:10:38 -0800 (PST) Received: from gmail.com (cpe-98-150-136-16.hawaii.res.rr.com. [98.150.136.16]) by smtp.gmail.com with ESMTPSA id f62sm12162098pgc.67.2018.12.16.17.10.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 16 Dec 2018 17:10:37 -0800 (PST) Date: Sun, 16 Dec 2018 15:10:35 -1000 From: Joey Pabalinas To: longli@microsoft.com Cc: Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, stable@vger.kernel.org, Joey Pabalinas Subject: Re: [PATCH] CIFS: use the correct length when pinning memory for direct I/O for write Message-ID: <20181217011035.ykal46ixowdqyl7h@gmail.com> Mail-Followup-To: Joey Pabalinas , longli@microsoft.com, Steve French , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, stable@vger.kernel.org References: <20181216231704.16761-1-longli@linuxonhyperv.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="idxsf4dcv7fappfg" Content-Disposition: inline In-Reply-To: <20181216231704.16761-1-longli@linuxonhyperv.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --idxsf4dcv7fappfg Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Dec 16, 2018 at 11:17:04PM +0000, Long Li wrote: > From: Long Li >=20 > The current code attempts to pin memory using the largest possible wsize > based on the currect SMB credits. This doesn't cause kernel oops but this= is > not optimal as we may pin more pages then actually needed. >=20 > Fix this by only pinning what are needed for doing this write I/O. >=20 > Signed-off-by: Long Li > Cc: stable@vger.kernel.org Looks sane to me. Reviewed-by: Joey Pabalinas > --- > fs/cifs/file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/fs/cifs/file.c b/fs/cifs/file.c > index 3467351..c23bf9d 100644 > --- a/fs/cifs/file.c > +++ b/fs/cifs/file.c > @@ -2617,11 +2617,13 @@ cifs_write_from_iter(loff_t offset, size_t len, s= truct iov_iter *from, > if (rc) > break; > =20 > + cur_len =3D min_t(const size_t, len, wsize); > + > if (ctx->direct_io) { > ssize_t result; > =20 > result =3D iov_iter_get_pages_alloc( > - from, &pagevec, wsize, &start); > + from, &pagevec, cur_len, &start); > if (result < 0) { > cifs_dbg(VFS, > "direct_writev couldn't get user pages " > --=20 > 2.7.4 >=20 --=20 Cheers, Joey Pabalinas --idxsf4dcv7fappfg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEENpTlWU2hUK/KMvHp2rGdfm9DtVIFAlwW94oACgkQ2rGdfm9D tVJDVw//YlX/0LsP6eZyP08m4OT21ajO8bNIkFqd+jLFVEcIlm/Nk0f+gxxcIwiJ y+Xt6rSwl3tyypQKvIh2ba6XdgFM+Ti3O7jb/6oiE0guwLhh1WUA4iQhPgDjBPrJ rzvsVaEB2LQpXOzPQd7zFcpvx5wJO8S13ZUpeaSUvA8LpbKQTf0Oh2u6WUOf2guo gfMJixovSgbl2kpTiUSd8gqh5Bw51zsyLTFsnE8GFx30liXzZ5zxguMXKPu41rQa uWfyK0A1LFzniBL9x0aDciYiL2qZZbyCY1BdKJTwqxFqX6VmHGGNlODguLdYAY6V mp3wt2EyXbGwt1yYhhkXEwFgYuNsdYYvZOGLhElIrvMBH27QtX52sPW3pIv2+vS2 8BZpHyOTuCJ/zC9EsOkK3dyHrCdh9wSk6VDycSKrBfNCDSyNSq1FZJaujzOk6TP+ uFBO0PDpi222KzBf1LuGVlLOZlHGMbrrZZTpIyFZwLnLP4kh/c0qdJCrdXgyMMYd biu/SBjt84+zvGIfLyXuq/5uJYUyesWaTpYWatpg1ohJ5QxIfCJb2B2YdniZ6fad m5tB2+E4Hy2xM4NeNiMqYm0dP2KgR8fFzoOe86Aqe/A+ufGAEaMYCh/XWieozVXO duE7ft8m5IQk/SgbvpCnhW1lYV3zm0K527wSaumYgxCYxcROs0Q= =bRcp -----END PGP SIGNATURE----- --idxsf4dcv7fappfg--