fuse_dev_i.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * FUSE: Filesystem in Userspace
  4. * Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu>
  5. */
  6. #ifndef _FS_FUSE_DEV_I_H
  7. #define _FS_FUSE_DEV_I_H
  8. #include <linux/types.h>
  9. /* Ordinary requests have even IDs, while interrupts IDs are odd */
  10. #define FUSE_INT_REQ_BIT (1ULL << 0)
  11. #define FUSE_REQ_ID_STEP (1ULL << 1)
  12. extern struct wait_queue_head fuse_dev_waitq;
  13. struct fuse_arg;
  14. struct fuse_args;
  15. struct fuse_pqueue;
  16. struct fuse_req;
  17. struct fuse_iqueue;
  18. struct fuse_forget_link;
  19. struct fuse_copy_state {
  20. struct fuse_req *req;
  21. struct iov_iter *iter;
  22. struct pipe_buffer *pipebufs;
  23. struct pipe_buffer *currbuf;
  24. struct pipe_inode_info *pipe;
  25. unsigned long nr_segs;
  26. struct page *pg;
  27. unsigned int len;
  28. unsigned int offset;
  29. bool write:1;
  30. bool move_folios:1;
  31. bool is_uring:1;
  32. struct {
  33. unsigned int copied_sz; /* copied size into the user buffer */
  34. } ring;
  35. };
  36. #define FUSE_DEV_SYNC_INIT ((struct fuse_dev *) 1)
  37. #define FUSE_DEV_PTR_MASK (~1UL)
  38. static inline struct fuse_dev *__fuse_get_dev(struct file *file)
  39. {
  40. /*
  41. * Lockless access is OK, because file->private data is set
  42. * once during mount and is valid until the file is released.
  43. */
  44. struct fuse_dev *fud = READ_ONCE(file->private_data);
  45. return (typeof(fud)) ((unsigned long) fud & FUSE_DEV_PTR_MASK);
  46. }
  47. struct fuse_dev *fuse_get_dev(struct file *file);
  48. unsigned int fuse_req_hash(u64 unique);
  49. struct fuse_req *fuse_request_find(struct fuse_pqueue *fpq, u64 unique);
  50. void fuse_dev_end_requests(struct list_head *head);
  51. void fuse_copy_init(struct fuse_copy_state *cs, bool write,
  52. struct iov_iter *iter);
  53. void fuse_copy_finish(struct fuse_copy_state *cs);
  54. int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs,
  55. unsigned int argpages, struct fuse_arg *args,
  56. int zeroing);
  57. int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args,
  58. unsigned int nbytes);
  59. void fuse_dev_queue_forget(struct fuse_iqueue *fiq,
  60. struct fuse_forget_link *forget);
  61. void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req);
  62. bool fuse_remove_pending_req(struct fuse_req *req, spinlock_t *lock);
  63. bool fuse_request_expired(struct fuse_conn *fc, struct list_head *list);
  64. #endif