Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3346654rdh; Thu, 28 Sep 2023 09:03:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEasOoB1CqJ61PCJ9cnvc7HxXh+4jDdZB/b7cSKQz87A8pY1CLd5jKrkINo0K02ri3G9aI1 X-Received: by 2002:a05:6a00:179f:b0:690:d008:8d02 with SMTP id s31-20020a056a00179f00b00690d0088d02mr1683548pfg.19.1695917025307; Thu, 28 Sep 2023 09:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695917025; cv=none; d=google.com; s=arc-20160816; b=hNvgPSjsA1sefjvOB6sLP2/+6QsyKi+yIjbNU5oNdV5CPGh5qAWXLPTc2cSVBOMLfP GvBA/eQCvHUrgIEIowqpIrfK13EbNduB+cga3NW8B9xuolBQI6bdR86+E4y4nx4oKCCB 9QFUcz1jNgfB0Ob3+bi4xX/qu/GMinLaBlm7m3vtAMLN0NXw/a5MvBQDb0p8TxVcchA2 By6Kfs+htuzJ/ZEUGP3HDn7i7tx6PLiYrepc6e4lUl6Jgvsq3H9DMGn0WJWwW5vQr6qu ilhWOyyEulfAdlPZ0HmwH4ziuD32E5pjfzRGCB7/w0FtuoejX9ZP2O0FxR6fEIUulAGQ mNPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Lf6zbB7cpsC0LUzVxploQbZGVjeNmiyysdG5No3aJYg=; fh=Q5QWD8ujztFxuR7D78J83h1yDiqvFffeocqAXneQJKk=; b=LTdUxl2jn+yM7BzqJd2RsyxsE5nDTYX68joM9o82yPlcjYYhi/AjnieqP/vNRkvG3N ewTM/p822MDvNsfDW0299nJMVKOdxj9u9UR/ULoJayTBYG31T40IoFswIGUJzxHEuJs/ 1BBV5CUHeh/k+HocaZ9ZDgqWm7At+RnfvQ6uNgfZcgK3/SqKUar0DoopPLEvO/OSxCAD g4HCWi39jB02C1rjjNNGdyk1G21rNbaNwplDx17IgM4r1vRgIaDRQhtEt8ioIM9J6QC9 gLS3KcJ2SE7Yq9n+rAb+19aUfpej1UW3Sr/4zLUeVRZwxHtPjxNJWIqv7sd7pPyAF8te rhqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cj7khq+g; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ct12-20020a056a000f8c00b00690fec2f3b6si18108829pfb.193.2023.09.28.09.03.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 09:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cj7khq+g; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 7BF2980BEB38; Wed, 27 Sep 2023 23:47:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230270AbjI1Grg (ORCPT + 99 others); Thu, 28 Sep 2023 02:47:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbjI1Gre (ORCPT ); Thu, 28 Sep 2023 02:47:34 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD070B7 for ; Wed, 27 Sep 2023 23:47:32 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-533d31a8523so11915413a12.1 for ; Wed, 27 Sep 2023 23:47:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695883651; x=1696488451; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Lf6zbB7cpsC0LUzVxploQbZGVjeNmiyysdG5No3aJYg=; b=cj7khq+gOUFFViUvJRsZQMMyAGj6TDWUnT/8Cv3LgBDf2YMmKI0XUS5zutafN7OX4Z 492S9o0nhP93DEvlcW/iEqHsTONf4rvfQODCTPPrYDseQaBT5wQXwL1nmh/GvG1OsU75 mOPWgbK/Wun+yb/MXSq2pAUk1G4iMDmdJulp79jckk9xZ6BFQcFJ8wvMR/TVILPjtGKg svIb0Tv6ukiPAcvNqwaUms5hL5TH4zVRz83kdKLMdUOcFUZDBc/mrLH57ZP/8JdwdWrV hu1piOyaclCPsw5GPtKvUQpw2+zo5xPNQRCEN1DJSduIvrXYIcV4q18g2Ygvdoh7LWCd lFLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695883651; x=1696488451; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Lf6zbB7cpsC0LUzVxploQbZGVjeNmiyysdG5No3aJYg=; b=pFFHfE8CLbUsmH0mY7Kju6NyIs13drVY74q8aL8ZAIjjPn1o7I0fTIKBynC6GoGYvg IRLBWpcuHzluDcP/iZsAD9wjtFksWiQ9are/Tpbb+Cx5Ndk2NpZZltqcUzf1UlB13t0D uStWMXUUsVUm8jYBlkduxW5GuisjHSZ9e2CGSVWuwLN4RkCfPDn7IAdQTEIfYshBxLKx 5qrtlQ5NSeN12kNULQuoqQZN2nYZpEIEOWix6sWUqlGHOutGNLOQeZEpSW6PI0S9mrFh j9X/Sq1rd2wpQEytjItU+ALZBcHVU6PTI1aJrsmJHbyI20MvIKeemLN7B1wARiOuh16g Dd3A== X-Gm-Message-State: AOJu0YyJ+aXQCqqxK9DYDdDKMU17mzX4dbYXkdk2n9nhbPffH993HxIz F8YRusXOpXvrKBGfaqPw4dg= X-Received: by 2002:a05:6402:646:b0:530:9d56:c2a5 with SMTP id u6-20020a056402064600b005309d56c2a5mr342843edx.6.1695883650400; Wed, 27 Sep 2023 23:47:30 -0700 (PDT) Received: from ?IPV6:2001:778:e27f:a23:36c4:e19f:3c1:8a8? ([2001:778:e27f:a23:36c4:e19f:3c1:8a8]) by smtp.gmail.com with ESMTPSA id l24-20020aa7c318000000b00533349696f1sm9163710edq.16.2023.09.27.23.47.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Sep 2023 23:47:29 -0700 (PDT) Message-ID: <8470f03b-0abd-497c-a4e4-3ea6ea042da4@gmail.com> Date: Thu, 28 Sep 2023 09:47:28 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] NFSD: Fix zero NFSv4 READ results when RQ_SPLICE_OK is not set Content-Language: en-US, lt-LT To: Chuck Lever , linux-nfs@vger.kernel.org Cc: Chuck Lever References: <169583500802.5201.6400721981172612933.stgit@bazille.1015granger.net> From: =?UTF-8?Q?Mantas_Mikul=C4=97nas?= In-Reply-To: <169583500802.5201.6400721981172612933.stgit@bazille.1015granger.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 27 Sep 2023 23:47:41 -0700 (PDT) On 27/09/2023 20.16, Chuck Lever wrote: > From: Chuck Lever > > nfsd4_encode_readv() uses xdr->buf->page_len as a starting point for > the nfsd_iter_read() sink buffer -- page_len is going to be offset > by the parts of the COMPOUND that have already been encoded into > xdr->buf->pages. > > However, that value must be captured /before/ > xdr_reserve_space_vec() advances page_len by the expected size of > the read payload. Otherwise, the whole front part of the first > page of the payload in the reply will be uninitialized. > > Mantas hit this because sec=krb5i forces RQ_SPLICE_OK off, which > invokes the readv part of the nfsd4_encode_read() path. Also, > older Linux NFS clients appear to send shorter READ requests > for files smaller than a page, whereas newer clients just send > page-sized requests and let the server send as many bytes as > are in the file. > > Reported-by: Mantas Mikulėnas > Closes: https://lore.kernel.org/linux-nfs/f1d0b234-e650-0f6e-0f5d-126b3d51d1eb@gmail.com/ > Fixes: 703d75215555 ("NFSD: Hoist rq_vec preparation into nfsd_read() [step two]") > Signed-off-by: Chuck Lever > --- > fs/nfsd/nfs4xdr.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index 2e40c74d2f72..92c7dde148a4 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -4113,6 +4113,7 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, > struct file *file, unsigned long maxcount) > { > struct xdr_stream *xdr = resp->xdr; > + unsigned int base = xdr->buf->page_len & ~PAGE_MASK; > unsigned int starting_len = xdr->buf->len; > __be32 zero = xdr_zero; > __be32 nfserr; > @@ -4121,8 +4122,7 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, > return nfserr_resource; > > nfserr = nfsd_iter_read(resp->rqstp, read->rd_fhp, file, > - read->rd_offset, &maxcount, > - xdr->buf->page_len & ~PAGE_MASK, > + read->rd_offset, &maxcount, base, > &read->rd_eof); > read->rd_length = maxcount; > if (nfserr) > Thanks, this seems to work for me.