rpc_pipe_fs.h 3.7 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
L
Linus Torvalds 已提交
2 3 4 5 6
#ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H
#define _LINUX_SUNRPC_RPC_PIPE_FS_H

#ifdef __KERNEL__

7 8
#include <linux/workqueue.h>

9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
struct rpc_pipe_dir_head {
	struct list_head pdh_entries;
	struct dentry *pdh_dentry;
};

struct rpc_pipe_dir_object_ops;
struct rpc_pipe_dir_object {
	struct list_head pdo_head;
	const struct rpc_pipe_dir_object_ops *pdo_ops;

	void *pdo_data;
};

struct rpc_pipe_dir_object_ops {
	int (*create)(struct dentry *dir,
			struct rpc_pipe_dir_object *pdo);
	void (*destroy)(struct dentry *dir,
			struct rpc_pipe_dir_object *pdo);
};

L
Linus Torvalds 已提交
29 30 31 32 33 34 35 36 37 38 39 40
struct rpc_pipe_msg {
	struct list_head list;
	void *data;
	size_t len;
	size_t copied;
	int errno;
};

struct rpc_pipe_ops {
	ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t);
	ssize_t (*downcall)(struct file *, const char __user *, size_t);
	void (*release_pipe)(struct inode *);
41
	int (*open_pipe)(struct inode *);
L
Linus Torvalds 已提交
42 43 44
	void (*destroy_msg)(struct rpc_pipe_msg *);
};

45
struct rpc_pipe {
L
Linus Torvalds 已提交
46 47
	struct list_head pipe;
	struct list_head in_upcall;
48
	struct list_head in_downcall;
L
Linus Torvalds 已提交
49 50 51 52 53
	int pipelen;
	int nreaders;
	int nwriters;
#define RPC_PIPE_WAIT_FOR_OPEN	1
	int flags;
54
	struct delayed_work queue_timeout;
55
	const struct rpc_pipe_ops *ops;
56
	spinlock_t lock;
57
	struct dentry *dentry;
L
Linus Torvalds 已提交
58 59
};

60 61 62 63
struct rpc_inode {
	struct inode vfs_inode;
	void *private;
	struct rpc_pipe *pipe;
64
	wait_queue_head_t waitq;
65 66
};

L
Linus Torvalds 已提交
67 68 69 70 71 72
static inline struct rpc_inode *
RPC_I(struct inode *inode)
{
	return container_of(inode, struct rpc_inode, vfs_inode);
}

73 74 75 76 77
enum {
	SUNRPC_PIPEFS_NFS_PRIO,
	SUNRPC_PIPEFS_RPC_PRIO,
};

78 79 80 81 82 83 84 85
extern int rpc_pipefs_notifier_register(struct notifier_block *);
extern void rpc_pipefs_notifier_unregister(struct notifier_block *);

enum {
	RPC_PIPEFS_MOUNT,
	RPC_PIPEFS_UMOUNT,
};

86 87
extern struct dentry *rpc_d_lookup_sb(const struct super_block *sb,
				      const unsigned char *dir_name);
88 89
extern int rpc_pipefs_init_net(struct net *net);
extern void rpc_pipefs_exit_net(struct net *net);
90 91
extern struct super_block *rpc_get_sb_net(const struct net *net);
extern void rpc_put_sb_net(const struct net *net);
92

93 94
extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *,
				       char __user *, size_t);
95
extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *);
L
Linus Torvalds 已提交
96

97
struct rpc_clnt;
98
extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *);
99
extern int rpc_remove_client_dir(struct rpc_clnt *);
100 101 102 103 104 105 106 107 108 109 110

extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh);
extern void rpc_init_pipe_dir_object(struct rpc_pipe_dir_object *pdo,
		const struct rpc_pipe_dir_object_ops *pdo_ops,
		void *pdo_data);
extern int rpc_add_pipe_dir_object(struct net *net,
		struct rpc_pipe_dir_head *pdh,
		struct rpc_pipe_dir_object *pdo);
extern void rpc_remove_pipe_dir_object(struct net *net,
		struct rpc_pipe_dir_head *pdh,
		struct rpc_pipe_dir_object *pdo);
111 112 113 114 115 116
extern struct rpc_pipe_dir_object *rpc_find_or_alloc_pipe_dir_object(
		struct net *net,
		struct rpc_pipe_dir_head *pdh,
		int (*match)(struct rpc_pipe_dir_object *, void *),
		struct rpc_pipe_dir_object *(*alloc)(void *),
		void *data);
117 118 119

struct cache_detail;
extern struct dentry *rpc_create_cache_dir(struct dentry *,
120
					   const char *,
A
Al Viro 已提交
121
					   umode_t umode,
122 123 124
					   struct cache_detail *);
extern void rpc_remove_cache_dir(struct dentry *);

125 126 127 128
struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags);
void rpc_destroy_pipe_data(struct rpc_pipe *pipe);
extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *,
					struct rpc_pipe *);
129
extern int rpc_unlink(struct dentry *);
T
Trond Myklebust 已提交
130 131
extern int register_rpc_pipefs(void);
extern void unregister_rpc_pipefs(void);
L
Linus Torvalds 已提交
132

133 134
extern bool gssd_running(struct net *net);

L
Linus Torvalds 已提交
135 136
#endif
#endif