Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp22867605rwd; Fri, 30 Jun 2023 14:00:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlFGjXPaXtxZpAQ7lnF9JpZln8gQDCCFNVcaGgiEDOzO+D7PmyIU0aVdR53E70ag9WQ3MOf9 X-Received: by 2002:a05:6a00:13a1:b0:677:bdc:cd6b with SMTP id t33-20020a056a0013a100b006770bdccd6bmr4388978pfg.19.1688158809194; Fri, 30 Jun 2023 14:00:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688158809; cv=none; d=google.com; s=arc-20160816; b=mpkCI2WpcDiqPVCEO8HbO4fW0wjwdJ1g7QEtfCVMHVJJk7iudhjMdAJjMu3ZY9OANY snC8BSE6DO+VU0bpmpWwJvqhUcdk5kBfw/za1Ybqo/95fKZM2i2sU5rC2XT5cNXbXesf rd12ht+yZLn9N1J8uVZXSf1NgfYgmsplSgzLUrnUB6Dpt9R+rIK9ArblzMu1IRbBWIau unboQzvDMdpiJoN/hTeMT9Z1fDho7iMaMDiVe57ebE9khdafsGFQ66tYNERVUmAbx1KV XNMSZqjtlLI2RmtM9XL0VwkUCNzUPZ3yxBVu8Yby+rS2MpJIFtR3RoyAgRR8VwsUS9cI zgRQ== 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=oyzD0FA9hHuLgqjSRVj9GXMez3jxCnR5RSWHrBO/OpU=; fh=zrf3k9maC4LGn/MmcHhRkqh5cHnarsSKx/fWXfAmYNI=; b=AKD5BJC+b2kIj9Q1ofkRIrLJIVRrYlFoHDedxNojcwKdE5aDE65kipzdnzUFMBnWOc N1TcgXLcboVkjPRdGVVzKBnGneVLYbD8Dt4MVQYnju/1EA+iN90VYg1x8d3HGWNxuI2n O8Pw8sBbTD1w9mc1bmncRwA3vBHTKZ4mrjgZiqFkx/EgXRyXra3pp2vqLbERstQMjySs /8KBs17A3gBOapoF+iNqarjauwpW4SlWwkgHDEOIi8ZFxf+lV/QVo0HoUrxpaymx1gMk tHmNPKqoNr3dokUaPaqClV6Tky21ZroQmeiXORFLyuNP133GTcjoMXNoQMuqdkxtc5bm jBUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Br5OcIos; 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 w23-20020a634757000000b0055373328de5si13127234pgk.204.2023.06.30.13.59.54; Fri, 30 Jun 2023 14:00:09 -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=Br5OcIos; 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 S232633AbjF3Umv (ORCPT + 99 others); Fri, 30 Jun 2023 16:42:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232113AbjF3Umq (ORCPT ); Fri, 30 Jun 2023 16:42:46 -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 1E9AF3C0B for ; Fri, 30 Jun 2023 13:42:44 -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 A8F6061834 for ; Fri, 30 Jun 2023 20:42:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF862C433CA; Fri, 30 Jun 2023 20:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688157763; bh=sZUdB4HXewAprQJemD6d+JaBNZUoLjQO4bIc7WuNV9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Br5OcIosY38Tu28LZ4/tYaDxN/2pSUDslf/+dx33epbirpqHduGqUoggUkaA98nJm 7aI2pso2CXDtWAr1bUzL6rafVEm5+asTaJs/OpniuhgwGiKmC8xYDHD4BZsdG9P5O+ eBPTUpDE/G/C3z3ZljXFw9Sb94DniayO2lK3Rx9b0EAqy8GtgU4uxYX+4gC+T/pANB ciXez98u6fJPD2jvNvcz7cTUjulNNos0RoFcpb9pFFt2jw1wG40sS3Lgvtf+ndL4Wg m2wfnKggHmNy1NvKQh/l1Kjsf1JzaEAqKDUAs98dNjUlJrjuqMkirrn+34doVXL8/I MHriQ5zngcV9A== From: Anna Schumaker To: linux-nfs@vger.kernel.org, trond.myklebust@hammerspace.com Cc: anna@kernel.org Subject: [PATCH v4 2/4] NFSv4.2: Fix READ_PLUS size calculations Date: Fri, 30 Jun 2023 16:42:38 -0400 Message-ID: <20230630204240.653492-3-anna@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230630204240.653492-1-anna@kernel.org> References: <20230630204240.653492-1-anna@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 ef3b150970ff..75765382cc0e 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -51,10 +51,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 */ + \ @@ -781,8 +787,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