Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp69811rdb; Mon, 18 Sep 2023 08:28:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFRSml+ErUdDvezUSuvRlk7LlpAHOxQXk/yUGjWwRuwwTLaxe6qxxczfEbrAULLMMDCbPe X-Received: by 2002:a9d:6d96:0:b0:6bd:152f:9913 with SMTP id x22-20020a9d6d96000000b006bd152f9913mr10552379otp.29.1695050923209; Mon, 18 Sep 2023 08:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695050923; cv=none; d=google.com; s=arc-20160816; b=e/08PTN4gsxq2YthLhPnYcfr5U/wOYFIgu9L/zod64RDCSQPeJNDMy1TurEcEcHdpa AicdNvdI39NKd4VkGlUMIKz89sMp4CL4Ivy+iuUw1IWjLj9vA9gtjYLWRvmJp3gRqMnx Lx3dvETq8SL3aQBJzgaj3iwynpgP+GS/MbN2KO2lNcvWqecGzqrt7j4A3iHardcqmsFX lpkGE9dKezaFGoC/3X9lU/rzD/aMh+BJ1vm7jweNKNThV9z3D1ffitR1FgQ/eFIXfUZL aJ6dhg9jbDAc/GeMTr+fIz5yTEdyt0gO7KDjfzzBIa9Iybn+0NUVCw2goxU4qj1pFEP/ Deaw== 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=OrGf02gOkCQvuvJvuYe/fV4VqK/J1/SCzzumbE2R/6M=; fh=v8a13lpFSZWlL4AptTEJnmXnlqoWXhGCGCgvrcnCT9I=; b=1LPWNanjdjtZ1FBOWW/EKWMNFU0qHSWKa5QbiWugoG610p430MayvdAztCjI8M+07j cTODI9thuDf7jHp1PI3LaYcgnka/xYykgLQ+KjeIEw+DZ4gf+jN7/w2LiMxbTZUs1I0n rFk2yrumnDkyxc55xHEkyFydAgRv0uIEG0JiwEzxBGOZWmDZ/5hRb8lEEyi78UPr0Hmj AXhRa/d+HYONYsbuPib7TKzDGyh2AiDpj3ZQ2Cpf2nvG5C684ay3vdbYlS4kk2Yqf8uP XuvEkmfv6z6MZcqrgB9u4L/UhrR/zRx1dvPZPZFrrMFGl0a3v2iQgludXmWbmdctia5j Iaww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qxRxBMCk; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id az1-20020a056a02004100b0056a55b14f2bsi421127pgb.285.2023.09.18.08.28.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 08:28:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qxRxBMCk; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 965D381DE6B7; Mon, 18 Sep 2023 08:25:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234376AbjIRPZn (ORCPT + 99 others); Mon, 18 Sep 2023 11:25:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232935AbjIRPZm (ORCPT ); Mon, 18 Sep 2023 11:25:42 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC3ECEA for ; Mon, 18 Sep 2023 08:24:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C832DC116D4; Mon, 18 Sep 2023 14:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695045683; bh=J3LpBgaMi3k7+6kgzaZ4NJOFtzEpmNGp6BzTjh0Ny9w=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qxRxBMCkECQgoQsoUa3S7JKgOlSkgFkpXWxNu7yh5H52bOKkEiGpOYy/5QL7XvjiW Sj6bDu/WCv7taJCV14VwRY+Pex6Y7V4rvp5mvLY0OGbZEA/WVpapivW8UwiUrJgRMW QGF2JO71omO7+FlYLXZCytlfPhDE30FAQcqZtJtrWRN6tqxzp8OZlarqzPXXohN5UU n05Rul3bKtSPb8sHqy/ZD9w2FEMY24lPEIaq+IhoIShH5mQe4dRnM95sQtYKg3F/Uw tvbThu4G6Xw6tWeuYcDk9HUyZxz5DWbBBUhuw8M/xiZtQGR9ItFD3ujmiARwO87oVy PE/Xv6q5D0uSg== Subject: [PATCH v1 43/52] NFSD: Add nfsd4_encode_fattr4_mounted_on_fileid() From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 18 Sep 2023 10:01:21 -0400 Message-ID: <169504568186.133720.2744006796725296542.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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 08:25:46 -0700 (PDT) From: Chuck Lever Refactor the encoder for FATTR4_MOUNTED_ON_FILEID into a helper. In a subsequent patch, this helper will be called from a bitmask loop. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 730596c53258..929be84482b9 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2914,6 +2914,7 @@ struct nfsd4_fattr_args { struct nfs4_acl *acl; u32 rdattr_err; bool contextsupport; + bool ignore_crossmnt; }; static __be32 nfsd4_encode_fattr4__true(struct xdr_stream *xdr, @@ -3274,6 +3275,23 @@ static __be32 nfsd4_encode_fattr4_time_modify(struct xdr_stream *xdr, return nfsd4_encode_nfstime4(xdr, &args->stat.mtime); } +static __be32 nfsd4_encode_fattr4_mounted_on_fileid(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + u64 ino; + int err; + + if (!args->ignore_crossmnt && + args->dentry == args->exp->ex_path.mnt->mnt_root) { + err = nfsd4_get_mounted_on_ino(args->exp, &ino); + if (err) + return nfserrno(err); + } else + ino = args->stat.ino; + + return nfsd4_encode_uint64_t(xdr, ino); +} + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3311,6 +3329,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, args.rqstp = rqstp; args.exp = exp; args.dentry = dentry; + args.ignore_crossmnt = (ignore_crossmnt != 0); args.rdattr_err = 0; if (exp->ex_fslocs.migrated) { @@ -3622,23 +3641,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, goto out; } if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) { - u64 ino = args.stat.ino; - - p = xdr_reserve_space(xdr, 8); - if (!p) - goto out_resource; - /* - * Get ino of mountpoint in parent filesystem, if not ignoring - * crossmount and this is the root of a cross-mounted - * filesystem. - */ - if (ignore_crossmnt == 0 && - dentry == exp->ex_path.mnt->mnt_root) { - err = nfsd4_get_mounted_on_ino(exp, &ino); - if (err) - goto out_nfserr; - } - p = xdr_encode_hyper(p, ino); + status = nfsd4_encode_fattr4_mounted_on_fileid(xdr, &args); + if (status != nfs_ok) + goto out; } #ifdef CONFIG_NFSD_PNFS if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) {