Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp491799pxb; Thu, 19 Nov 2020 06:33:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxV5vBgnaIPEF9GuNFGowff4JWAIvvJdpnbQ/pypDyS3eCUmvezBkavHr+i33+U08BjhDiT X-Received: by 2002:a17:906:29db:: with SMTP id y27mr24501005eje.179.1605796420709; Thu, 19 Nov 2020 06:33:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605796420; cv=none; d=google.com; s=arc-20160816; b=sv7EQsBw+rMeIQR61u+m3feGpzI0sJysp2PPGE2TaKqRXkMNn61aqEYqepobzwsg1Z vhohJlLxmttXWYTA7fdys3o36L4Z3Ga+1v5Hwz23VU6iA6SbBh07N++Ph/GORdXGM4Cf 4QJSExyBn1rtBpZEl2Auhzm/wlYQgemATCdpDZX1t0vHe1+JLeiSpDw5B5d9ttoKG5cR DpE0rsh5esr82nCuJQHABdyR2I6XHJi44Bc2KssUofHWB3IPHkR2BNqgb2BmOa2XnquO 6RtlVd5gPWSmIzH8zdMfbZ9u8ycYBkMDNUtYkE7Aknij29rhdmfDA2eJ4zhBsOt1XABq hwRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=oMpiwxKVNfLdH1qxpf9A/rN0fFqqRP0yDDb/OgBMWVU=; b=T0W+voWFPNeisytESW6n3n14akBKvAuyoKz8WafSX7AODt5qf30EpnNSvknHbkRPnh mVXIkMSHKK7J00Px5/cEb7QeX3CMlM/wYZmfsoPEjKUsUwuT1A9C6XMeaeSBXv2QPXmB DXMKvAdTZ1QcFLfAL4nRoyuCwEBnSvVde7mW9HpLxBZ/76jK8CQI72n83+5ltx1UPI/m 4kXsEdXz8YfxqgXRnrT64I0tJLegj2duQC8w+cKhKv1mkKDwTgCHVRIQ8Q8O/kQweCDx wd07AmBdKEP/bHy8qjUEbXSVG4AVxRAbunbSJxRoVn9pWMIwUYjj3Ukih+E44vUPVWgr QUDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=irBBfunH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z20si2954566edq.601.2020.11.19.06.33.16; Thu, 19 Nov 2020 06:33:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=irBBfunH; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727950AbgKSOcF (ORCPT + 99 others); Thu, 19 Nov 2020 09:32:05 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:55232 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727513AbgKSOcE (ORCPT ); Thu, 19 Nov 2020 09:32:04 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AJEOaBA119297; Thu, 19 Nov 2020 14:32:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=content-type : mime-version : subject : from : in-reply-to : date : cc : content-transfer-encoding : message-id : references : to; s=corp-2020-01-29; bh=oMpiwxKVNfLdH1qxpf9A/rN0fFqqRP0yDDb/OgBMWVU=; b=irBBfunHKRqqsY76mmOQdXzVCwb3ci9jOmmiu+CkK09wL7moJ4T5KvB9meaKe2S+a3Oz KHxWZMYLSZq9rHYZXxRJH7YytEWbcBdQoIfe1BZYwic2wIEAv8YXFz+H34AEr9f3p0pH uGvo9dBpskPtrTdqoIfQy3FYi9RFk6pK2yWOwAnIrFduqCx7Yccpf9pC+HSZ7LhEihNT huxot2B4pyKp0TVzXhboYqMvr+XkcvZ9icjzlp0WrhjyUef/JOmrngnQP/OeCF4OPxdU NcS+Q1jgrfZOd9XJZNb4+8vYwrRkFITJFe383jkqDTTCAsLUDaMtV7yhxgxTIZrvevLt 2w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 34t76m5nnw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 19 Nov 2020 14:32:00 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 0AJEPh66039436; Thu, 19 Nov 2020 14:32:00 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 34uspw8c60-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Nov 2020 14:31:59 +0000 Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 0AJEVvpY030999; Thu, 19 Nov 2020 14:31:58 GMT Received: from anon-dhcp-152.1015granger.net (/68.61.232.219) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 19 Nov 2020 06:31:57 -0800 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: [PATCH 3/3] NFS: Avoid copy of xdr padding in read() From: Chuck Lever In-Reply-To: <57b085d32f624986412770d10cc4daa8211ee0f4.camel@hammerspace.com> Date: Thu, 19 Nov 2020 09:31:56 -0500 Cc: "trondmy@kernel.org" , Linux NFS Mailing List Content-Transfer-Encoding: quoted-printable Message-Id: References: <20201118221939.20715-1-trondmy@kernel.org> <20201118221939.20715-2-trondmy@kernel.org> <20201118221939.20715-3-trondmy@kernel.org> <42FFB4EC-5E31-4002-92FC-7CA329479D78@oracle.com> <57b085d32f624986412770d10cc4daa8211ee0f4.camel@hammerspace.com> To: Trond Myklebust X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9809 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 adultscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011190109 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9809 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 adultscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 mlxlogscore=999 malwarescore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011190109 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org > On Nov 19, 2020, at 9:30 AM, Trond Myklebust = wrote: >=20 > On Thu, 2020-11-19 at 09:17 -0500, Chuck Lever wrote: >>=20 >>=20 >>> On Nov 18, 2020, at 5:19 PM, trondmy@kernel.org wrote: >>>=20 >>> From: Trond Myklebust >>>=20 >>> When doing a read() into a page, we also don't care if the nul >>> padding >>> stays in that last page when the data length is not 32-bit aligned. >>=20 >> What if the READ payload lands in the middle of a file? The >> pad on the end will overwrite file content just past where >> the READ payload lands. >=20 > If the size > buf->page_len, then it gets truncated in > xdr_align_pages() afaik. I will need to check how RPC/RDMA behaves. It might build a chunk that includes the pad in this case, which would break things. >>> Signed-off-by: Trond Myklebust >>> --- >>> fs/nfs/nfs2xdr.c | 2 +- >>> fs/nfs/nfs3xdr.c | 2 +- >>> fs/nfs/nfs4xdr.c | 2 +- >>> 3 files changed, 3 insertions(+), 3 deletions(-) >>>=20 >>> diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c >>> index db9c265ad9e1..468bfbfe44d7 100644 >>> --- a/fs/nfs/nfs2xdr.c >>> +++ b/fs/nfs/nfs2xdr.c >>> @@ -102,7 +102,7 @@ static int decode_nfsdata(struct xdr_stream >>> *xdr, struct nfs_pgio_res *result) >>> if (unlikely(!p)) >>> return -EIO; >>> count =3D be32_to_cpup(p); >>> - recvd =3D xdr_read_pages(xdr, count); >>> + recvd =3D xdr_read_pages(xdr, xdr_align_size(count)); >>> if (unlikely(count > recvd)) >>> goto out_cheating; >>> out: >>> diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c >>> index d3e1726d538b..8ef7c961d3e2 100644 >>> --- a/fs/nfs/nfs3xdr.c >>> +++ b/fs/nfs/nfs3xdr.c >>> @@ -1611,7 +1611,7 @@ static int decode_read3resok(struct >>> xdr_stream *xdr, >>> ocount =3D be32_to_cpup(p++); >>> if (unlikely(ocount !=3D count)) >>> goto out_mismatch; >>> - recvd =3D xdr_read_pages(xdr, count); >>> + recvd =3D xdr_read_pages(xdr, xdr_align_size(count)); >>> if (unlikely(count > recvd)) >>> goto out_cheating; >>> out: >>> diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c >>> index 755b556e85c3..5baa767106dc 100644 >>> --- a/fs/nfs/nfs4xdr.c >>> +++ b/fs/nfs/nfs4xdr.c >>> @@ -5202,7 +5202,7 @@ static int decode_read(struct xdr_stream >>> *xdr, struct rpc_rqst *req, >>> return -EIO; >>> eof =3D be32_to_cpup(p++); >>> count =3D be32_to_cpup(p); >>> - recvd =3D xdr_read_pages(xdr, count); >>> + recvd =3D xdr_read_pages(xdr, xdr_align_size(count)); >>> if (count > recvd) { >>> dprintk("NFS: server cheating in read reply: " >>> "count %u > recvd %u\n", count, >>> recvd); >>> --=20 >>> 2.28.0 >>>=20 >>=20 >> -- >> Chuck Lever >>=20 >>=20 >>=20 >=20 > --=20 > Trond Myklebust > Linux NFS client maintainer, Hammerspace > trond.myklebust@hammerspace.com -- Chuck Lever