From patchwork Mon Sep 18 13:57:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13390036 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7C4BC46CA1 for ; Mon, 18 Sep 2023 16:25:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230109AbjIRQZh (ORCPT ); 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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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