brintos

brintos / linux-shallow public Read only

0
0
Text · 2.6 KiB · 3982fea Raw
91 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright (C) 2024 Mike Snitzer <snitzer@hammerspace.com>4 * Copyright (C) 2024 NeilBrown <neilb@suse.de>5 */6#ifndef __LINUX_NFSLOCALIO_H7#define __LINUX_NFSLOCALIO_H8 9/* nfsd_file structure is purposely kept opaque to NFS client */10struct nfsd_file;11 12#if IS_ENABLED(CONFIG_NFS_LOCALIO)13 14#include <linux/module.h>15#include <linux/list.h>16#include <linux/uuid.h>17#include <linux/sunrpc/clnt.h>18#include <linux/sunrpc/svcauth.h>19#include <linux/nfs.h>20#include <net/net_namespace.h>21 22/*23 * Useful to allow a client to negotiate if localio24 * possible with its server.25 *26 * See Documentation/filesystems/nfs/localio.rst for more detail.27 */28typedef struct {29	uuid_t uuid;30	struct list_head list;31	struct net __rcu *net; /* nfsd's network namespace */32	struct auth_domain *dom; /* auth_domain for localio */33} nfs_uuid_t;34 35void nfs_uuid_init(nfs_uuid_t *);36bool nfs_uuid_begin(nfs_uuid_t *);37void nfs_uuid_end(nfs_uuid_t *);38void nfs_uuid_is_local(const uuid_t *, struct list_head *,39		       struct net *, struct auth_domain *, struct module *);40void nfs_uuid_invalidate_clients(struct list_head *list);41void nfs_uuid_invalidate_one_client(nfs_uuid_t *nfs_uuid);42 43/* localio needs to map filehandle -> struct nfsd_file */44extern struct nfsd_file *45nfsd_open_local_fh(struct net *, struct auth_domain *, struct rpc_clnt *,46		   const struct cred *, const struct nfs_fh *,47		   const fmode_t) __must_hold(rcu);48 49struct nfsd_localio_operations {50	bool (*nfsd_serv_try_get)(struct net *);51	void (*nfsd_serv_put)(struct net *);52	struct nfsd_file *(*nfsd_open_local_fh)(struct net *,53						struct auth_domain *,54						struct rpc_clnt *,55						const struct cred *,56						const struct nfs_fh *,57						const fmode_t);58	void (*nfsd_file_put_local)(struct nfsd_file *);59	struct file *(*nfsd_file_file)(struct nfsd_file *);60} ____cacheline_aligned;61 62extern void nfsd_localio_ops_init(void);63extern const struct nfsd_localio_operations *nfs_to;64 65struct nfsd_file *nfs_open_local_fh(nfs_uuid_t *,66		   struct rpc_clnt *, const struct cred *,67		   const struct nfs_fh *, const fmode_t);68 69static inline void nfs_to_nfsd_file_put_local(struct nfsd_file *localio)70{71	/*72	 * Once reference to nfsd_serv is dropped, NFSD could be73	 * unloaded, so ensure safe return from nfsd_file_put_local()74	 * by always taking RCU.75	 */76	rcu_read_lock();77	nfs_to->nfsd_file_put_local(localio);78	rcu_read_unlock();79}80 81#else   /* CONFIG_NFS_LOCALIO */82static inline void nfsd_localio_ops_init(void)83{84}85static inline void nfs_to_nfsd_file_put_local(struct nfsd_file *localio)86{87}88#endif  /* CONFIG_NFS_LOCALIO */89 90#endif  /* __LINUX_NFSLOCALIO_H */91