Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp943990imi; Fri, 22 Jul 2022 13:11:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tpQBiyNY/2KlHqRlTuIJC4sp809PU7gG23lltYTA/i3sW6SB38UomWHOmZxwXctHtOMBy2 X-Received: by 2002:a05:6402:34c3:b0:43a:c323:274f with SMTP id w3-20020a05640234c300b0043ac323274fmr1529116edc.67.1658520688274; Fri, 22 Jul 2022 13:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658520688; cv=none; d=google.com; s=arc-20160816; b=v6g53Bu2HACHG320ui0fghIIcM+ebtJvgC6dPu403KBo4D8wQjojSh26G0yqxfmNIY 6qjDnMEFzRSjQmvnvtKwiOHyfJDPlJp2Q89oqnpv4mQSo2sHNac/Fn+dFHaJXd6+roP6 lYqC6l+2d0/j39hV1yMx9OeuFXcS7jr3SaHLaNrcOYMm1ehlYB6xCx1B007tMdSEbA78 PtrvG3hCL1Apg1SpABpQjM4zFodrGt0+zQPeWMeCNMqXOZ6nejxW3JtN7Cjind999M+S qw0/xVA49n2WRPpdnhoR/Qt1bzLEc90qX/NuK0XdKed+KwghxznvkcxPUNnphV/tIvwn kqtg== 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=RWU4iiTKGq7YKKxETTmQfJcOpywHsOJ0Dsue+NC8y7c=; b=cLIPmf4FuPwcdUWfZeyo9wCWO87RnPHdG49MJlAUupi/baWBezdppPCkz5YFyaBsRf t6QgC2kA2VYeUFNfonyhSxpZsAms0DxpcXg4hxVjanzMKEln43AykjVrDLwaD/BaFzrw K6yXSsub+zme3KZtOsAPaSPR1UijmG2fXY2HIPBwmVGGsryoz4bJKadV1Vu/l6i367oR XB6enc/uygm5IL039fLqtK/CxoopqfmUajOHbE3ysDD8oLr1TlD34OdWkPB9TvF3hBpL Y/eHS9LqI4iRiWI3nNuBaD6gAgbQD6OM49FDbDow5CgNaZPqsbEqN+L716P7VKKbwYcP dzkA== 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 z8-20020a05640235c800b0043bd505e0e9si2276326edc.458.2022.07.22.13.11.04; Fri, 22 Jul 2022 13:11:28 -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 S236681AbiGVUJX (ORCPT + 99 others); Fri, 22 Jul 2022 16:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236639AbiGVUJV (ORCPT ); Fri, 22 Jul 2022 16:09:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91E7A8941 for ; Fri, 22 Jul 2022 13:09:20 -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 ams.source.kernel.org (Postfix) with ESMTPS id 431A4B81EDB for ; Fri, 22 Jul 2022 20:09:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4F23C341C6 for ; Fri, 22 Jul 2022 20:09:17 +0000 (UTC) Subject: [PATCH v1 7/8] NFSD: Use xdr_pad_size() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Fri, 22 Jul 2022 16:09:16 -0400 Message-ID: <165852055678.11198.9033444688475970678.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 Clean up: Use a helper instead of open-coding the calculation of the XDR pad size. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 32f4f48458e6..71bac0039c42 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3940,9 +3940,8 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, { struct xdr_stream *xdr = resp->xdr; unsigned int starting_len = xdr->buf->len; + __be32 zero = xdr_zero; __be32 nfserr; - __be32 tmp; - int pad; read->rd_vlen = xdr_reserve_space_vec(xdr, resp->rqstp->rq_vec, maxcount); if (read->rd_vlen < 0) @@ -3958,11 +3957,9 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, return nfserr_io; xdr_truncate_encode(xdr, starting_len + xdr_align_size(maxcount)); - tmp = xdr_zero; - pad = (maxcount&3) ? 4 - (maxcount&3) : 0; - write_bytes_to_xdr_buf(xdr->buf, starting_len + maxcount, &tmp, pad); - return 0; - + write_bytes_to_xdr_buf(xdr->buf, starting_len + maxcount, &zero, + xdr_pad_size(maxcount)); + return nfs_ok; } static __be32