rpc_pipe_fs.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_SUNRPC_RPC_PIPE_FS_H
  3. #define _LINUX_SUNRPC_RPC_PIPE_FS_H
  4. #ifdef __KERNEL__
  5. #include <linux/workqueue.h>
  6. struct rpc_pipe_dir_head {
  7. struct list_head pdh_entries;
  8. struct dentry *pdh_dentry;
  9. };
  10. struct rpc_pipe_dir_object_ops;
  11. struct rpc_pipe_dir_object {
  12. struct list_head pdo_head;
  13. const struct rpc_pipe_dir_object_ops *pdo_ops;
  14. void *pdo_data;
  15. };
  16. struct rpc_pipe_dir_object_ops {
  17. int (*create)(struct dentry *dir,
  18. struct rpc_pipe_dir_object *pdo);
  19. void (*destroy)(struct dentry *dir,
  20. struct rpc_pipe_dir_object *pdo);
  21. };
  22. struct rpc_pipe_msg {
  23. struct list_head list;
  24. void *data;
  25. size_t len;
  26. size_t copied;
  27. int errno;
  28. };
  29. struct rpc_pipe_ops {
  30. ssize_t (*upcall)(struct file *, struct rpc_pipe_msg *, char __user *, size_t);
  31. ssize_t (*downcall)(struct file *, const char __user *, size_t);
  32. void (*release_pipe)(struct inode *);
  33. int (*open_pipe)(struct inode *);
  34. void (*destroy_msg)(struct rpc_pipe_msg *);
  35. };
  36. struct rpc_pipe {
  37. struct list_head pipe;
  38. struct list_head in_upcall;
  39. struct list_head in_downcall;
  40. int pipelen;
  41. int nreaders;
  42. int nwriters;
  43. #define RPC_PIPE_WAIT_FOR_OPEN 1
  44. int flags;
  45. struct delayed_work queue_timeout;
  46. const struct rpc_pipe_ops *ops;
  47. spinlock_t lock;
  48. struct dentry *dentry;
  49. };
  50. struct rpc_inode {
  51. struct inode vfs_inode;
  52. void *private;
  53. struct rpc_pipe *pipe;
  54. wait_queue_head_t waitq;
  55. };
  56. static inline struct rpc_inode *
  57. RPC_I(struct inode *inode)
  58. {
  59. return container_of(inode, struct rpc_inode, vfs_inode);
  60. }
  61. enum {
  62. SUNRPC_PIPEFS_NFS_PRIO,
  63. SUNRPC_PIPEFS_RPC_PRIO,
  64. };
  65. extern int rpc_pipefs_notifier_register(struct notifier_block *);
  66. extern void rpc_pipefs_notifier_unregister(struct notifier_block *);
  67. enum {
  68. RPC_PIPEFS_MOUNT,
  69. RPC_PIPEFS_UMOUNT,
  70. };
  71. extern struct dentry *rpc_d_lookup_sb(const struct super_block *sb,
  72. const unsigned char *dir_name);
  73. extern int rpc_pipefs_init_net(struct net *net);
  74. extern void rpc_pipefs_exit_net(struct net *net);
  75. extern struct super_block *rpc_get_sb_net(const struct net *net);
  76. extern void rpc_put_sb_net(const struct net *net);
  77. extern ssize_t rpc_pipe_generic_upcall(struct file *, struct rpc_pipe_msg *,
  78. char __user *, size_t);
  79. extern int rpc_queue_upcall(struct rpc_pipe *, struct rpc_pipe_msg *);
  80. struct rpc_clnt;
  81. extern struct dentry *rpc_create_client_dir(struct dentry *, const char *, struct rpc_clnt *);
  82. extern int rpc_remove_client_dir(struct rpc_clnt *);
  83. extern void rpc_init_pipe_dir_head(struct rpc_pipe_dir_head *pdh);
  84. extern void rpc_init_pipe_dir_object(struct rpc_pipe_dir_object *pdo,
  85. const struct rpc_pipe_dir_object_ops *pdo_ops,
  86. void *pdo_data);
  87. extern int rpc_add_pipe_dir_object(struct net *net,
  88. struct rpc_pipe_dir_head *pdh,
  89. struct rpc_pipe_dir_object *pdo);
  90. extern void rpc_remove_pipe_dir_object(struct net *net,
  91. struct rpc_pipe_dir_head *pdh,
  92. struct rpc_pipe_dir_object *pdo);
  93. extern struct rpc_pipe_dir_object *rpc_find_or_alloc_pipe_dir_object(
  94. struct net *net,
  95. struct rpc_pipe_dir_head *pdh,
  96. int (*match)(struct rpc_pipe_dir_object *, void *),
  97. struct rpc_pipe_dir_object *(*alloc)(void *),
  98. void *data);
  99. struct cache_detail;
  100. extern struct dentry *rpc_create_cache_dir(struct dentry *,
  101. const char *,
  102. umode_t umode,
  103. struct cache_detail *);
  104. extern void rpc_remove_cache_dir(struct dentry *);
  105. struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags);
  106. void rpc_destroy_pipe_data(struct rpc_pipe *pipe);
  107. extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *,
  108. struct rpc_pipe *);
  109. extern int rpc_unlink(struct dentry *);
  110. extern int register_rpc_pipefs(void);
  111. extern void unregister_rpc_pipefs(void);
  112. extern bool gssd_running(struct net *net);
  113. #endif
  114. #endif