Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1209906rdh; Mon, 25 Sep 2023 06:29:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkvdiDd4VxphNP/2D07efmR9F9fIWp+HNzTerF+0WI1PT6vMsT5q9P+HpguNPXVyTsoH/p X-Received: by 2002:a05:6a20:1b25:b0:15c:b7ba:6a4d with SMTP id ch37-20020a056a201b2500b0015cb7ba6a4dmr6564971pzb.50.1695648569739; Mon, 25 Sep 2023 06:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695648569; cv=none; d=google.com; s=arc-20160816; b=oHCWc3fkRSgTRNsVcdSAIgmu8Oede+OjHm6phhb+4kctePkrRkczrFXQcIKGN/PotA ufMYP1EM5EZ+bUpD23qrusFwQtPKr59FoeXzT5v+O9EEXwMbqKZScMdDRSW4tnJFHiat zVmhRxvv8yloTEQwBizIhjCvjpOUziR+dmE0KtHM+FVaZbRvhFiUH/MXuRaNUiFftAfv B0aWVgyacZB2Vf672G1ajsvKT7BbGYNT/8Pron7husOLa+C6vTWNY1V1Vg4YA7DMQJRY uspDPqR/rY+O0gOdF02c0DODyqkDhLCR//ZlxJ6IJNpVcA8l61jxMaOKqnD7DWcCUl7O 5rLA== 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=9QQOUfYlusOyeeJRfoYu804G3bW+ce1GvNotWC5Vv60=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=S7o0Iyasl7EbRitTUkhGlTqKMCKg2Bniyyd6+pDLQQDgo2fB//RENu91hu50QxaHUK g4vi6cRtFCgnY49t/SJUbhZkAYI/5gn1umAmhDSlc16+SGJW0pMM2GjgtvB5KQ2/HZAW fYnMKhgFg1yrZgoJmVB55EeLyDvv/prMTZDE1P9S8Jj1+qn65nIM21+BxoWxPUUN3x9m 4yWcIGyb2HljLDHhc6hpFYHFBfaHgtZ002tFnR8TJYloUAoT/3sDi9axZ73e00asHD5n 0Aw3Yq887UvO0IweIWv4RsYgZ4gt1T7YJkoU1cFMlKSM7DfzS6BH/Lzv9fpJZLNQapGM h7nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pkOWpyrf; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id f1-20020a056a00228100b00690d255b5a7si10747152pfe.45.2023.09.25.06.29.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:29:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pkOWpyrf; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 1D096811874B; Mon, 25 Sep 2023 06:28:17 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbjIYN2V (ORCPT + 99 others); Mon, 25 Sep 2023 09:28:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231803AbjIYN2U (ORCPT ); Mon, 25 Sep 2023 09:28:20 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5381911B for ; Mon, 25 Sep 2023 06:28:12 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C079DC433CA; Mon, 25 Sep 2023 13:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695648492; bh=SA+yZhDzYXp/u530y4wUu74cwlukkGC/kPghk3B5Egc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=pkOWpyrfO2XEkHH5mbCOFpHXncOJzu2H49ckvDtIDj/cb6rDMfPBmZqsofLF2Gp2T M3YVEq/QSs1Jt1zr9xFNa+kXRd4z1ZBwu9nuaSTZO+WgO/5nMNaE5Ti91sFap4MB6q Rnuy+xkdomSj+COovcm5L7El/pFvOVBC+CScW1dz66NCD5kYMrcQEIkpZoJEV2O8xU j6wsI46sq0Wp+A9NP3szFC7bZzJsDPlxzZ4Mu3fQncRIxlkxNeieFaEwSiB6ywotVh X8c/8Y03JslRofSUMzAyywH+hsacmrwGyXJRwSIOONrz99U8wRzVdxDQMb42o7ju7y a9El6XXdi9V2w== Subject: [PATCH v1 6/8] NFSD: Clean up nfsd4_encode_layoutreturn() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 25 Sep 2023 09:28:10 -0400 Message-ID: <169564849080.6013.9045083643257491751.stgit@klimt.1015granger.net> In-Reply-To: <169564827064.6013.5014460767978657478.stgit@klimt.1015granger.net> References: <169564827064.6013.5014460767978657478.stgit@klimt.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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Mon, 25 Sep 2023 06:28:17 -0700 (PDT) From: Chuck Lever Adopt the use of conventional XDR utility functions. Restructure the encoder to better align with the XDR definition of the result. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4layouts.c | 6 +++--- fs/nfsd/nfs4xdr.c | 12 ++++++------ fs/nfsd/xdr4.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index e8a80052cb1b..5e8096bc5eaa 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -515,11 +515,11 @@ nfsd4_return_file_layouts(struct svc_rqst *rqstp, if (!list_empty(&ls->ls_layouts)) { if (found) nfs4_inc_and_copy_stateid(&lrp->lr_sid, &ls->ls_stid); - lrp->lrs_present = 1; + lrp->lrs_present = true; } else { trace_nfsd_layoutstate_unhash(&ls->ls_stid.sc_stateid); nfs4_unhash_stid(&ls->ls_stid); - lrp->lrs_present = 0; + lrp->lrs_present = false; } spin_unlock(&ls->ls_lock); @@ -539,7 +539,7 @@ nfsd4_return_client_layouts(struct svc_rqst *rqstp, struct nfs4_layout *lp, *t; LIST_HEAD(reaplist); - lrp->lrs_present = 0; + lrp->lrs_present = false; spin_lock(&clp->cl_lock); list_for_each_entry_safe(ls, n, &clp->cl_lo_states, ls_perclnt) { diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index beba5677a1c9..38217ac74b01 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -4927,15 +4927,15 @@ nfsd4_encode_layoutreturn(struct nfsd4_compoundres *resp, __be32 nfserr, { struct nfsd4_layoutreturn *lrp = &u->layoutreturn; struct xdr_stream *xdr = resp->xdr; - __be32 *p; - p = xdr_reserve_space(xdr, 4); - if (!p) - return nfserr_resource; - *p++ = cpu_to_be32(lrp->lrs_present); + /* lrs_present */ + nfserr = nfsd4_encode_bool(xdr, lrp->lrs_present); + if (nfserr != nfs_ok) + return nfserr; if (lrp->lrs_present) + /* lrs_stateid */ return nfsd4_encode_stateid4(xdr, &lrp->lr_sid); - return 0; + return nfs_ok; } #endif /* CONFIG_NFSD_PNFS */ diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 1b393f1734e4..aba07d5378fc 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -630,7 +630,7 @@ struct nfsd4_layoutreturn { u32 lrf_body_len; /* request */ void *lrf_body; /* request */ stateid_t lr_sid; /* request/response */ - u32 lrs_present; /* response */ + bool lrs_present; /* response */ }; struct nfsd4_fallocate {