From: Mike Snitzer <snitzer@kernel.org>
To: linux-nfs@vger.kernel.org
Cc: Jeff Layton <jlayton@kernel.org>,
Chuck Lever <chuck.lever@oracle.com>,
Anna Schumaker <anna@kernel.org>,
Trond Myklebust <trondmy@hammerspace.com>,
NeilBrown <neilb@suse.de>,
linux-fsdevel@vger.kernel.org
Subject: [PATCH v12 22/24] nfs: push localio nfsd_file_put call out to client
Date: Mon, 19 Aug 2024 14:17:27 -0400 [thread overview]
Message-ID: <20240819181750.70570-23-snitzer@kernel.org> (raw)
In-Reply-To: <20240819181750.70570-1-snitzer@kernel.org>
Change nfsd_open_local_fh() to return an nfsd_file, instead of file,
and move associated reference counting to the nfs client's
nfs_local_open_fh().
This is the first step in allowing proper use of nfsd_file for localio
(such that the benefits of nfsd's filecache can be realized).
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
---
fs/nfs/localio.c | 7 +++++--
fs/nfs_common/nfslocalio.c | 2 +-
fs/nfsd/localio.c | 11 ++++-------
fs/nfsd/vfs.h | 2 +-
include/linux/nfslocalio.h | 2 +-
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
index 38303427e0b3..7d63d7e34643 100644
--- a/fs/nfs/localio.c
+++ b/fs/nfs/localio.c
@@ -237,13 +237,14 @@ nfs_local_open_fh(struct nfs_client *clp, const struct cred *cred,
struct nfs_fh *fh, const fmode_t mode)
{
struct file *filp;
+ struct nfsd_file *nf;
int status;
if (mode & ~(FMODE_READ | FMODE_WRITE))
return ERR_PTR(-EINVAL);
status = nfs_to.nfsd_open_local_fh(clp->cl_nfssvc_net, clp->cl_nfssvc_dom,
- clp->cl_rpcclient, cred, fh, mode, &filp);
+ clp->cl_rpcclient, cred, fh, mode, &nf);
if (status < 0) {
trace_nfs_local_open_fh(fh, mode, status);
switch (status) {
@@ -255,8 +256,10 @@ nfs_local_open_fh(struct nfs_client *clp, const struct cred *cred,
case -ETIMEDOUT:
status = -EAGAIN;
}
- filp = ERR_PTR(status);
+ return ERR_PTR(status);
}
+ filp = get_file(nfs_to.nfsd_file_file(nf));
+ nfs_to.nfsd_file_put(nf);
return filp;
}
EXPORT_SYMBOL_GPL(nfs_local_open_fh);
diff --git a/fs/nfs_common/nfslocalio.c b/fs/nfs_common/nfslocalio.c
index 087649911b52..f59167e596d3 100644
--- a/fs/nfs_common/nfslocalio.c
+++ b/fs/nfs_common/nfslocalio.c
@@ -98,7 +98,7 @@ static void put_##NFSD_SYMBOL(void) \
/* The nfs localio code needs to call into nfsd to map filehandle -> struct nfsd_file */
extern int nfsd_open_local_fh(struct net *, struct auth_domain *, struct rpc_clnt *,
const struct cred *, const struct nfs_fh *,
- const fmode_t, struct file **);
+ const fmode_t, struct nfsd_file **);
DEFINE_NFS_TO_NFSD_SYMBOL(nfsd_open_local_fh);
/* The nfs localio code needs to call into nfsd to acquire the nfsd_file */
diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c
index 008b935a3a6c..2ceab49f3cb6 100644
--- a/fs/nfsd/localio.c
+++ b/fs/nfsd/localio.c
@@ -32,13 +32,13 @@
* @cred: cred that the client established
* @nfs_fh: filehandle to lookup
* @fmode: fmode_t to use for open
- * @pfilp: returned file pointer that maps to @nfs_fh
+ * @pnf: returned nfsd_file pointer that maps to @nfs_fh
*
* This function maps a local fh to a path on a local filesystem.
* This is useful when the nfs client has the local server mounted - it can
* avoid all the NFS overhead with reads, writes and commits.
*
- * On successful return, caller is responsible for calling path_put. Also
+ * On successful return, caller is responsible for calling nfsd_file_put. Also
* note that this is called from nfs.ko via find_symbol() to avoid an explicit
* dependency on knfsd. So, there is no forward declaration in a header file
* for it that is shared with the client.
@@ -49,7 +49,7 @@ int nfsd_open_local_fh(struct net *cl_nfssvc_net,
const struct cred *cred,
const struct nfs_fh *nfs_fh,
const fmode_t fmode,
- struct file **pfilp)
+ struct nfsd_file **pnf)
{
int mayflags = NFSD_MAY_LOCALIO;
int status = 0;
@@ -57,7 +57,6 @@ int nfsd_open_local_fh(struct net *cl_nfssvc_net,
const struct cred *save_cred;
struct svc_cred rq_cred;
struct svc_fh fh;
- struct nfsd_file *nf;
__be32 beres;
if (nfs_fh->size > NFS4_FHSIZE)
@@ -91,13 +90,11 @@ int nfsd_open_local_fh(struct net *cl_nfssvc_net,
rpcauth_map_clnt_to_svc_cred_local(rpc_clnt, cred, &rq_cred);
beres = nfsd_file_acquire_local(cl_nfssvc_net, &rq_cred, rpc_clnt->cl_vers,
- cl_nfssvc_dom, &fh, mayflags, &nf);
+ cl_nfssvc_dom, &fh, mayflags, pnf);
if (beres) {
status = nfs_stat_to_errno(be32_to_cpu(beres));
goto out_fh_put;
}
- *pfilp = get_file(nf->nf_file);
- nfsd_file_put(nf);
out_fh_put:
fh_put(&fh);
if (rq_cred.cr_group_info)
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index 9720951c49a0..ec8a8aae540b 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -166,7 +166,7 @@ int nfsd_open_local_fh(struct net *net,
const struct cred *cred,
const struct nfs_fh *nfs_fh,
const fmode_t fmode,
- struct file **pfilp);
+ struct nfsd_file **pnf);
static inline int fh_want_write(struct svc_fh *fh)
{
diff --git a/include/linux/nfslocalio.h b/include/linux/nfslocalio.h
index 6302d36f9112..7e09ff621d93 100644
--- a/include/linux/nfslocalio.h
+++ b/include/linux/nfslocalio.h
@@ -35,7 +35,7 @@ struct nfsd_file;
typedef int (*nfs_to_nfsd_open_local_fh_t)(struct net *, struct auth_domain *,
struct rpc_clnt *, const struct cred *,
const struct nfs_fh *, const fmode_t,
- struct file **);
+ struct nfsd_file **);
typedef struct nfsd_file * (*nfs_to_nfsd_file_get_t)(struct nfsd_file *);
typedef void (*nfs_to_nfsd_file_put_t)(struct nfsd_file *);
typedef struct file * (*nfs_to_nfsd_file_file_t)(struct nfsd_file *);
--
2.44.0
next prev parent reply other threads:[~2024-08-19 18:18 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 18:17 [PATCH v12 00/24] nfs/nfsd: add support for localio Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 01/24] nfs_common: factor out nfs_errtbl and nfs_stat_to_errno Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 02/24] nfs_common: factor out nfs4_errtbl and nfs4_stat_to_errno Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 03/24] nfs: factor out {encode,decode}_opaque_fixed to nfs_xdr.h Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 04/24] nfsd: factor out __fh_verify to allow NULL rqstp to be passed Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 05/24] nfsd: fix nfsfh tracepoints to properly handle NULL rqstp Mike Snitzer
2024-08-21 17:46 ` Jeff Layton
2024-08-21 21:23 ` Mike Snitzer
2024-08-22 15:07 ` Chuck Lever
2024-08-22 16:04 ` Mike Snitzer
2024-08-22 17:07 ` Jeff Layton
2024-08-22 17:20 ` Mike Snitzer
2024-08-22 18:14 ` Chuck Lever III
2024-08-19 18:17 ` [PATCH v12 06/24] nfsd: add nfsd_file_acquire_local() Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 07/24] SUNRPC: remove call_allocate() BUG_ONs Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 08/24] SUNRPC: add rpcauth_map_clnt_to_svc_cred_local Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 09/24] nfs_common: add NFS LOCALIO auxiliary protocol enablement Mike Snitzer
2024-08-21 18:04 ` Jeff Layton
2024-08-21 18:39 ` Jeff Layton
2024-08-19 18:17 ` [PATCH v12 10/24] nfsd: add localio support Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 11/24] nfsd: implement server support for NFS_LOCALIO_PROGRAM Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 12/24] SUNRPC: replace program list with program array Mike Snitzer
2024-08-21 18:31 ` Jeff Layton
2024-08-21 20:40 ` Mike Snitzer
2024-08-21 21:43 ` Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 13/24] nfs: pass struct file to nfs_init_pgio and nfs_init_commit Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 14/24] nfs: add localio support Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 15/24] nfs: enable localio for non-pNFS IO Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 16/24] pnfs/flexfiles: enable localio support Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 17/24] nfs/localio: use dedicated workqueues for filesystem read and write Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 18/24] nfs: implement client support for NFS_LOCALIO_PROGRAM Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 19/24] nfs: add Documentation/filesystems/nfs/localio.rst Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 20/24] nfsd: use GC for nfsd_file returned by nfsd_file_acquire_local Mike Snitzer
2024-08-21 18:34 ` Jeff Layton
2024-08-19 18:17 ` [PATCH v12 21/24] nfs_common: expose localio's required nfsd symbols to nfs client Mike Snitzer
2024-08-19 18:17 ` Mike Snitzer [this message]
2024-08-21 18:50 ` [PATCH v12 22/24] nfs: push localio nfsd_file_put call out to client Jeff Layton
2024-08-19 18:17 ` [PATCH v12 23/24] nfs: switch client to use nfsd_file for localio Mike Snitzer
2024-08-19 18:17 ` [PATCH v12 24/24] nfs: add FAQ section to Documentation/filesystems/nfs/localio.rst Mike Snitzer
2024-08-21 19:03 ` Jeff Layton
2024-08-21 20:12 ` Mike Snitzer
2024-08-21 20:14 ` Mike Snitzer
2024-08-21 23:46 ` Jeff Layton
2024-08-19 18:29 ` [PATCH v12 00/24] nfs/nfsd: add support for localio Chuck Lever III
2024-08-19 18:43 ` Mike Snitzer
2024-08-21 19:20 ` Jeff Layton
2024-08-21 20:05 ` Mike Snitzer
2024-08-22 12:35 ` Jeff Layton
2024-08-22 2:00 ` Mike Snitzer
2024-08-22 12:50 ` Jeff Layton
2024-08-22 15:18 ` Chuck Lever III
2024-08-22 15:42 ` Mike Snitzer
2024-08-21 19:56 ` Chuck Lever
2024-08-21 20:10 ` Mike Snitzer
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=20240819181750.70570-23-snitzer@kernel.org \
--to=snitzer@kernel.org \
--cc=anna@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=trondmy@hammerspace.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.