SUNPRC: cleanup RPC PipeFS pipes upcall interface
[cascardo/linux.git] / include / linux / sunrpc / rpc_pipe_fs.h
1 #ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H
2 #define _LINUX_SUNRPC_RPC_PIPE_FS_H
3
4 #ifdef __KERNEL__
5
6 #include <linux/workqueue.h>
7
8 struct rpc_pipe_msg {
9         struct list_head list;
10         void *data;
11         size_t len;
12         size_t copied;
13         int errno;
14 };
15
16 struct rpc_pipe_ops {
17         ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t);
18         ssize_t (*downcall)(struct file *, const char __user *, size_t);
19         void (*release_pipe)(struct inode *);
20         int (*open_pipe)(struct inode *);
21         void (*destroy_msg)(struct rpc_pipe_msg *);
22 };
23
24 struct rpc_pipe {
25         struct list_head pipe;
26         struct list_head in_upcall;
27         struct list_head in_downcall;
28         int pipelen;
29         int nreaders;
30         int nwriters;
31         wait_queue_head_t waitq;
32 #define RPC_PIPE_WAIT_FOR_OPEN  1
33         int flags;
34         struct delayed_work queue_timeout;
35         const struct rpc_pipe_ops *ops;
36         spinlock_t lock;
37 };
38
39 struct rpc_inode {
40         struct inode vfs_inode;
41         void *private;
42         struct rpc_pipe *pipe;
43 };
44
45 static inline struct rpc_inode *
46 RPC_I(struct inode *inode)
47 {
48         return container_of(inode, struct rpc_inode, vfs_inode);
49 }
50
51 extern int rpc_pipefs_notifier_register(struct notifier_block *);
52 extern void rpc_pipefs_notifier_unregister(struct notifier_block *);
53
54 enum {
55         RPC_PIPEFS_MOUNT,
56         RPC_PIPEFS_UMOUNT,
57 };
58
59 extern struct dentry *rpc_d_lookup_sb(const struct super_block *sb,
60                                       const unsigned char *dir_name);
61 extern void rpc_pipefs_init_net(struct net *net);
62 extern struct super_block *rpc_get_sb_net(const struct net *net);
63 extern void rpc_put_sb_net(const struct net *net);
64
65 extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *,
66                                        char __user *, size_t);
67 extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *);
68
69 struct rpc_clnt;
70 extern struct dentry *rpc_create_client_dir(struct dentry *, struct qstr *, struct rpc_clnt *);
71 extern int rpc_remove_client_dir(struct dentry *);
72
73 struct cache_detail;
74 extern struct dentry *rpc_create_cache_dir(struct dentry *,
75                                            struct qstr *,
76                                            umode_t umode,
77                                            struct cache_detail *);
78 extern void rpc_remove_cache_dir(struct dentry *);
79
80 extern struct dentry *rpc_mkpipe(struct dentry *, const char *, void *,
81                                  const struct rpc_pipe_ops *, int flags);
82 extern int rpc_unlink(struct dentry *);
83 extern struct vfsmount *rpc_get_mount(void);
84 extern void rpc_put_mount(void);
85 extern int register_rpc_pipefs(void);
86 extern void unregister_rpc_pipefs(void);
87
88 #endif
89 #endif