rpc_pipe_fs.h 3.9 KB

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