Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H |
| 3 | #define _LINUX_SUNRPC_RPC_PIPE_FS_H |
| 4 | |
| 5 | #ifdef __KERNEL__ |
| 6 | |
J. Bruce Fields | 4dceef9 | 2009-08-20 17:08:39 -0400 | [diff] [blame] | 7 | #include <linux/workqueue.h> |
| 8 | |
Trond Myklebust | 6739ffb | 2013-08-26 15:38:11 -0400 | [diff] [blame] | 9 | struct rpc_pipe_dir_head { |
| 10 | struct list_head pdh_entries; |
| 11 | struct dentry *pdh_dentry; |
| 12 | }; |
| 13 | |
| 14 | struct rpc_pipe_dir_object_ops; |
| 15 | struct 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 | |
| 22 | struct 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | struct rpc_pipe_msg { |
| 30 | struct list_head list; |
| 31 | void *data; |
| 32 | size_t len; |
| 33 | size_t copied; |
| 34 | int errno; |
| 35 | }; |
| 36 | |
| 37 | struct 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 *); |
\"J. Bruce Fields\ | c381060 | 2008-12-23 16:08:32 -0500 | [diff] [blame] | 41 | int (*open_pipe)(struct inode *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | void (*destroy_msg)(struct rpc_pipe_msg *); |
| 43 | }; |
| 44 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 45 | struct rpc_pipe { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | struct list_head pipe; |
| 47 | struct list_head in_upcall; |
Trond Myklebust | 6e84c7b | 2007-06-07 15:31:36 -0400 | [diff] [blame] | 48 | struct list_head in_downcall; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | int pipelen; |
| 50 | int nreaders; |
| 51 | int nwriters; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | #define RPC_PIPE_WAIT_FOR_OPEN 1 |
| 53 | int flags; |
David Howells | 52bad64 | 2006-11-22 14:54:01 +0000 | [diff] [blame] | 54 | struct delayed_work queue_timeout; |
Trond Myklebust | b693ba4 | 2009-08-09 15:14:15 -0400 | [diff] [blame] | 55 | const struct rpc_pipe_ops *ops; |
Stanislav Kinsbursky | 766347b | 2011-12-26 15:43:23 +0300 | [diff] [blame] | 56 | spinlock_t lock; |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 57 | struct dentry *dentry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 60 | struct rpc_inode { |
| 61 | struct inode vfs_inode; |
| 62 | void *private; |
| 63 | struct rpc_pipe *pipe; |
Stanislav Kinsbursky | 591ad7f | 2012-02-27 22:05:54 +0400 | [diff] [blame] | 64 | wait_queue_head_t waitq; |
Stanislav Kinsbursky | ba9e097 | 2011-12-26 15:43:32 +0300 | [diff] [blame] | 65 | }; |
| 66 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | static inline struct rpc_inode * |
| 68 | RPC_I(struct inode *inode) |
| 69 | { |
| 70 | return container_of(inode, struct rpc_inode, vfs_inode); |
| 71 | } |
| 72 | |
Stanislav Kinsbursky | eee17325 | 2012-01-10 16:13:19 +0400 | [diff] [blame] | 73 | enum { |
| 74 | SUNRPC_PIPEFS_NFS_PRIO, |
| 75 | SUNRPC_PIPEFS_RPC_PRIO, |
| 76 | }; |
| 77 | |
Stanislav Kinsbursky | 2d00131 | 2011-12-26 15:39:13 +0300 | [diff] [blame] | 78 | extern int rpc_pipefs_notifier_register(struct notifier_block *); |
| 79 | extern void rpc_pipefs_notifier_unregister(struct notifier_block *); |
| 80 | |
| 81 | enum { |
| 82 | RPC_PIPEFS_MOUNT, |
| 83 | RPC_PIPEFS_UMOUNT, |
| 84 | }; |
| 85 | |
Stanislav Kinsbursky | 432eb1a | 2011-12-26 15:39:22 +0300 | [diff] [blame] | 86 | extern struct dentry *rpc_d_lookup_sb(const struct super_block *sb, |
| 87 | const unsigned char *dir_name); |
Jeff Layton | 4b9a445 | 2013-11-14 07:25:17 -0500 | [diff] [blame] | 88 | extern int rpc_pipefs_init_net(struct net *net); |
| 89 | extern void rpc_pipefs_exit_net(struct net *net); |
Stanislav Kinsbursky | c21a588 | 2011-12-26 15:39:39 +0300 | [diff] [blame] | 90 | extern struct super_block *rpc_get_sb_net(const struct net *net); |
| 91 | extern void rpc_put_sb_net(const struct net *net); |
Stanislav Kinsbursky | 432eb1a | 2011-12-26 15:39:22 +0300 | [diff] [blame] | 92 | |
Peng Tao | c122515 | 2011-09-22 21:50:10 -0400 | [diff] [blame] | 93 | extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *, |
| 94 | char __user *, size_t); |
Stanislav Kinsbursky | d706ed1 | 2011-12-26 15:43:49 +0300 | [diff] [blame] | 95 | extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
Trond Myklebust | 458adb8b | 2009-08-09 15:14:22 -0400 | [diff] [blame] | 97 | struct rpc_clnt; |
Al Viro | a95e691 | 2013-07-14 16:43:54 +0400 | [diff] [blame] | 98 | extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *); |
Trond Myklebust | c36dcfe1 | 2013-08-26 17:44:26 -0400 | [diff] [blame] | 99 | extern int rpc_remove_client_dir(struct rpc_clnt *); |
Trond Myklebust | 6739ffb | 2013-08-26 15:38:11 -0400 | [diff] [blame] | 100 | |
| 101 | extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh); |
| 102 | extern 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); |
| 105 | extern int rpc_add_pipe_dir_object(struct net *net, |
| 106 | struct rpc_pipe_dir_head *pdh, |
| 107 | struct rpc_pipe_dir_object *pdo); |
| 108 | extern void rpc_remove_pipe_dir_object(struct net *net, |
| 109 | struct rpc_pipe_dir_head *pdh, |
| 110 | struct rpc_pipe_dir_object *pdo); |
Trond Myklebust | 298fc35 | 2013-08-27 16:27:04 -0400 | [diff] [blame] | 111 | extern 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); |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 117 | |
| 118 | struct cache_detail; |
| 119 | extern struct dentry *rpc_create_cache_dir(struct dentry *, |
Al Viro | a95e691 | 2013-07-14 16:43:54 +0400 | [diff] [blame] | 120 | const char *, |
Al Viro | 64f1426 | 2011-07-25 00:35:13 -0400 | [diff] [blame] | 121 | umode_t umode, |
Trond Myklebust | 8854e82 | 2009-08-09 15:14:30 -0400 | [diff] [blame] | 122 | struct cache_detail *); |
| 123 | extern void rpc_remove_cache_dir(struct dentry *); |
| 124 | |
Stanislav Kinsbursky | c239d83 | 2011-12-26 15:44:06 +0300 | [diff] [blame] | 125 | struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags); |
| 126 | void rpc_destroy_pipe_data(struct rpc_pipe *pipe); |
| 127 | extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *, |
| 128 | struct rpc_pipe *); |
Trond Myklebust | 5d67476 | 2006-07-31 14:11:48 -0700 | [diff] [blame] | 129 | extern int rpc_unlink(struct dentry *); |
Trond Myklebust | 7531d69 | 2007-05-14 17:21:26 -0400 | [diff] [blame] | 130 | extern int register_rpc_pipefs(void); |
| 131 | extern void unregister_rpc_pipefs(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Jeff Layton | 89f8424 | 2013-11-14 07:25:18 -0500 | [diff] [blame] | 133 | extern bool gssd_running(struct net *net); |
| 134 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | #endif |
| 136 | #endif |