// SPDX-License-Identifier: GPL-2.0-only /* * NFS server support for local clients to bypass network stack * * Copyright (C) 2014 Weston Andros Adamson <[email protected]> * Copyright (C) 2019 Trond Myklebust <[email protected]> * Copyright (C) 2024 Mike Snitzer <[email protected]> * Copyright (C) 2024 NeilBrown <[email protected]> */ #include <linux/exportfs.h> #include <linux/sunrpc/svcauth.h> #include <linux/sunrpc/clnt.h> #include <linux/nfs.h> #include <linux/nfs_common.h> #include <linux/nfslocalio.h> #include <linux/nfs_fs.h> #include <linux/nfs_xdr.h> #include <linux/string.h> #include "nfsd.h" #include "vfs.h" #include "netns.h" #include "filecache.h" #include "cache.h" static const struct nfsd_localio_operations nfsd_localio_ops = …; void nfsd_localio_ops_init(void) { … } /** * nfsd_open_local_fh - lookup a local filehandle @nfs_fh and map to nfsd_file * * @net: 'struct net' to get the proper nfsd_net required for LOCALIO access * @dom: 'struct auth_domain' required for LOCALIO access * @rpc_clnt: rpc_clnt that the client established * @cred: cred that the client established * @nfs_fh: filehandle to lookup * @fmode: fmode_t to use for open * * 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, returned nfsd_file will have its nf_net member * set. Caller (NFS client) is responsible for calling nfsd_serv_put and * nfsd_file_put (via nfs_to_nfsd_file_put_local). */ struct nfsd_file * nfsd_open_local_fh(struct net *net, struct auth_domain *dom, struct rpc_clnt *rpc_clnt, const struct cred *cred, const struct nfs_fh *nfs_fh, const fmode_t fmode) { … } EXPORT_SYMBOL_GPL(…); /* * UUID_IS_LOCAL XDR functions */ static __be32 localio_proc_null(struct svc_rqst *rqstp) { … } struct localio_uuidarg { … }; static __be32 localio_proc_uuid_is_local(struct svc_rqst *rqstp) { … } static bool localio_decode_uuidarg(struct svc_rqst *rqstp, struct xdr_stream *xdr) { … } static const struct svc_procedure localio_procedures1[] = …; #define LOCALIO_NR_PROCEDURES … static DEFINE_PER_CPU_ALIGNED(unsigned long, localio_count[LOCALIO_NR_PROCEDURES]); const struct svc_version localio_version1 = …;