From: NeilBrown <neilb@suse.de>
To: Chuck Lever <chuck.lever@oracle.com>, Jeff Layton <jlayton@kernel.org>
Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia <kolga@netapp.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Mike Snitzer <snitzer@kernel.org>
Subject: [PATCH 1/6] nfsd: introduce __fh_verify which takes explicit nfsd_net arg
Date: Mon, 1 Jul 2024 12:53:16 +1000 [thread overview]
Message-ID: <20240701025802.22985-2-neilb@suse.de> (raw)
In-Reply-To: <20240701025802.22985-1-neilb@suse.de>
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(-)
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.
--
2.44.0
next prev parent reply other threads:[~2024-07-01 2:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 2:53 [PATCH 0/6 RFC] nfsd: provide simpler interface for LOCALIO access NeilBrown
2024-07-01 2:53 ` NeilBrown [this message]
2024-07-01 14:54 ` [PATCH 1/6] nfsd: introduce __fh_verify which takes explicit nfsd_net arg Chuck Lever
2024-07-01 15:46 ` kernel test robot
2024-07-01 2:53 ` [PATCH 2/6] nfsd: add cred parameter to __fh_verify() NeilBrown
2024-07-01 11:02 ` Jeff Layton
2024-07-01 17:34 ` kernel test robot
2024-07-01 2:53 ` [PATCH 3/6] nfsd: pass nfs_vers explicitly " NeilBrown
2024-07-01 14:57 ` Chuck Lever
2024-07-01 19:16 ` kernel test robot
2024-07-01 2:53 ` [PATCH 4/6] nfsd: pass client " NeilBrown
2024-07-01 11:12 ` Jeff Layton
2024-07-01 2:53 ` [PATCH 5/6] nfsd: __fh_verify now treats NULL rqstp as a trusted connection NeilBrown
2024-07-01 2:53 ` [PATCH 6/6] nfsd: add nfsd_file_acquire_local() NeilBrown
2024-07-01 11:21 ` Jeff Layton
2024-07-01 23:55 ` NeilBrown
2024-07-02 0:29 ` Jeff Layton
2024-07-04 8:58 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240701025802.22985-2-neilb@suse.de \
--to=neilb@suse.de \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=kolga@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=snitzer@kernel.org \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox