Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp943556imi; Fri, 22 Jul 2022 13:10:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tynhrczGniz9I3q2wRDUjpYGTrJV6/1MCOdqkbpRugRwsdt6fiV5mP6XnqaKMLWRgEHeB5 X-Received: by 2002:a17:907:97c3:b0:72f:4a1d:a7b2 with SMTP id js3-20020a17090797c300b0072f4a1da7b2mr1229565ejc.260.1658520650577; Fri, 22 Jul 2022 13:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658520650; cv=none; d=google.com; s=arc-20160816; b=E+8DdS7wEd5cTkkk6M+guOwq/m++64jSLE+RmclTUoUoXgKMlQ2xiu6DCXff7tAy2a GlJ7AKjoJ5qu2zP4Nw8BlRcpExJvfELMWLnodC0xU8NRa1JMA4n760TGRCjDFn0RnYo8 u/RbGQUGpNArPVdRR9W5AfBSB+Mt0u/rTcjJrhUozXX8qF6f2WV7ME+yD53TdQQcQIdq iMLb6DdXGK5OdoOgLB4US3lEi+T/mvuPr55LmLnRuytlQbwQDiyQt7rrrFY4s4GWyjqR WBRMe9WCVnZeLEkHKv11pl18pb5s+DTS5PnA9hqe1s4HOfuMce78D80QnghxEWqzqLIG kZvQ== 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=zHA5xc1GUn5D16XopSnOIpn5DeHav0QUrirhfPKqXSA=; b=QTHdXiY8/t+HlXFhPevFjBYKHoaj6KmYcNUupvUXRKv7kgvvkDnQOBG8FTvTzhjKGt 0n1So0td6R1U1LHZBxr5CEHSlxomcbEbyvxVjx0/Ep8r6HHYvZIDXhDlaJ7PDo/j4v3C vh2uX2j9zO1W+yuTIFzChu9k22e0Gu2rkItRZTcdeS39CZf2RJZB7GQYMnWnXbt3uuj7 wz/vr2D2Qa1YIR3AHKKiHmG3RQ+K08UceDO8VrFthEByB022HOwolB61z/AaqsUr8GCX xXUTcOwwJk9/0Aehkq3q9O0GejbH1WBRdmR11H115jadMz8r7OQWset2pAps1O8+4IS3 DgQA== 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 y9-20020a056402270900b0043abd755ebasi7264766edd.454.2022.07.22.13.10.19; Fri, 22 Jul 2022 13:10:50 -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 S236670AbiGVUJJ (ORCPT + 99 others); Fri, 22 Jul 2022 16:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236207AbiGVUIy (ORCPT ); Fri, 22 Jul 2022 16:08:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7134AAF862 for ; Fri, 22 Jul 2022 13:08:47 -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 0D0E661F5E for ; Fri, 22 Jul 2022 20:08:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64387C341C7 for ; Fri, 22 Jul 2022 20:08:46 +0000 (UTC) Subject: [PATCH v1 2/8] NFSD: Optimize nfsd4_encode_fattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Fri, 22 Jul 2022 16:08:45 -0400 Message-ID: <165852052545.11198.5880890758074740315.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 write_bytes_to_xdr_buf() is a generic way to place a variable-length data item in an already-reserved spot in the encoding buffer. However, it is costly. In nfsd4_encode_fattr(), it is unnecessary because the data item is fixed in size and the buffer destination address is always word-aligned. 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 b52ea7d8313a..e590236a60ab 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2828,10 +2828,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, struct kstat stat; struct svc_fh *tempfh = NULL; struct kstatfs statfs; - __be32 *p; + __be32 *p, *attrlen_p; int starting_len = xdr->buf->len; int attrlen_offset; - __be32 attrlen; u32 dummy; u64 dummy64; u32 rdattr_err = 0; @@ -2919,10 +2918,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; attrlen_offset = xdr->buf->len; - p = xdr_reserve_space(xdr, 4); - if (!p) + attrlen_p = xdr_reserve_space(xdr, XDR_UNIT); + if (!attrlen_p) goto out_resource; - p++; /* to be backfilled later */ if (bmval0 & FATTR4_WORD0_SUPPORTED_ATTRS) { u32 supp[3]; @@ -3344,8 +3342,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, *p++ = cpu_to_be32(err == 0); } - attrlen = htonl(xdr->buf->len - attrlen_offset - 4); - write_bytes_to_xdr_buf(xdr->buf, attrlen_offset, &attrlen, 4); + *attrlen_p = cpu_to_be32(xdr->buf->len - attrlen_offset - XDR_UNIT); status = nfs_ok; out: