Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
9#include <linux/types.h>
10
11/* Ordinary requests have even IDs, while interrupts IDs are odd */
12#define FUSE_INT_REQ_BIT (1ULL << 0)
13#define FUSE_REQ_ID_STEP (1ULL << 1)
14
15extern struct wait_queue_head fuse_dev_waitq;
16
17struct fuse_arg;
18struct fuse_args;
19struct fuse_pqueue;
20struct fuse_req;
21struct fuse_iqueue;
22struct fuse_forget_link;
23
24struct fuse_copy_state {
25 struct fuse_req *req;
26 struct iov_iter *iter;
27 struct pipe_buffer *pipebufs;
28 struct pipe_buffer *currbuf;
29 struct pipe_inode_info *pipe;
30 unsigned long nr_segs;
31 struct page *pg;
32 unsigned int len;
33 unsigned int offset;
34 bool write:1;
35 bool move_folios:1;
36 bool is_uring:1;
37 struct {
38 unsigned int copied_sz; /* copied size into the user buffer */
39 } ring;
40};
41
42#define FUSE_DEV_SYNC_INIT ((struct fuse_dev *) 1)
43#define FUSE_DEV_PTR_MASK (~1UL)
44
45static inline struct fuse_dev *__fuse_get_dev(struct file *file)
46{
47 /*
48 * Lockless access is OK, because file->private data is set
49 * once during mount and is valid until the file is released.
50 */
51 struct fuse_dev *fud = READ_ONCE(file->private_data);
52
53 return (typeof(fud)) ((unsigned long) fud & FUSE_DEV_PTR_MASK);
54}
55
56struct fuse_dev *fuse_get_dev(struct file *file);
57
58unsigned int fuse_req_hash(u64 unique);
59struct fuse_req *fuse_request_find(struct fuse_pqueue *fpq, u64 unique);
60
61void fuse_dev_end_requests(struct list_head *head);
62
63void fuse_copy_init(struct fuse_copy_state *cs, bool write,
64 struct iov_iter *iter);
65void fuse_copy_finish(struct fuse_copy_state *cs);
66int fuse_copy_args(struct fuse_copy_state *cs, unsigned int numargs,
67 unsigned int argpages, struct fuse_arg *args,
68 int zeroing);
69int fuse_copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args,
70 unsigned int nbytes);
71void fuse_dev_queue_forget(struct fuse_iqueue *fiq,
72 struct fuse_forget_link *forget);
73void fuse_dev_queue_interrupt(struct fuse_iqueue *fiq, struct fuse_req *req);
74bool fuse_remove_pending_req(struct fuse_req *req, spinlock_t *lock);
75
76bool fuse_request_expired(struct fuse_conn *fc, struct list_head *list);
77
78#endif
79