Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp125908rdb; Mon, 18 Sep 2023 09:57:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGeHHR/hzchZ2RR81BX3IUhnVuUjL2WlGcEjq7BELCNyou2nOUshjAu1pQ7KI1yE6c/4Smv X-Received: by 2002:a17:902:f68f:b0:1b9:ea60:cd82 with SMTP id l15-20020a170902f68f00b001b9ea60cd82mr10942474plg.5.1695056256196; Mon, 18 Sep 2023 09:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695056256; cv=none; d=google.com; s=arc-20160816; b=J4CqtSjV6DRI7kjHGQTqMh2l0/L6d0WSjZh0MRbxVwouZKjwkQUnyhBgz0b69lpVZq fDDdnQtqXIiqmXNGzmgJN+gBZ+zQoDVNdO1Wr4VEct9AyizbZ94o+Ofb3Tb6B8cJMmsd ZDZiNIatIf7Kmp0Ju4ku7gqRTGNPcG2HgeK7Vb/ogb+9zCHHOal3H25acYvnX1xYAn5x 0SPrbuMBtjtqqTird+iEBhcHGJiPNJ2YWJXKMDCRxCCvrm3TlsvRm4Fodzng3nWbxS1t ZM1Jm+HVXFzCNAH7F6QvRvtVuqIPRm0SbbSeKxwYPwOzhdw0ULRUYyWBNxHgAq2kXAbu thmw== 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:cc:to:from :subject:dkim-signature; bh=TyD+3pVentD+Bn/ku8PM4vD+fZ0XlbUvSS8NhL5XCsg=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=yoPuJ0xpIcDFeq1hIVUM9vJWjpbn0RTTxmqNiYl0cXAeivegA5sQaQS5DZDg45ypQV cj1Zy3AVjic/su0iEeiYmVk8mHcw1KI2dYFDIIJNYejSRTlMEMkEQcGJO01SxPZGTDDe 3q6hvpIBo6UgvV0fPSSgevvVr0mmCbKZQb0s7uuE3BQ0sKv2i71gfUTCx0drThfvUkaF uBfkoi25ZxqZ7im+osn+uao58v6aXgWeZkreP/88KmS+C7sDxO+65YcTrxuLj0xH+IZz qu5MbgaNnzmf/gynXjqCBE1ycTZp5IibjwfOeAL5VLol9M4LYz7ydeuB/cReiU8qFdRC 9Q4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MNUvVqK5; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e5-20020a17090301c500b001bbc7ed95efsi8729555plh.44.2023.09.18.09.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 09:57:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MNUvVqK5; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C2FE58080D66; Mon, 18 Sep 2023 09:25:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbjIRQZh (ORCPT + 99 others); Mon, 18 Sep 2023 12:25:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbjIRQZd (ORCPT ); Mon, 18 Sep 2023 12:25:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 914872547C for ; Mon, 18 Sep 2023 09:22:40 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 035F5C433BA; Mon, 18 Sep 2023 13:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045428; bh=ivYlbbAmiVVZYNkuHJx1W3/ofNUn2OJQ7vClkjK6ed4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=MNUvVqK5CT7jzFctXirM01STWlsprXNaXTwz2HollLyjpnN5spA0OVyV22qs9rIDt BVKre+k/EFm9sdE+BshdjnUqcycAj6cWhUPSSHGcZtnvT5nfztef2RHVS8kQcrNqHK k1ASifW03pu+dP2F7GqZKspNyOsbPOa2qLIzj1gNjdzmi5hFfMJXjh885uZFyvtdAx XvG+mme5Qdve3QvoLlppRYVCfbClXL9c+rcWE/xHuT7G9HglQmUzy18PFF6P12dBB4 7jA7JYQcyxuJ5ucHUwcvfak+vlZ9nqGphmIjc4qeP3Lh31+ZCpGYS7uDQp6/kZwukw Wyp9UgIUo9ONQ== Subject: [PATCH v1 03/52] NFSD: Clean up nfsd4_encode_setattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 09:57:07 -0400 Message-ID: <169504542705.133720.14718638463977967182.stgit@manet.1015granger.net> In-Reply-To: <169504501081.133720.4162400017732492854.stgit@manet.1015granger.net> References: <169504501081.133720.4162400017732492854.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 18 Sep 2023 09:25:35 -0700 (PDT) From: Chuck Lever De-duplicate the encoding of bitmap4 results in nfsd4_encode_setattr(). Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 84df0f36c15b..8715a43a70c4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4427,34 +4427,25 @@ nfsd4_encode_secinfo_no_name(struct nfsd4_compoundres *resp, __be32 nfserr, return nfsd4_do_encode_secinfo(xdr, secinfo->sin_exp); } -/* - * The SETATTR encode routine is special -- it always encodes a bitmap, - * regardless of the error status. - */ static __be32 nfsd4_encode_setattr(struct nfsd4_compoundres *resp, __be32 nfserr, union nfsd4_op_u *u) { struct nfsd4_setattr *setattr = &u->setattr; - struct xdr_stream *xdr = resp->xdr; - __be32 *p; + __be32 status; - p = xdr_reserve_space(xdr, 16); - if (!p) - return nfserr_resource; - if (nfserr) { - *p++ = cpu_to_be32(3); - *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(0); - *p++ = cpu_to_be32(0); - } - else { - *p++ = cpu_to_be32(3); - *p++ = cpu_to_be32(setattr->sa_bmval[0]); - *p++ = cpu_to_be32(setattr->sa_bmval[1]); - *p++ = cpu_to_be32(setattr->sa_bmval[2]); + switch (nfserr) { + case nfs_ok: + /* attrsset */ + status = nfsd4_encode_bitmap4(resp->xdr, setattr->sa_bmval[0], + setattr->sa_bmval[1], + setattr->sa_bmval[2]); + break; + default: + /* attrsset */ + status = nfsd4_encode_bitmap4(resp->xdr, 0, 0, 0); } - return nfserr; + return status != nfs_ok ? status : nfserr; } static __be32