diff mbox series

[1/6] nfsd: introduce __fh_verify which takes explicit nfsd_net arg

Message ID 20240701025802.22985-2-neilb@suse.de (mailing list archive)
State New
Headers show
Series nfsd: provide simpler interface for LOCALIO access | expand

Commit Message

NeilBrown July 1, 2024, 2:53 a.m. UTC
This is a step towards having an interface like fh_verify() which
doesn't require a struct svc_rqst *, but instead takes the specific
parts of that which are actually needed.

This first step allows the 'struct nfsd_net *' to be passed in
separately.  __fh_verify() does not use SVC_NET(), nor does its
callers.

Signed-off-by: NeilBrown <neilb@suse.de>
---
 fs/nfsd/export.c   | 12 ++++++++----
 fs/nfsd/export.h   |  4 +++-
 fs/nfsd/nfs4proc.c |  2 +-
 fs/nfsd/nfsfh.c    | 20 ++++++++++++++------
 4 files changed, 26 insertions(+), 12 deletions(-)

Comments

Chuck Lever July 1, 2024, 2:54 p.m. UTC | #1
On Mon, Jul 01, 2024 at 12:53:16PM +1000, NeilBrown wrote:
> This is a step towards having an interface like fh_verify() which
> doesn't require a struct svc_rqst *, but instead takes the specific
> parts of that which are actually needed.
> 
> This first step allows the 'struct nfsd_net *' to be passed in
> separately.  __fh_verify() does not use SVC_NET(), nor does its
> callers.

It might be a little cleaner to first update rqst_exp_find() as a
zeroeth step, but no big deal.


> Signed-off-by: NeilBrown <neilb@suse.de>
> ---
>  fs/nfsd/export.c   | 12 ++++++++----
>  fs/nfsd/export.h   |  4 +++-
>  fs/nfsd/nfs4proc.c |  2 +-
>  fs/nfsd/nfsfh.c    | 20 ++++++++++++++------
>  4 files changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
> index 50b3135d07ac..a35f06b610d0 100644
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -1165,11 +1165,15 @@ rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path)
>  }
>  
>  struct svc_export *
> -rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
> +rqst_exp_find(struct svc_rqst *rqstp,  struct nfsd_net *nn,

Extra blank after "*rqstp,"

I agree with Jeff, the new modern rqst_exp_find() deserves a kdoc
comment.


> +	      int fsid_type, u32 *fsidv)
>  {
>  	struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT);
> -	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
> -	struct cache_detail *cd = nn->svc_export_cache;
> +	struct cache_detail *cd;
> +
> +	if (!nn)
> +		nn = net_generic(SVC_NET(rqstp), nfsd_net_id);

If it's this easy to fabricate a network namespace, IMO the API
would be more straightforward if all callers passed a valid @nn.

In fact, by the end of the series, the combinations of which
parameters are allowed to be NULL and what each NULL means is a bit
brittle... Perhaps you can make that simpler in the next version of
this series?


> +	cd = nn->svc_export_cache;
>  
>  	if (rqstp->rq_client == NULL)
>  		goto gss;
> @@ -1220,7 +1224,7 @@ struct svc_export *rqst_find_fsidzero_export(struct svc_rqst *rqstp)
>  
>  	mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
>  
> -	return rqst_exp_find(rqstp, FSID_NUM, fsidv);
> +	return rqst_exp_find(rqstp, NULL, FSID_NUM, fsidv);

Right, so here, I don't think there's a problem manufacturing a
proper nn to pass to rqstp_exp_find().


>  }
>  
>  /*
> diff --git a/fs/nfsd/export.h b/fs/nfsd/export.h
> index ca9dc230ae3d..1a54d388d58d 100644
> --- a/fs/nfsd/export.h
> +++ b/fs/nfsd/export.h
> @@ -127,6 +127,8 @@ static inline struct svc_export *exp_get(struct svc_export *exp)
>  	cache_get(&exp->h);
>  	return exp;
>  }
> -struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
> +struct nfsd_net;
> +struct svc_export * rqst_exp_find(struct svc_rqst *, struct nfsd_net *,
> +				  int, u32 *);
>  
>  #endif /* NFSD_EXPORT_H */
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index 2e39cf2e502a..30335cdf9e6c 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -2231,7 +2231,7 @@ nfsd4_getdeviceinfo(struct svc_rqst *rqstp,
>  		return nfserr_noent;
>  	}
>  
> -	exp = rqst_exp_find(rqstp, map->fsid_type, map->fsid);
> +	exp = rqst_exp_find(rqstp, NULL, map->fsid_type, map->fsid);

Ditto.


>  	if (IS_ERR(exp)) {
>  		dprintk("%s: could not find device id\n", __func__);
>  		return nfserr_noent;
> diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
> index 0b75305fb5f5..e27ed27054ab 100644
> --- a/fs/nfsd/nfsfh.c
> +++ b/fs/nfsd/nfsfh.c
> @@ -151,7 +151,8 @@ static inline __be32 check_pseudo_root(struct svc_rqst *rqstp,
>   * dentry.  On success, the results are used to set fh_export and
>   * fh_dentry.
>   */
> -static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
> +static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct nfsd_net *nn,
> +				 struct svc_fh *fhp)
>  {
>  	struct knfsd_fh	*fh = &fhp->fh_handle;
>  	struct fid *fid = NULL;
> @@ -195,7 +196,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
>  	data_left -= len;
>  	if (data_left < 0)
>  		return error;
> -	exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_fsid);
> +	exp = rqst_exp_find(rqstp, nn, fh->fh_fsid_type, fh->fh_fsid);
>  	fid = (struct fid *)(fh->fh_fsid + len);
>  
>  	error = nfserr_stale;
> @@ -324,16 +325,16 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
>   * @access is formed from the NFSD_MAY_* constants defined in
>   * fs/nfsd/vfs.h.
>   */
> -__be32
> -fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
> +static __be32
> +__fh_verify(struct svc_rqst *rqstp, struct nfsd_net *nn,
> +	    struct svc_fh *fhp, umode_t type, int access)
>  {
> -	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
>  	struct svc_export *exp = NULL;
>  	struct dentry	*dentry;
>  	__be32		error;
>  
>  	if (!fhp->fh_dentry) {
> -		error = nfsd_set_fh_dentry(rqstp, fhp);
> +		error = nfsd_set_fh_dentry(rqstp, nn, fhp);
>  		if (error)
>  			goto out;
>  	}
> @@ -400,6 +401,13 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
>  	return error;
>  }

Can this patch copy the kdoc comment from above? And of course the
kdoc comment for __fh_verify() will need to be updated
appropriately.


> +__be32
> +fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
> +{
> +	return __fh_verify(rqstp, net_generic(SVC_NET(rqstp), nfsd_net_id),
> +			   fhp, type, access);
> +}
> +

Extra blank line added.


>  /*
>   * Compose a file handle for an NFS reply.
> -- 
> 2.44.0
>
kernel test robot July 1, 2024, 3:46 p.m. UTC | #2
Hi NeilBrown,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.10-rc6 next-20240701]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/NeilBrown/nfsd-introduce-__fh_verify-which-takes-explicit-nfsd_net-arg/20240701-122856
base:   linus/master
patch link:    https://lore.kernel.org/r/20240701025802.22985-2-neilb%40suse.de
patch subject: [PATCH 1/6] nfsd: introduce __fh_verify which takes explicit nfsd_net arg
config: parisc-defconfig
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build):

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202407012313.vEtlGGRL-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> fs/nfsd/nfsfh.c:331: warning: Function parameter or struct member 'nn' not described in '__fh_verify'
>> fs/nfsd/nfsfh.c:331: warning: expecting prototype for fh_verify(). Prototype was for __fh_verify() instead


vim +331 fs/nfsd/nfsfh.c

03550fac06c4f0c J. Bruce Fields 2008-03-14  300  
b3d47676d474ecd J. Bruce Fields 2008-10-20  301  /**
b3d47676d474ecd J. Bruce Fields 2008-10-20  302   * fh_verify - filehandle lookup and access checking
b3d47676d474ecd J. Bruce Fields 2008-10-20  303   * @rqstp: pointer to current rpc request
b3d47676d474ecd J. Bruce Fields 2008-10-20  304   * @fhp: filehandle to be verified
b3d47676d474ecd J. Bruce Fields 2008-10-20  305   * @type: expected type of object pointed to by filehandle
b3d47676d474ecd J. Bruce Fields 2008-10-20  306   * @access: type of access needed to object
b3d47676d474ecd J. Bruce Fields 2008-10-20  307   *
b3d47676d474ecd J. Bruce Fields 2008-10-20  308   * Look up a dentry from the on-the-wire filehandle, check the client's
b3d47676d474ecd J. Bruce Fields 2008-10-20  309   * access to the export, and set the current task's credentials.
b3d47676d474ecd J. Bruce Fields 2008-10-20  310   *
b3d47676d474ecd J. Bruce Fields 2008-10-20  311   * Regardless of success or failure of fh_verify(), fh_put() should be
b3d47676d474ecd J. Bruce Fields 2008-10-20  312   * called on @fhp when the caller is finished with the filehandle.
b3d47676d474ecd J. Bruce Fields 2008-10-20  313   *
b3d47676d474ecd J. Bruce Fields 2008-10-20  314   * fh_verify() may be called multiple times on a given filehandle, for
b3d47676d474ecd J. Bruce Fields 2008-10-20  315   * example, when processing an NFSv4 compound.  The first call will look
b3d47676d474ecd J. Bruce Fields 2008-10-20  316   * up a dentry using the on-the-wire filehandle.  Subsequent calls will
b3d47676d474ecd J. Bruce Fields 2008-10-20  317   * skip the lookup and just perform the other checks and possibly change
b3d47676d474ecd J. Bruce Fields 2008-10-20  318   * the current task's credentials.
03550fac06c4f0c J. Bruce Fields 2008-03-14  319   *
b3d47676d474ecd J. Bruce Fields 2008-10-20  320   * @type specifies the type of object expected using one of the S_IF*
b3d47676d474ecd J. Bruce Fields 2008-10-20  321   * constants defined in include/linux/stat.h.  The caller may use zero
b3d47676d474ecd J. Bruce Fields 2008-10-20  322   * to indicate that it doesn't care, or a negative integer to indicate
b3d47676d474ecd J. Bruce Fields 2008-10-20  323   * that it expects something not of the given type.
03550fac06c4f0c J. Bruce Fields 2008-03-14  324   *
b3d47676d474ecd J. Bruce Fields 2008-10-20  325   * @access is formed from the NFSD_MAY_* constants defined in
93f580a9a2413de Oleg Drokin     2016-07-07  326   * fs/nfsd/vfs.h.
03550fac06c4f0c J. Bruce Fields 2008-03-14  327   */
63e675e35f79eda NeilBrown       2024-07-01  328  static __be32
63e675e35f79eda NeilBrown       2024-07-01  329  __fh_verify(struct svc_rqst *rqstp, struct nfsd_net *nn,
63e675e35f79eda NeilBrown       2024-07-01  330  	    struct svc_fh *fhp, umode_t type, int access)
03550fac06c4f0c J. Bruce Fields 2008-03-14 @331  {
20ad856e47323e2 Amir Goldstein  2021-01-06  332  	struct svc_export *exp = NULL;
03550fac06c4f0c J. Bruce Fields 2008-03-14  333  	struct dentry	*dentry;
03550fac06c4f0c J. Bruce Fields 2008-03-14  334  	__be32		error;
03550fac06c4f0c J. Bruce Fields 2008-03-14  335  
03550fac06c4f0c J. Bruce Fields 2008-03-14  336  	if (!fhp->fh_dentry) {
63e675e35f79eda NeilBrown       2024-07-01  337  		error = nfsd_set_fh_dentry(rqstp, nn, fhp);
03550fac06c4f0c J. Bruce Fields 2008-03-14  338  		if (error)
03550fac06c4f0c J. Bruce Fields 2008-03-14  339  			goto out;
864f0f61f829bac J. Bruce Fields 2009-11-25  340  	}
^1da177e4c3f415 Linus Torvalds  2005-04-16  341  	dentry = fhp->fh_dentry;
^1da177e4c3f415 Linus Torvalds  2005-04-16  342  	exp = fhp->fh_export;
051382885552e12 Chuck Lever     2022-06-21  343  
051382885552e12 Chuck Lever     2022-06-21  344  	trace_nfsd_fh_verify(rqstp, fhp, type, access);
051382885552e12 Chuck Lever     2022-06-21  345  
6fa02839bf9412e J. Bruce Fields 2007-11-12  346  	/*
864f0f61f829bac J. Bruce Fields 2009-11-25  347  	 * We still have to do all these permission checks, even when
864f0f61f829bac J. Bruce Fields 2009-11-25  348  	 * fh_dentry is already set:
864f0f61f829bac J. Bruce Fields 2009-11-25  349  	 * 	- fh_verify may be called multiple times with different
864f0f61f829bac J. Bruce Fields 2009-11-25  350  	 * 	  "access" arguments (e.g. nfsd_proc_create calls
864f0f61f829bac J. Bruce Fields 2009-11-25  351  	 * 	  fh_verify(...,NFSD_MAY_EXEC) first, then later (in
864f0f61f829bac J. Bruce Fields 2009-11-25  352  	 * 	  nfsd_create) calls fh_verify(...,NFSD_MAY_CREATE).
864f0f61f829bac J. Bruce Fields 2009-11-25  353  	 *	- in the NFSv4 case, the filehandle may have been filled
864f0f61f829bac J. Bruce Fields 2009-11-25  354  	 *	  in by fh_compose, and given a dentry, but further
864f0f61f829bac J. Bruce Fields 2009-11-25  355  	 *	  compound operations performed with that filehandle
864f0f61f829bac J. Bruce Fields 2009-11-25  356  	 *	  still need permissions checks.  In the worst case, a
864f0f61f829bac J. Bruce Fields 2009-11-25  357  	 *	  mountpoint crossing may have changed the export
864f0f61f829bac J. Bruce Fields 2009-11-25  358  	 *	  options, and we may now need to use a different uid
864f0f61f829bac J. Bruce Fields 2009-11-25  359  	 *	  (for example, if different id-squashing options are in
864f0f61f829bac J. Bruce Fields 2009-11-25  360  	 *	  effect on the new filesystem).
6fa02839bf9412e J. Bruce Fields 2007-11-12  361  	 */
03a816b46d7eba7 Steve Dickson   2009-09-09  362  	error = check_pseudo_root(rqstp, dentry, exp);
03a816b46d7eba7 Steve Dickson   2009-09-09  363  	if (error)
03a816b46d7eba7 Steve Dickson   2009-09-09  364  		goto out;
03a816b46d7eba7 Steve Dickson   2009-09-09  365  
6fa02839bf9412e J. Bruce Fields 2007-11-12  366  	error = nfsd_setuser_and_check_port(rqstp, exp);
7fc90ec93a5eb71 J. Bruce Fields 2006-06-30  367  	if (error)
7fc90ec93a5eb71 J. Bruce Fields 2006-06-30  368  		goto out;
7fc90ec93a5eb71 J. Bruce Fields 2006-06-30  369  
e75b23f9e323b1e J. Bruce Fields 2016-07-19  370  	error = nfsd_mode_check(rqstp, dentry, type);
^1da177e4c3f415 Linus Torvalds  2005-04-16  371  	if (error)
^1da177e4c3f415 Linus Torvalds  2005-04-16  372  		goto out;
^1da177e4c3f415 Linus Torvalds  2005-04-16  373  
9091224f3cff472 J. Bruce Fields 2007-07-17  374  	/*
9091224f3cff472 J. Bruce Fields 2007-07-17  375  	 * pseudoflavor restrictions are not enforced on NLM,
9091224f3cff472 J. Bruce Fields 2007-07-17  376  	 * which clients virtually always use auth_sys for,
9091224f3cff472 J. Bruce Fields 2007-07-17  377  	 * even while using RPCSEC_GSS for NFS.
9091224f3cff472 J. Bruce Fields 2007-07-17  378  	 */
204f4ce75434c34 J. Bruce Fields 2011-04-08  379  	if (access & NFSD_MAY_LOCK || access & NFSD_MAY_BYPASS_GSS)
04716e6621ff4ab J. Bruce Fields 2008-08-07  380  		goto skip_pseudoflavor_check;
04716e6621ff4ab J. Bruce Fields 2008-08-07  381  	/*
04716e6621ff4ab J. Bruce Fields 2008-08-07  382  	 * Clients may expect to be able to use auth_sys during mount,
04716e6621ff4ab J. Bruce Fields 2008-08-07  383  	 * even if they use gss for everything else; see section 2.3.2
04716e6621ff4ab J. Bruce Fields 2008-08-07  384  	 * of rfc 2623.
04716e6621ff4ab J. Bruce Fields 2008-08-07  385  	 */
04716e6621ff4ab J. Bruce Fields 2008-08-07  386  	if (access & NFSD_MAY_BYPASS_GSS_ON_ROOT
04716e6621ff4ab J. Bruce Fields 2008-08-07  387  			&& exp->ex_path.dentry == dentry)
04716e6621ff4ab J. Bruce Fields 2008-08-07  388  		goto skip_pseudoflavor_check;
04716e6621ff4ab J. Bruce Fields 2008-08-07  389  
32c1eb0cd7ee00b Andy Adamson    2007-07-17  390  	error = check_nfsd_access(exp, rqstp);
32c1eb0cd7ee00b Andy Adamson    2007-07-17  391  	if (error)
32c1eb0cd7ee00b Andy Adamson    2007-07-17  392  		goto out;
32c1eb0cd7ee00b Andy Adamson    2007-07-17  393  
04716e6621ff4ab J. Bruce Fields 2008-08-07  394  skip_pseudoflavor_check:
^1da177e4c3f415 Linus Torvalds  2005-04-16  395  	/* Finally, check access permissions. */
0ec757df9743025 J. Bruce Fields 2007-07-17  396  	error = nfsd_permission(rqstp, exp, dentry, access);
^1da177e4c3f415 Linus Torvalds  2005-04-16  397  out:
93c128e709aec23 Jeff Layton     2022-10-12  398  	trace_nfsd_fh_verify_err(rqstp, fhp, type, access, error);
^1da177e4c3f415 Linus Torvalds  2005-04-16  399  	if (error == nfserr_stale)
4b14885411f74b2 Josef Bacik     2024-01-26  400  		nfsd_stats_fh_stale_inc(nn, exp);
^1da177e4c3f415 Linus Torvalds  2005-04-16  401  	return error;
^1da177e4c3f415 Linus Torvalds  2005-04-16  402  }
^1da177e4c3f415 Linus Torvalds  2005-04-16  403
diff mbox series

Patch

diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 50b3135d07ac..a35f06b610d0 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1165,11 +1165,15 @@  rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path)
 }
 
 struct svc_export *
-rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
+rqst_exp_find(struct svc_rqst *rqstp,  struct nfsd_net *nn,
+	      int fsid_type, u32 *fsidv)
 {
 	struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT);
-	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
-	struct cache_detail *cd = nn->svc_export_cache;
+	struct cache_detail *cd;
+
+	if (!nn)
+		nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
+	cd = nn->svc_export_cache;
 
 	if (rqstp->rq_client == NULL)
 		goto gss;
@@ -1220,7 +1224,7 @@  struct svc_export *rqst_find_fsidzero_export(struct svc_rqst *rqstp)
 
 	mk_fsid(FSID_NUM, fsidv, 0, 0, 0, NULL);
 
-	return rqst_exp_find(rqstp, FSID_NUM, fsidv);
+	return rqst_exp_find(rqstp, NULL, FSID_NUM, fsidv);
 }
 
 /*
diff --git a/fs/nfsd/export.h b/fs/nfsd/export.h
index ca9dc230ae3d..1a54d388d58d 100644
--- a/fs/nfsd/export.h
+++ b/fs/nfsd/export.h
@@ -127,6 +127,8 @@  static inline struct svc_export *exp_get(struct svc_export *exp)
 	cache_get(&exp->h);
 	return exp;
 }
-struct svc_export * rqst_exp_find(struct svc_rqst *, int, u32 *);
+struct nfsd_net;
+struct svc_export * rqst_exp_find(struct svc_rqst *, struct nfsd_net *,
+				  int, u32 *);
 
 #endif /* NFSD_EXPORT_H */
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 2e39cf2e502a..30335cdf9e6c 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -2231,7 +2231,7 @@  nfsd4_getdeviceinfo(struct svc_rqst *rqstp,
 		return nfserr_noent;
 	}
 
-	exp = rqst_exp_find(rqstp, map->fsid_type, map->fsid);
+	exp = rqst_exp_find(rqstp, NULL, map->fsid_type, map->fsid);
 	if (IS_ERR(exp)) {
 		dprintk("%s: could not find device id\n", __func__);
 		return nfserr_noent;
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 0b75305fb5f5..e27ed27054ab 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -151,7 +151,8 @@  static inline __be32 check_pseudo_root(struct svc_rqst *rqstp,
  * dentry.  On success, the results are used to set fh_export and
  * fh_dentry.
  */
-static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
+static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct nfsd_net *nn,
+				 struct svc_fh *fhp)
 {
 	struct knfsd_fh	*fh = &fhp->fh_handle;
 	struct fid *fid = NULL;
@@ -195,7 +196,7 @@  static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
 	data_left -= len;
 	if (data_left < 0)
 		return error;
-	exp = rqst_exp_find(rqstp, fh->fh_fsid_type, fh->fh_fsid);
+	exp = rqst_exp_find(rqstp, nn, fh->fh_fsid_type, fh->fh_fsid);
 	fid = (struct fid *)(fh->fh_fsid + len);
 
 	error = nfserr_stale;
@@ -324,16 +325,16 @@  static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp)
  * @access is formed from the NFSD_MAY_* constants defined in
  * fs/nfsd/vfs.h.
  */
-__be32
-fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
+static __be32
+__fh_verify(struct svc_rqst *rqstp, struct nfsd_net *nn,
+	    struct svc_fh *fhp, umode_t type, int access)
 {
-	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
 	struct svc_export *exp = NULL;
 	struct dentry	*dentry;
 	__be32		error;
 
 	if (!fhp->fh_dentry) {
-		error = nfsd_set_fh_dentry(rqstp, fhp);
+		error = nfsd_set_fh_dentry(rqstp, nn, fhp);
 		if (error)
 			goto out;
 	}
@@ -400,6 +401,13 @@  fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
 	return error;
 }
 
+__be32
+fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access)
+{
+	return __fh_verify(rqstp, net_generic(SVC_NET(rqstp), nfsd_net_id),
+			   fhp, type, access);
+}
+
 
 /*
  * Compose a file handle for an NFS reply.