Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6052728rwp; Mon, 17 Jul 2023 14:06:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlGwjVLA8CKFglWYAfq2GBssWfapBBnjiGCq90J1fWlNXohZuX0LvDO+puw6eWXmkx1/TFf2 X-Received: by 2002:a05:6a00:3995:b0:67e:18c6:d2c6 with SMTP id fi21-20020a056a00399500b0067e18c6d2c6mr19016092pfb.5.1689627983154; Mon, 17 Jul 2023 14:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689627983; cv=none; d=google.com; s=arc-20160816; b=a7LyoaZV3aElXuFzc054/NyIyXaq4eZEyDTxtC1UhEIwk85si+afRhaIfYPib5rkfR HWiwlTJ1lGXLkIMQNb0BCtk/piE8HWPQv7L7TPD7rIVwhSdRw5aGdhOwJDEkwYyYvnk0 UY7M10W2XsfllpU/bRAkschl62aLtVdWQ5LtoE2nnX/l4726yRaVJgarFFXoi58Q2+9D CeQO59+2WLEcETym7FpPmyd8tg2DVLH6kxV4sO+oX2hypOhohRvhcUp9x/w57P1Dln6W utzDDDDFKYeZgXpafntV7QkQPWfGfyDsuT8311zcsRylbNw4D0nX5K7o65CHdHTRKbBs 24OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NeI6IDpR7Qx96Gs++O64DoGnxQDDLxISWr2pxXBhWbQ=; fh=CLPq7QbinQSVZA7N65n4uhPiamQHST74TBceNWSqx8g=; b=W/vcGzOygBjSqqVU+APuW1V2SliMw31TYknF74+OgUOjcVWLNQ4ctZkqeV5kVLNKoo W4zBC9aOCZ/CNMp5duTsxtZPtq3mnrxYF6LEIyThNNTg1YoY2vUE+Ag81N4IaTj8m2Iw uB9Ut+4gJGeJbsL0QmW0Jlht/JMBhYMAFqeeGadLdS6tJuBnifkbJb+AzGLDVbuIjp37 pgQ6ddWyrwOxpVp3ilQkjd6Cm3r6++jNAvFKZ6Xx1HdPYR+1H5/ku0s8yGoC3a7l7yBM wqRl6v5wD8ZLS+0MCpD6lTfajds5xBi4Mruitn1L+FkKlkRTn4OZc3NRyDapTvVI6+6X achA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tmHgmvOi; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch7-20020a056a00288700b00660b5630927si384704pfb.133.2023.07.17.14.06.05; Mon, 17 Jul 2023 14:06:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tmHgmvOi; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229690AbjGQUxX (ORCPT + 99 others); Mon, 17 Jul 2023 16:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231288AbjGQUxR (ORCPT ); Mon, 17 Jul 2023 16:53:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E741702 for ; Mon, 17 Jul 2023 13:52:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8193F61265 for ; Mon, 17 Jul 2023 20:52:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89033C433C7; Mon, 17 Jul 2023 20:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689627161; bh=fR3gJSpm32obogOfvijfq+oe3qtayu6qbsZyOoujcHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tmHgmvOiV0TH4nT2gfYVEbNv+wKdyI2/vl4pIPmR4UgIahagfJvGWTJ2crMuwIq4j OBiDtTwMwodxIi9sUFbioL92p4DSay/9yshfZ7dBX4Q3S5zkuSyU3eTLuXcr/saUhE UdE4RpSKLmsoLhX9fMcpgpz4h80ye+rMQ3+BzaBxkV/toy5HElvEN3IBvcNvHBGUcB AU3e1QqySwv+9/OoD3/nvfPo2dcr7ZMtewkKnKQlEG2GJPE409pieBnOZiJBjRN4D9 66IsN5X5l3glLspTtnTS9cbjDfUqrucgw++hNsrQ2dZFubbor4N45QbBQGu5eqIsO/ XGO10B9WG1vdQ== From: Anna Schumaker To: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com Cc: anna@kernel.org, krzysztof.kozlowski@linaro.org Subject: [PATCH v5 2/5] NFSv4.2: Fix READ_PLUS size calculations Date: Mon, 17 Jul 2023 16:52:36 -0400 Message-ID: <20230717205239.921002-3-anna@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230717205239.921002-1-anna@kernel.org> References: <20230717205239.921002-1-anna@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker I bump the decode_read_plus_maxsz to account for hole segments, but I need to subtract out this increase when calling rpc_prepare_reply_pages() so the common case of single data segment replies can be directly placed into the xdr pages without needing to be shifted around. Reported-by: Chuck Lever Fixes: d3b00a802c845 ("NFS: Replace the READ_PLUS decoding code") Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index d0919c5bf61c..78193f04d892 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -54,10 +54,16 @@ (1 /* data_content4 */ + \ 2 /* data_info4.di_offset */ + \ 1 /* data_info4.di_length */) +#define NFS42_READ_PLUS_HOLE_SEGMENT_SIZE \ + (1 /* data_content4 */ + \ + 2 /* data_info4.di_offset */ + \ + 2 /* data_info4.di_length */) +#define READ_PLUS_SEGMENT_SIZE_DIFF (NFS42_READ_PLUS_HOLE_SEGMENT_SIZE - \ + NFS42_READ_PLUS_DATA_SEGMENT_SIZE) #define decode_read_plus_maxsz (op_decode_hdr_maxsz + \ 1 /* rpr_eof */ + \ 1 /* rpr_contents count */ + \ - NFS42_READ_PLUS_DATA_SEGMENT_SIZE) + NFS42_READ_PLUS_HOLE_SEGMENT_SIZE) #define encode_seek_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + \ 2 /* offset */ + \ @@ -617,8 +623,8 @@ static void nfs4_xdr_enc_read_plus(struct rpc_rqst *req, encode_putfh(xdr, args->fh, &hdr); encode_read_plus(xdr, args, &hdr); - rpc_prepare_reply_pages(req, args->pages, args->pgbase, - args->count, hdr.replen); + rpc_prepare_reply_pages(req, args->pages, args->pgbase, args->count, + hdr.replen - READ_PLUS_SEGMENT_SIZE_DIFF); encode_nops(&hdr); } -- 2.41.0