]> git.dujemihanovic.xyz Git - linux.git/commitdiff
nfsd: Don't pass all of rqst into rqst_exp_find()
authorNeilBrown <neilb@suse.de>
Fri, 26 Jul 2024 02:21:30 +0000 (12:21 +1000)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 20 Sep 2024 23:31:03 +0000 (19:31 -0400)
Rather than passing the whole rqst, pass the pieces that are actually
needed.  This makes the inputs to rqst_exp_find() more obvious.

Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/export.c
fs/nfsd/export.h
fs/nfsd/nfs4proc.c
fs/nfsd/nfsfh.c

index 50b3135d07ac7345de22fe44b7ed781dc4d125f2..9aa5f95f18a8d1ede86b9c3043b7c7ec7f8d27e8 100644 (file)
@@ -1164,19 +1164,35 @@ gss:
        return gssexp;
 }
 
+/**
+ * rqst_exp_find - Find an svc_export in the context of a rqst or similar
+ * @reqp:      The handle to be used to suspend the request if a cache-upcall is needed
+ *             If NULL, missing in-cache information will result in failure.
+ * @net:       The network namespace in which the request exists
+ * @cl:                default auth_domain to use for looking up the export
+ * @gsscl:     an alternate auth_domain defined using deprecated gss/krb5 format.
+ * @fsid_type: The type of fsid to look for
+ * @fsidv:     The actual fsid to look up in the context of either client.
+ *
+ * Perform a lookup for @cl/@fsidv in the given @net for an export.  If
+ * none found and @gsscl specified, repeat the lookup.
+ *
+ * Returns an export, or an error pointer.
+ */
 struct svc_export *
-rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
+rqst_exp_find(struct cache_req *reqp, struct net *net,
+             struct auth_domain *cl, struct auth_domain *gsscl,
+             int fsid_type, u32 *fsidv)
 {
+       struct nfsd_net *nn = net_generic(net, nfsd_net_id);
        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;
 
-       if (rqstp->rq_client == NULL)
+       if (!cl)
                goto gss;
 
        /* First try the auth_unix client: */
-       exp = exp_find(cd, rqstp->rq_client, fsid_type,
-                      fsidv, &rqstp->rq_chandle);
+       exp = exp_find(cd, cl, fsid_type, fsidv, reqp);
        if (PTR_ERR(exp) == -ENOENT)
                goto gss;
        if (IS_ERR(exp))
@@ -1186,10 +1202,9 @@ rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
                return exp;
 gss:
        /* Otherwise, try falling back on gss client */
-       if (rqstp->rq_gssclient == NULL)
+       if (!gsscl)
                return exp;
-       gssexp = exp_find(cd, rqstp->rq_gssclient, fsid_type, fsidv,
-                                               &rqstp->rq_chandle);
+       gssexp = exp_find(cd, gsscl, fsid_type, fsidv, reqp);
        if (PTR_ERR(gssexp) == -ENOENT)
                return exp;
        if (!IS_ERR(exp))
@@ -1220,7 +1235,9 @@ 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->rq_chandle, SVC_NET(rqstp),
+                            rqstp->rq_client, rqstp->rq_gssclient,
+                            FSID_NUM, fsidv);
 }
 
 /*
index ca9dc230ae3d0bea1ee5a55215fbfe4a5eae57c5..cb17f05e332902e58250f601ce9dddae44bb27ba 100644 (file)
@@ -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 svc_export *rqst_exp_find(struct cache_req *reqp, struct net *net,
+                                struct auth_domain *cl, struct auth_domain *gsscl,
+                                int fsid_type, u32 *fsidv);
 
 #endif /* NFSD_EXPORT_H */
index 911134ed5a0e84f430016a5470038eb2d1f98c24..4f5b8c4be417110413dc619b65b77d961e6363ec 100644 (file)
@@ -2233,7 +2233,9 @@ nfsd4_getdeviceinfo(struct svc_rqst *rqstp,
                return nfserr_noent;
        }
 
-       exp = rqst_exp_find(rqstp, map->fsid_type, map->fsid);
+       exp = rqst_exp_find(&rqstp->rq_chandle, SVC_NET(rqstp),
+                           rqstp->rq_client, rqstp->rq_gssclient,
+                           map->fsid_type, map->fsid);
        if (IS_ERR(exp)) {
                dprintk("%s: could not find device id\n", __func__);
                return nfserr_noent;
index dd4e11a703aa6a815bc4c7d42fc81f2918616a18..17d40600e02c3d753fa5bbbd87b9dae127ffeec7 100644 (file)
@@ -195,7 +195,9 @@ 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->rq_chandle, SVC_NET(rqstp),
+                           rqstp->rq_client, rqstp->rq_gssclient,
+                           fh->fh_fsid_type, fh->fh_fsid);
        fid = (struct fid *)(fh->fh_fsid + len);
 
        error = nfserr_stale;