Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H |
3 | #define _LINUX_SUNRPC_RPC_PIPE_FS_H | |
4 | ||
4dceef96 BF |
5 | #include <linux/workqueue.h> |
6 | ||
6739ffb7 TM |
7 | struct rpc_pipe_dir_head { |
8 | struct list_head pdh_entries; | |
9 | struct dentry *pdh_dentry; | |
10 | }; | |
11 | ||
12 | struct rpc_pipe_dir_object_ops; | |
13 | struct rpc_pipe_dir_object { | |
14 | struct list_head pdo_head; | |
15 | const struct rpc_pipe_dir_object_ops *pdo_ops; | |
16 | ||
17 | void *pdo_data; | |
18 | }; | |
19 | ||
20 | struct rpc_pipe_dir_object_ops { | |
21 | int (*create)(struct dentry *dir, | |
22 | struct rpc_pipe_dir_object *pdo); | |
23 | void (*destroy)(struct dentry *dir, | |
24 | struct rpc_pipe_dir_object *pdo); | |
25 | }; | |
26 | ||
1da177e4 LT |
27 | struct rpc_pipe_msg { |
28 | struct list_head list; | |
29 | void *data; | |
30 | size_t len; | |
31 | size_t copied; | |
32 | int errno; | |
33 | }; | |
34 | ||
35 | struct rpc_pipe_ops { | |
36 | ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t); | |
37 | ssize_t (*downcall)(struct file *, const char __user *, size_t); | |
38 | void (*release_pipe)(struct inode *); | |
c3810608 | 39 | int (*open_pipe)(struct inode *); |
1da177e4 LT |
40 | void (*destroy_msg)(struct rpc_pipe_msg *); |
41 | }; | |
42 | ||
ba9e0975 | 43 | struct rpc_pipe { |
1da177e4 LT |
44 | struct list_head pipe; |
45 | struct list_head in_upcall; | |
6e84c7b6 | 46 | struct list_head in_downcall; |
1da177e4 LT |
47 | int pipelen; |
48 | int nreaders; | |
49 | int nwriters; | |
1da177e4 LT |
50 | #define RPC_PIPE_WAIT_FOR_OPEN 1 |
51 | int flags; | |
52bad64d | 52 | struct delayed_work queue_timeout; |
b693ba4a | 53 | const struct rpc_pipe_ops *ops; |
766347be | 54 | spinlock_t lock; |
c239d83b | 55 | struct dentry *dentry; |
1da177e4 LT |
56 | }; |
57 | ||
ba9e0975 SK |
58 | struct rpc_inode { |
59 | struct inode vfs_inode; | |
60 | void *private; | |
61 | struct rpc_pipe *pipe; | |
591ad7fe | 62 | wait_queue_head_t waitq; |
ba9e0975 SK |
63 | }; |
64 | ||
1da177e4 LT |
65 | static inline struct rpc_inode * |
66 | RPC_I(struct inode *inode) | |
67 | { | |
68 | return container_of(inode, struct rpc_inode, vfs_inode); | |
69 | } | |
70 | ||
eee17325 SK |
71 | enum { |
72 | SUNRPC_PIPEFS_NFS_PRIO, | |
73 | SUNRPC_PIPEFS_RPC_PRIO, | |
74 | }; | |
75 | ||
2d00131a SK |
76 | extern int rpc_pipefs_notifier_register(struct notifier_block *); |
77 | extern void rpc_pipefs_notifier_unregister(struct notifier_block *); | |
78 | ||
79 | enum { | |
80 | RPC_PIPEFS_MOUNT, | |
81 | RPC_PIPEFS_UMOUNT, | |
82 | }; | |
83 | ||
432eb1a5 SK |
84 | extern struct dentry *rpc_d_lookup_sb(const struct super_block *sb, |
85 | const unsigned char *dir_name); | |
4b9a445e JL |
86 | extern int rpc_pipefs_init_net(struct net *net); |
87 | extern void rpc_pipefs_exit_net(struct net *net); | |
c21a588f SK |
88 | extern struct super_block *rpc_get_sb_net(const struct net *net); |
89 | extern void rpc_put_sb_net(const struct net *net); | |
432eb1a5 | 90 | |
c1225158 PT |
91 | extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *, |
92 | char __user *, size_t); | |
d706ed1f | 93 | extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *); |
1da177e4 | 94 | |
b18cba09 | 95 | /* returns true if the msg is in-flight, i.e., already eaten by the peer */ |
96 | static inline bool rpc_msg_is_inflight(const struct rpc_pipe_msg *msg) { | |
97 | return (msg->copied != 0 && list_empty(&msg->list)); | |
98 | } | |
99 | ||
458adb8b | 100 | struct rpc_clnt; |
a95e691f | 101 | extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *); |
c36dcfe1 | 102 | extern int rpc_remove_client_dir(struct rpc_clnt *); |
6739ffb7 TM |
103 | |
104 | extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh); | |
105 | extern void rpc_init_pipe_dir_object(struct rpc_pipe_dir_object *pdo, | |
106 | const struct rpc_pipe_dir_object_ops *pdo_ops, | |
107 | void *pdo_data); | |
108 | extern int rpc_add_pipe_dir_object(struct net *net, | |
109 | struct rpc_pipe_dir_head *pdh, | |
110 | struct rpc_pipe_dir_object *pdo); | |
111 | extern void rpc_remove_pipe_dir_object(struct net *net, | |
112 | struct rpc_pipe_dir_head *pdh, | |
113 | struct rpc_pipe_dir_object *pdo); | |
298fc355 TM |
114 | extern struct rpc_pipe_dir_object *rpc_find_or_alloc_pipe_dir_object( |
115 | struct net *net, | |
116 | struct rpc_pipe_dir_head *pdh, | |
117 | int (*match)(struct rpc_pipe_dir_object *, void *), | |
118 | struct rpc_pipe_dir_object *(*alloc)(void *), | |
119 | void *data); | |
8854e82d TM |
120 | |
121 | struct cache_detail; | |
122 | extern struct dentry *rpc_create_cache_dir(struct dentry *, | |
a95e691f | 123 | const char *, |
64f1426f | 124 | umode_t umode, |
8854e82d TM |
125 | struct cache_detail *); |
126 | extern void rpc_remove_cache_dir(struct dentry *); | |
127 | ||
c239d83b SK |
128 | struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags); |
129 | void rpc_destroy_pipe_data(struct rpc_pipe *pipe); | |
130 | extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *, | |
131 | struct rpc_pipe *); | |
5d67476f | 132 | extern int rpc_unlink(struct dentry *); |
7531d692 TM |
133 | extern int register_rpc_pipefs(void); |
134 | extern void unregister_rpc_pipefs(void); | |
1da177e4 | 135 | |
89f84243 JL |
136 | extern bool gssd_running(struct net *net); |
137 | ||
1da177e4 | 138 | #endif |