Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3929869pxu; Mon, 30 Nov 2020 13:27:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrVrCPey0t3NA+gq3uLMg2ehJ/B8Nie8u+QQcLErtFfdUS7wwNEntbXO++2pEp2u96cdJX X-Received: by 2002:aa7:c712:: with SMTP id i18mr8851021edq.357.1606771679441; Mon, 30 Nov 2020 13:27:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606771679; cv=none; d=google.com; s=arc-20160816; b=Ip6HyemP1HDXuXymB5QAGaguU3jJXD6HNndE2T4pKkMHLLis6nIwxSK3bORnSJVQYw 92b44Zvt81SYHzsJyRbAU/ufn+HEbkyBW5j4Q0KxrQp4+vRGT8iGez6XHcOgSFxxyBGA jvqTLh+ZjQ6LfSszrOPsSLdSiPq9NSbSbOyJHHZrI8vUz/lB1bTJ2WGAY2kiBKiXwZRy /WUCfdaBycNIoOYFTW9yDyg3hMiv4TPRuPZZJmx/1V4oJ/2lqX2Sz0ctvLgoNWIRJvfM TH8WqOcVGW1n/+6hn79LLcIV8s88mDVIhqQdxJEdcrjBra/2G6jaWL8yel8ZjIOpzGhd TmRQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7ZSNI8VYDjpJp4/4zDkWO9TfGwHU1P+knHFkHkZXmGo=; b=EhV4zqSF/1LwxvOFCO33Zxz1Um6SVevV9w2SWmK+HDw1hkOwDZdjXR0yhCpUuyZl2s bdJk59az5oWp21ocQfAtE7KLIoI2JD+MlM3FSCq+G3NMv2MGVirU2Z4C5Tzvk5y6g3sW mniMAd4rLj3tqkIWezUGqNY9OBo0TMfX0yfPIXnmwlSXWn7KVR6ETLN952jsI+0O9el4 rHOjHQzt23Y245W7Ln7cQdnXt7E32DiVOZcxw231JPEXsGkNSgMZzgZy1FHpTPPbth/f Ht+G2mfdGjTmlOMXWSC5fCD4SbLAo/s+Kk5dgUxiK/zUodCd0XTajLV7g5p3TbRNz6dL Zxzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d4DOkHrx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si11308731ejc.144.2020.11.30.13.27.36; Mon, 30 Nov 2020 13:27:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d4DOkHrx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388604AbgK3VZo (ORCPT + 99 others); Mon, 30 Nov 2020 16:25:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:42092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388607AbgK3VZo (ORCPT ); Mon, 30 Nov 2020 16:25:44 -0500 Received: from leira.hammer.space (c-68-36-133-222.hsd1.mi.comcast.net [68.36.133.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 03576208FE; Mon, 30 Nov 2020 21:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606771503; bh=ehKoeRQqCtqwzwU9iqCAkFba82xZ6gMw2ZiEuos4uc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d4DOkHrxLeBCFtZxEAma1s/JgZC89G/UI/mO1JNbo9eqCJaG+8g726dOi0Ff4tzyi zukgVh4Zm5iNM3DFIL9r+uD6fdbjRHLfTJT/VfHCPBr+pqyfB249mORl9dMEgejt0v APKKM0nFqC4oJWnJzbBvS+6deGaV64/i9cTvKLiQ= From: trondmy@kernel.org To: "J. Bruce Fields" , Chuck Lever Cc: linux-nfs@vger.kernel.org Subject: [PATCH 4/6] exportfs: Add a function to return the raw output from fh_to_dentry() Date: Mon, 30 Nov 2020 16:24:53 -0500 Message-Id: <20201130212455.254469-5-trondmy@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201130212455.254469-4-trondmy@kernel.org> References: <20201130212455.254469-1-trondmy@kernel.org> <20201130212455.254469-2-trondmy@kernel.org> <20201130212455.254469-3-trondmy@kernel.org> <20201130212455.254469-4-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust In order to allow nfsd to accept return values that are not acceptable to overlayfs and others, add a new function. Signed-off-by: Trond Myklebust --- fs/exportfs/expfs.c | 32 ++++++++++++++++++++++++-------- include/linux/exportfs.h | 5 +++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c index 2dd55b172d57..0106eba46d5a 100644 --- a/fs/exportfs/expfs.c +++ b/fs/exportfs/expfs.c @@ -417,9 +417,11 @@ int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, } EXPORT_SYMBOL_GPL(exportfs_encode_fh); -struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, - int fh_len, int fileid_type, - int (*acceptable)(void *, struct dentry *), void *context) +struct dentry * +exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len, + int fileid_type, + int (*acceptable)(void *, struct dentry *), + void *context) { const struct export_operations *nop = mnt->mnt_sb->s_export_op; struct dentry *result, *alias; @@ -432,10 +434,8 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, if (!nop || !nop->fh_to_dentry) return ERR_PTR(-ESTALE); result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type); - if (PTR_ERR(result) == -ENOMEM) - return ERR_CAST(result); if (IS_ERR_OR_NULL(result)) - return ERR_PTR(-ESTALE); + return result; /* * If no acceptance criteria was specified by caller, a disconnected @@ -561,10 +561,26 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, err_result: dput(result); - if (err != -ENOMEM) - err = -ESTALE; return ERR_PTR(err); } +EXPORT_SYMBOL_GPL(exportfs_decode_fh_raw); + +struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, + int fh_len, int fileid_type, + int (*acceptable)(void *, struct dentry *), + void *context) +{ + struct dentry *ret; + + ret = exportfs_decode_fh_raw(mnt, fid, fh_len, fileid_type, + acceptable, context); + if (IS_ERR_OR_NULL(ret)) { + if (ret == ERR_PTR(-ENOMEM)) + return ret; + return ERR_PTR(-ESTALE); + } + return ret; +} EXPORT_SYMBOL_GPL(exportfs_decode_fh); MODULE_LICENSE("GPL"); diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index d829403ffd3b..846df3c96730 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h @@ -223,6 +223,11 @@ extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid, int *max_len, struct inode *parent); extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, int connectable); +extern struct dentry *exportfs_decode_fh_raw(struct vfsmount *mnt, + struct fid *fid, int fh_len, + int fileid_type, + int (*acceptable)(void *, struct dentry *), + void *context); extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, int fh_len, int fileid_type, int (*acceptable)(void *, struct dentry *), void *context); -- 2.28.0