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