Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H |
| 2 | #define _LINUX_SUNRPC_RPC_PIPE_FS_H |
| 3 | |
| 4 | #ifdef __KERNEL__ |
| 5 | |
J. Bruce Fields | 4dceef9 | 2009-08-20 17:08:39 -0400 | [diff] [blame] | 6 | #include <linux/workqueue.h> |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 *); |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 20 | int (*open_pipe)(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | void (*destroy_msg)(struct rpc_pipe_msg *); |
| 22 | }; |
| 23 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 24 | struct rpc_pipe { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | struct list_head pipe; |
| 26 | struct list_head in_upcall; |
Trond Myklebust | 6e84c7b | 2007-06-07 15:31:36 -0400 | [diff] [blame] | 27 | struct list_head in_downcall; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | int pipelen; |
| 29 | int nreaders; |
| 30 | int nwriters; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #define RPC_PIPE_WAIT_FOR_OPEN 1 |
| 32 | int flags; |
David Howells | 52bad64 | 2006-11-22 14:54:01 +0000 | [diff] [blame] | 33 | struct delayed_work queue_timeout; |
Trond Myklebust | b693ba4 | 2009-08-09 15:14:15 -0400 | [diff] [blame] | 34 | const struct rpc_pipe_ops *ops; |
Stanislav Kinsbursky | 766347b | 2011-12-26 15:43:23 +0300 | [diff] [blame] | 35 | spinlock_t lock; |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 36 | struct dentry *dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | }; |
| 38 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 39 | struct rpc_inode { |
| 40 | struct inode vfs_inode; |
| 41 | void *private; |
| 42 | struct rpc_pipe *pipe; |
Stanislav Kinsbursky | 591ad7f | 2012-02-27 22:05:54 +0400 | [diff] [blame^] | 43 | wait_queue_head_t waitq; |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 44 | }; |
| 45 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | static inline struct rpc_inode * |
| 47 | RPC_I(struct inode *inode) |
| 48 | { |
| 49 | return container_of(inode, struct rpc_inode, vfs_inode); |
| 50 | } |
| 51 | |
Stanislav Kinsbursky | eee1732 | 2012-01-10 16:13:19 +0400 | [diff] [blame] | 52 | enum { |
| 53 | SUNRPC_PIPEFS_NFS_PRIO, |
| 54 | SUNRPC_PIPEFS_RPC_PRIO, |
| 55 | }; |
| 56 | |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 57 | extern int rpc_pipefs_notifier_register(struct notifier_block *); |
| 58 | extern void rpc_pipefs_notifier_unregister(struct notifier_block *); |
| 59 | |
| 60 | enum { |
| 61 | RPC_PIPEFS_MOUNT, |
| 62 | RPC_PIPEFS_UMOUNT, |
| 63 | }; |
| 64 | |
Stanislav Kinsbursky | 432eb1a | 2011-12-26 15:39:22 +0300 | [diff] [blame] | 65 | extern struct dentry *rpc_d_lookup_sb(const struct super_block *sb, |
| 66 | const unsigned char *dir_name); |
Stanislav Kinsbursky | c21a588 | 2011-12-26 15:39:39 +0300 | [diff] [blame] | 67 | extern void rpc_pipefs_init_net(struct net *net); |
| 68 | extern struct super_block *rpc_get_sb_net(const struct net *net); |
| 69 | extern void rpc_put_sb_net(const struct net *net); |
Stanislav Kinsbursky | 432eb1a | 2011-12-26 15:39:22 +0300 | [diff] [blame] | 70 | |
Peng Tao | c122515 | 2011-09-22 21:50:10 -0400 | [diff] [blame] | 71 | extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *, |
| 72 | char __user *, size_t); |
Stanislav Kinsbursky | d706ed1 | 2011-12-26 15:43:49 +0300 | [diff] [blame] | 73 | extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Trond Myklebust | 458adb8b | 2009-08-09 15:14:22 -0400 | [diff] [blame] | 75 | struct rpc_clnt; |
Trond Myklebust | 23ac658 | 2009-08-09 15:14:25 -0400 | [diff] [blame] | 76 | extern struct dentry *rpc_create_client_dir(struct dentry *, struct qstr *, struct rpc_clnt *); |
Trond Myklebust | 458adb8b | 2009-08-09 15:14:22 -0400 | [diff] [blame] | 77 | extern int rpc_remove_client_dir(struct dentry *); |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 78 | |
| 79 | struct cache_detail; |
| 80 | extern struct dentry *rpc_create_cache_dir(struct dentry *, |
| 81 | struct qstr *, |
Al Viro | 64f1426 | 2011-07-25 00:35:13 -0400 | [diff] [blame] | 82 | umode_t umode, |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 83 | struct cache_detail *); |
| 84 | extern void rpc_remove_cache_dir(struct dentry *); |
| 85 | |
Stanislav Kinsbursky | eee1732 | 2012-01-10 16:13:19 +0400 | [diff] [blame] | 86 | extern int rpc_rmdir(struct dentry *dentry); |
| 87 | |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 88 | struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags); |
| 89 | void rpc_destroy_pipe_data(struct rpc_pipe *pipe); |
| 90 | extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *, |
| 91 | struct rpc_pipe *); |
Trond Myklebust | 5d67476 | 2006-07-31 14:11:48 -0700 | [diff] [blame] | 92 | extern int rpc_unlink(struct dentry *); |
Trond Myklebust | 7531d69 | 2007-05-14 17:21:26 -0400 | [diff] [blame] | 93 | extern int register_rpc_pipefs(void); |
| 94 | extern void unregister_rpc_pipefs(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | |
| 96 | #endif |
| 97 | #endif |