mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-01-27 15:13:58 +01:00
Add client support for bypassing NFS for localhost reads, writes, and commits. This is only useful when the client and the server are running on the same host. nfs_local_probe() is stubbed out, later commits will enable client and server handshake via a Linux-only LOCALIO auxiliary RPC protocol. This has dynamic binding with the nfsd module (via nfs_localio module which is part of nfs_common). LOCALIO will only work if nfsd is already loaded. The "localio_enabled" nfs kernel module parameter can be used to disable and enable the ability to use LOCALIO support. CONFIG_NFS_LOCALIO enables NFS client support for LOCALIO. Lastly, LOCALIO uses an nfsd_file to initiate all IO. To make proper use of nfsd_file (and nfsd's filecache) its lifetime (duration before nfsd_file_put is called) must extend until after commit, read and write operations. So rather than immediately drop the nfsd_file reference in nfs_local_open_fh(), that doesn't happen until nfs_local_pgio_release() for read/write and not until nfs_local_release_commit_data() for commit. The same applies to the reference held on nfsd's nn->nfsd_serv. Both objects' lifetimes and associated references are managed through calls to nfs_to->nfsd_file_put_local(). Signed-off-by: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Co-developed-by: Mike Snitzer <snitzer@kernel.org> Signed-off-by: Mike Snitzer <snitzer@kernel.org> Signed-off-by: NeilBrown <neilb@suse.de> # nfs_open_local_fh Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
75 lines
2.2 KiB
C
75 lines
2.2 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* Copyright (C) 2024 Mike Snitzer <snitzer@hammerspace.com>
|
|
* Copyright (C) 2024 NeilBrown <neilb@suse.de>
|
|
*/
|
|
#ifndef __LINUX_NFSLOCALIO_H
|
|
#define __LINUX_NFSLOCALIO_H
|
|
|
|
/* nfsd_file structure is purposely kept opaque to NFS client */
|
|
struct nfsd_file;
|
|
|
|
#if IS_ENABLED(CONFIG_NFS_LOCALIO)
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/list.h>
|
|
#include <linux/uuid.h>
|
|
#include <linux/sunrpc/clnt.h>
|
|
#include <linux/sunrpc/svcauth.h>
|
|
#include <linux/nfs.h>
|
|
#include <net/net_namespace.h>
|
|
|
|
/*
|
|
* Useful to allow a client to negotiate if localio
|
|
* possible with its server.
|
|
*
|
|
* See Documentation/filesystems/nfs/localio.rst for more detail.
|
|
*/
|
|
typedef struct {
|
|
uuid_t uuid;
|
|
struct list_head list;
|
|
struct net __rcu *net; /* nfsd's network namespace */
|
|
struct auth_domain *dom; /* auth_domain for localio */
|
|
} nfs_uuid_t;
|
|
|
|
void nfs_uuid_begin(nfs_uuid_t *);
|
|
void nfs_uuid_end(nfs_uuid_t *);
|
|
void nfs_uuid_is_local(const uuid_t *, struct list_head *,
|
|
struct net *, struct auth_domain *, struct module *);
|
|
void nfs_uuid_invalidate_clients(struct list_head *list);
|
|
void nfs_uuid_invalidate_one_client(nfs_uuid_t *nfs_uuid);
|
|
|
|
/* localio needs to map filehandle -> struct nfsd_file */
|
|
extern struct nfsd_file *
|
|
nfsd_open_local_fh(struct net *, struct auth_domain *, struct rpc_clnt *,
|
|
const struct cred *, const struct nfs_fh *,
|
|
const fmode_t) __must_hold(rcu);
|
|
|
|
struct nfsd_localio_operations {
|
|
bool (*nfsd_serv_try_get)(struct net *);
|
|
void (*nfsd_serv_put)(struct net *);
|
|
struct nfsd_file *(*nfsd_open_local_fh)(struct net *,
|
|
struct auth_domain *,
|
|
struct rpc_clnt *,
|
|
const struct cred *,
|
|
const struct nfs_fh *,
|
|
const fmode_t);
|
|
void (*nfsd_file_put_local)(struct nfsd_file *);
|
|
struct file *(*nfsd_file_file)(struct nfsd_file *);
|
|
} ____cacheline_aligned;
|
|
|
|
extern void nfsd_localio_ops_init(void);
|
|
extern const struct nfsd_localio_operations *nfs_to;
|
|
|
|
struct nfsd_file *nfs_open_local_fh(nfs_uuid_t *,
|
|
struct rpc_clnt *, const struct cred *,
|
|
const struct nfs_fh *, const fmode_t);
|
|
|
|
#else /* CONFIG_NFS_LOCALIO */
|
|
static inline void nfsd_localio_ops_init(void)
|
|
{
|
|
}
|
|
#endif /* CONFIG_NFS_LOCALIO */
|
|
|
|
#endif /* __LINUX_NFSLOCALIO_H */
|