Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp944256imi; Fri, 22 Jul 2022 13:11:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1srqb2/L4Jmo1V05BYc+1x6CdMJWPsZf8OUE6bP42Tfy2NFa/gxQSgq1vFpAc2ACU9zwQIB X-Received: by 2002:a17:906:8475:b0:72b:12c7:effe with SMTP id hx21-20020a170906847500b0072b12c7effemr1168874ejc.337.1658520712993; Fri, 22 Jul 2022 13:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658520712; cv=none; d=google.com; s=arc-20160816; b=k/OM3EJKnITIPN3zjVAAqzf1hPfd/etTTH+0a0VsQ950oVXae9dnMkOiLla+/6/Kzy oDyN7zO1zFR8M1alg58DoLsld/7+ZbBGvnQtAlFZ3QJeTfXy6HianRSxg2LMofDoepqH CdbeVSZzbDlsH3483Pjsn3mm1z0d0JtNj8c0ZHoNhSnNa0H4rUr7fiWPL82nw+upsFYZ WQ1H6aeMy1ZavcUibbR8zt7TH/BqWyYbli99qLmexIyvXimEKuuH7ylJQqxmcDen326I FQVt5vpTyoiatH9lkhzG6a0+T4rA71aiLdwG+9gvHUW23mSMjiihsyqyv5JFvRiK5fUI Es2w== 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 :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=rTjfB3dLnjx4M0KVsw8r3eKcsKK49Lnf/ekPoSsaS8E=; b=Wz20FMfhleC26fkKaqgH2ELmw6WGHDWf0Jy3l71q30POKF/nfnHUAok88/NicV37sj Utc5plDUtpZZVbH9LsTwBDNJu/nhe1fF8/PP2ID4qokjURBXzaxLdXUg0C0kaoOaP1lw 6SAxs+kqy04nJBiNgb3EeLA5P9DzLO91ZL4J7vDkW9asE8G+7kYWtzSR9/aHEyMGTec/ /t062Q34U8+G1q6ZQ9i9YbKR9y+z7cURkvo26HZN1Zrr7V3tS52NbO3InKItyOOH1CYm prOGhVgcWPNFkEdQ7UkyDGx7ZwwJ3EjSvtB44KclejilG5o1RyMUTShx/0VoxqfzuxUc CYVg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a056402400400b0043bcb2968e6si3816824eda.619.2022.07.22.13.11.29; Fri, 22 Jul 2022 13:11:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236614AbiGVUJ2 (ORCPT + 99 others); Fri, 22 Jul 2022 16:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236713AbiGVUJ1 (ORCPT ); Fri, 22 Jul 2022 16:09:27 -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 741DEAF852 for ; Fri, 22 Jul 2022 13:09:25 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CDC0C61F52 for ; Fri, 22 Jul 2022 20:09:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29E8AC341C6 for ; Fri, 22 Jul 2022 20:09:24 +0000 (UTC) Subject: [PATCH v1 8/8] NFSD: Clean up nfsd_encode_readlink() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Fri, 22 Jul 2022 16:09:23 -0400 Message-ID: <165852056314.11198.9481263320352443620.stgit@manet.1015granger.net> In-Reply-To: <165852051841.11198.2929614302983292322.stgit@manet.1015granger.net> References: <165852051841.11198.2929614302983292322.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS 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 Similar changes to nfsd4_encode_readv(), all bundled into a single patch. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 71bac0039c42..358b3338c4cc 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4008,16 +4008,13 @@ nfsd4_encode_read(struct nfsd4_compoundres *resp, __be32 nfserr, static __be32 nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_readlink *readlink) { - int maxcount; - __be32 wire_count; - int zero = 0; + __be32 *p, *maxcount_p, zero = xdr_zero; struct xdr_stream *xdr = resp->xdr; int length_offset = xdr->buf->len; - int status; - __be32 *p; + int maxcount, status; - p = xdr_reserve_space(xdr, 4); - if (!p) + maxcount_p = xdr_reserve_space(xdr, XDR_UNIT); + if (!maxcount_p) return nfserr_resource; maxcount = PAGE_SIZE; @@ -4042,14 +4039,11 @@ nfsd4_encode_readlink(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd nfserr = nfserrno(status); goto out_err; } - - wire_count = htonl(maxcount); - write_bytes_to_xdr_buf(xdr->buf, length_offset, &wire_count, 4); - xdr_truncate_encode(xdr, length_offset + 4 + ALIGN(maxcount, 4)); - if (maxcount & 3) - write_bytes_to_xdr_buf(xdr->buf, length_offset + 4 + maxcount, - &zero, 4 - (maxcount&3)); - return 0; + *maxcount_p = cpu_to_be32(maxcount); + xdr_truncate_encode(xdr, length_offset + 4 + xdr_align_size(maxcount)); + write_bytes_to_xdr_buf(xdr->buf, length_offset + 4 + maxcount, &zero, + xdr_pad_size(maxcount)); + return nfs_ok; out_err: xdr_truncate_encode(xdr, length_offset);