]>
Commit | Line | Data |
---|---|---|
d8a5ba45 MS |
1 | /* |
2 | FUSE: Filesystem in Userspace | |
1729a16c | 3 | Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> |
d8a5ba45 MS |
4 | |
5 | This program can be distributed under the terms of the GNU GPL. | |
6 | See the file COPYING. | |
7 | */ | |
8 | ||
29d434b3 TH |
9 | #ifndef _FS_FUSE_I_H |
10 | #define _FS_FUSE_I_H | |
11 | ||
f2294482 KS |
12 | #ifndef pr_fmt |
13 | # define pr_fmt(fmt) "fuse: " fmt | |
14 | #endif | |
15 | ||
d8a5ba45 MS |
16 | #include <linux/fuse.h> |
17 | #include <linux/fs.h> | |
51eb01e7 | 18 | #include <linux/mount.h> |
d8a5ba45 MS |
19 | #include <linux/wait.h> |
20 | #include <linux/list.h> | |
21 | #include <linux/spinlock.h> | |
22 | #include <linux/mm.h> | |
23 | #include <linux/backing-dev.h> | |
bafa9654 | 24 | #include <linux/mutex.h> |
3be5a52b | 25 | #include <linux/rwsem.h> |
95668a69 TH |
26 | #include <linux/rbtree.h> |
27 | #include <linux/poll.h> | |
5a18ec17 | 28 | #include <linux/workqueue.h> |
744742d6 | 29 | #include <linux/kref.h> |
60bcc88a | 30 | #include <linux/xattr.h> |
0b6e9ea0 | 31 | #include <linux/pid_namespace.h> |
4e8c2eb5 | 32 | #include <linux/refcount.h> |
8cb08329 | 33 | #include <linux/user_namespace.h> |
d8a5ba45 | 34 | |
5da784cc CS |
35 | /** Default max number of pages that can be used in a single read request */ |
36 | #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32 | |
37 | ||
3be5a52b MS |
38 | /** Bias for fi->writectr, meaning new writepages must not be sent */ |
39 | #define FUSE_NOWRITE INT_MIN | |
40 | ||
27992ef8 BS |
41 | /** Maximum length of a filename, not including terminating null */ |
42 | ||
43 | /* maximum, small enough for FUSE_MIN_READ_BUFFER*/ | |
44 | #define FUSE_NAME_LOW_MAX 1024 | |
45 | /* maximum, but needs a request buffer > FUSE_MIN_READ_BUFFER */ | |
46 | #define FUSE_NAME_MAX (PATH_MAX - 1) | |
1d3d752b | 47 | |
bafa9654 | 48 | /** Number of dentries for each connection in the control filesystem */ |
79a9d994 | 49 | #define FUSE_CTL_NUM_DENTRIES 5 |
bafa9654 | 50 | |
9b17cb59 JK |
51 | /* Frequency (in seconds) of request timeout checks, if opted into */ |
52 | #define FUSE_TIMEOUT_TIMER_FREQ 15 | |
53 | ||
0f6439f6 JK |
54 | /** Frequency (in jiffies) of request timeout checks, if opted into */ |
55 | extern const unsigned long fuse_timeout_timer_freq; | |
56 | ||
2b3933b1 JK |
57 | /** Maximum of max_pages received in init_out */ |
58 | extern unsigned int fuse_max_pages_limit; | |
9b17cb59 JK |
59 | /* |
60 | * Default timeout (in seconds) for the server to reply to a request | |
61 | * before the connection is aborted, if no timeout was specified on mount. | |
62 | */ | |
63 | extern unsigned int fuse_default_req_timeout; | |
64 | /* | |
65 | * Max timeout (in seconds) for the server to reply to a request before | |
66 | * the connection is aborted. | |
67 | */ | |
68 | extern unsigned int fuse_max_req_timeout; | |
2b3933b1 | 69 | |
bafa9654 MS |
70 | /** List of active connections */ |
71 | extern struct list_head fuse_conn_list; | |
72 | ||
73 | /** Global mutex protecting fuse_conn_list and the control filesystem */ | |
74 | extern struct mutex fuse_mutex; | |
413ef8cb | 75 | |
79a9d994 | 76 | /** Module parameters */ |
0486b183 JY |
77 | extern unsigned int max_user_bgreq; |
78 | extern unsigned int max_user_congthresh; | |
79a9d994 | 79 | |
07e77dca MS |
80 | /* One forget request */ |
81 | struct fuse_forget_link { | |
02c048b9 | 82 | struct fuse_forget_one forget_one; |
07e77dca MS |
83 | struct fuse_forget_link *next; |
84 | }; | |
85 | ||
c4d361f6 KJ |
86 | /* Submount lookup tracking */ |
87 | struct fuse_submount_lookup { | |
88 | /** Refcount */ | |
89 | refcount_t count; | |
90 | ||
91 | /** Unique ID, which identifies the inode between userspace | |
92 | * and kernel */ | |
93 | u64 nodeid; | |
94 | ||
95 | /** The request used for sending the FORGET message */ | |
96 | struct fuse_forget_link *forget; | |
97 | }; | |
98 | ||
7dc4e97a AG |
99 | /** Container for data related to mapping to backing file */ |
100 | struct fuse_backing { | |
101 | struct file *file; | |
44350256 | 102 | struct cred *cred; |
7dc4e97a AG |
103 | |
104 | /** refcount */ | |
105 | refcount_t count; | |
106 | struct rcu_head rcu; | |
107 | }; | |
108 | ||
d8a5ba45 MS |
109 | /** FUSE inode */ |
110 | struct fuse_inode { | |
111 | /** Inode data */ | |
112 | struct inode inode; | |
113 | ||
114 | /** Unique ID, which identifies the inode between userspace | |
115 | * and kernel */ | |
116 | u64 nodeid; | |
117 | ||
9e6268db MS |
118 | /** Number of lookups on this inode */ |
119 | u64 nlookup; | |
120 | ||
e5e5558e | 121 | /** The request used for sending the FORGET message */ |
07e77dca | 122 | struct fuse_forget_link *forget; |
e5e5558e | 123 | |
d8a5ba45 | 124 | /** Time in jiffies until the file attributes are valid */ |
0a0898cf | 125 | u64 i_time; |
ebc14c4d | 126 | |
2f1e8196 MS |
127 | /* Which attributes are invalid */ |
128 | u32 inval_mask; | |
129 | ||
ebc14c4d MS |
130 | /** The sticky bit in inode->i_mode may have been removed, so |
131 | preserve the original mode */ | |
541af6a0 | 132 | umode_t orig_i_mode; |
1fb69e78 | 133 | |
972f4c46 MS |
134 | /* Cache birthtime */ |
135 | struct timespec64 i_btime; | |
136 | ||
45c72cd7 PS |
137 | /** 64 bit inode number */ |
138 | u64 orig_ino; | |
139 | ||
1fb69e78 MS |
140 | /** Version of last attribute change */ |
141 | u64 attr_version; | |
93a8c3cd | 142 | |
ab2257e9 | 143 | union { |
cb098dd2 | 144 | /* read/write io cache (regular file only) */ |
ab2257e9 | 145 | struct { |
f15ecfef | 146 | /* Files usable in writepage. Protected by fi->lock */ |
ab2257e9 | 147 | struct list_head write_files; |
3be5a52b | 148 | |
ab2257e9 MS |
149 | /* Writepages pending on truncate or fsync */ |
150 | struct list_head queued_writes; | |
3be5a52b | 151 | |
ab2257e9 MS |
152 | /* Number of sent writes, a negative bias |
153 | * (FUSE_NOWRITE) means more writes are blocked */ | |
154 | int writectr; | |
3be5a52b | 155 | |
cb098dd2 AG |
156 | /** Number of files/maps using page cache */ |
157 | int iocachectr; | |
158 | ||
ab2257e9 MS |
159 | /* Waitq for writepage completion */ |
160 | wait_queue_head_t page_waitq; | |
3be5a52b | 161 | |
205c1d80 AG |
162 | /* waitq for direct-io completion */ |
163 | wait_queue_head_t direct_io_waitq; | |
ab2257e9 | 164 | }; |
4582a4ab | 165 | |
ab2257e9 MS |
166 | /* readdir cache (directory only) */ |
167 | struct { | |
168 | /* true if fully cached */ | |
169 | bool cached; | |
69e34551 | 170 | |
ab2257e9 MS |
171 | /* size of cache */ |
172 | loff_t size; | |
69e34551 | 173 | |
ab2257e9 MS |
174 | /* position at end of cache (position of next entry) */ |
175 | loff_t pos; | |
69e34551 | 176 | |
ab2257e9 MS |
177 | /* version of the cache */ |
178 | u64 version; | |
3494927e | 179 | |
ab2257e9 MS |
180 | /* modification time of directory when cache was |
181 | * started */ | |
182 | struct timespec64 mtime; | |
7118883b | 183 | |
ab2257e9 MS |
184 | /* iversion of directory when cache was started */ |
185 | u64 iversion; | |
261aaba7 | 186 | |
ab2257e9 MS |
187 | /* protects above fields */ |
188 | spinlock_t lock; | |
189 | } rdc; | |
190 | }; | |
69e34551 | 191 | |
4582a4ab FS |
192 | /** Miscellaneous bits describing inode state */ |
193 | unsigned long state; | |
5c672ab3 MS |
194 | |
195 | /** Lock for serializing lookup and readdir for back compatibility*/ | |
196 | struct mutex mutex; | |
f15ecfef KT |
197 | |
198 | /** Lock to protect write related fields */ | |
199 | spinlock_t lock; | |
c2d0ad00 VG |
200 | |
201 | #ifdef CONFIG_FUSE_DAX | |
202 | /* | |
203 | * Dax specific inode data | |
204 | */ | |
205 | struct fuse_inode_dax *dax; | |
206 | #endif | |
c4d361f6 KJ |
207 | /** Submount specific lookup tracking */ |
208 | struct fuse_submount_lookup *submount_lookup; | |
7dc4e97a AG |
209 | #ifdef CONFIG_FUSE_PASSTHROUGH |
210 | /** Reference to backing file in passthrough mode */ | |
211 | struct fuse_backing *fb; | |
212 | #endif | |
4582a4ab FS |
213 | }; |
214 | ||
215 | /** FUSE inode state bits */ | |
216 | enum { | |
217 | /** Advise readdirplus */ | |
218 | FUSE_I_ADVISE_RDPLUS, | |
6314efee MS |
219 | /** Initialized with readdirplus */ |
220 | FUSE_I_INIT_RDPLUS, | |
06a7c3c2 MP |
221 | /** An operation changing file size is in progress */ |
222 | FUSE_I_SIZE_UNSTABLE, | |
5d069dbe MS |
223 | /* Bad inode */ |
224 | FUSE_I_BAD, | |
972f4c46 MS |
225 | /* Has btime */ |
226 | FUSE_I_BTIME, | |
cb098dd2 AG |
227 | /* Wants or already has page cache IO */ |
228 | FUSE_I_CACHE_IO_MODE, | |
d8a5ba45 MS |
229 | }; |
230 | ||
da5e4714 | 231 | struct fuse_conn; |
fcee216b | 232 | struct fuse_mount; |
fc8ff397 | 233 | union fuse_file_args; |
da5e4714 | 234 | |
b6aeaded MS |
235 | /** FUSE specific file data */ |
236 | struct fuse_file { | |
da5e4714 | 237 | /** Fuse connection for this file */ |
fcee216b | 238 | struct fuse_mount *fm; |
da5e4714 | 239 | |
fc8ff397 AG |
240 | /* Argument space reserved for open/release */ |
241 | union fuse_file_args *args; | |
b6aeaded | 242 | |
acf99433 TH |
243 | /** Kernel file handle guaranteed to be unique */ |
244 | u64 kh; | |
245 | ||
b6aeaded MS |
246 | /** File handle used by userspace */ |
247 | u64 fh; | |
c756e0a4 | 248 | |
da5e4714 MS |
249 | /** Node id of this file */ |
250 | u64 nodeid; | |
251 | ||
c756e0a4 | 252 | /** Refcount */ |
4e8c2eb5 | 253 | refcount_t count; |
93a8c3cd | 254 | |
c7b7143c MS |
255 | /** FOPEN_* flags returned by open */ |
256 | u32 open_flags; | |
257 | ||
93a8c3cd MS |
258 | /** Entry on inode's write_files list */ |
259 | struct list_head write_entry; | |
95668a69 | 260 | |
5d7bc7e8 MS |
261 | /* Readdir related */ |
262 | struct { | |
5d7bc7e8 MS |
263 | /* Dir stream position */ |
264 | loff_t pos; | |
265 | ||
266 | /* Offset in cache */ | |
267 | loff_t cache_off; | |
3494927e MS |
268 | |
269 | /* Version of cache we are reading */ | |
270 | u64 version; | |
271 | ||
5d7bc7e8 MS |
272 | } readdir; |
273 | ||
95668a69 TH |
274 | /** RB node to be linked on fuse_conn->polled_files */ |
275 | struct rb_node polled_node; | |
276 | ||
277 | /** Wait queue head for poll */ | |
278 | wait_queue_head_t poll_wait; | |
37fb3a30 | 279 | |
cb098dd2 AG |
280 | /** Does file hold a fi->iocachectr refcount? */ |
281 | enum { IOM_NONE, IOM_CACHED, IOM_UNCACHED } iomode; | |
282 | ||
4a90451b AG |
283 | #ifdef CONFIG_FUSE_PASSTHROUGH |
284 | /** Reference to backing file in passthrough mode */ | |
285 | struct file *passthrough; | |
286 | const struct cred *cred; | |
287 | #endif | |
288 | ||
37fb3a30 MS |
289 | /** Has flock been performed on this file? */ |
290 | bool flock:1; | |
b6aeaded MS |
291 | }; |
292 | ||
334f485d MS |
293 | /** One input argument of a request */ |
294 | struct fuse_in_arg { | |
295 | unsigned size; | |
296 | const void *value; | |
297 | }; | |
298 | ||
334f485d MS |
299 | /** One output argument of a request */ |
300 | struct fuse_arg { | |
301 | unsigned size; | |
302 | void *value; | |
303 | }; | |
304 | ||
a669c2df JK |
305 | /** FUSE folio descriptor */ |
306 | struct fuse_folio_desc { | |
307 | unsigned int length; | |
308 | unsigned int offset; | |
309 | }; | |
310 | ||
7078187a | 311 | struct fuse_args { |
d5b48543 | 312 | uint64_t nodeid; |
1f4e9d03 | 313 | uint32_t opcode; |
15d937d7 MS |
314 | uint8_t in_numargs; |
315 | uint8_t out_numargs; | |
316 | uint8_t ext_idx; | |
c500ebaa | 317 | bool force:1; |
454a7613 | 318 | bool noreply:1; |
e413754b | 319 | bool nocreds:1; |
68583165 MS |
320 | bool in_pages:1; |
321 | bool out_pages:1; | |
0c4bcfde | 322 | bool user_pages:1; |
1f4e9d03 | 323 | bool out_argvar:1; |
68583165 MS |
324 | bool page_zeroing:1; |
325 | bool page_replace:1; | |
bb737bbe | 326 | bool may_block:1; |
15d937d7 | 327 | bool is_ext:1; |
738adade | 328 | bool is_pinned:1; |
41748675 | 329 | bool invalidate_vmap:1; |
7ccd86ba | 330 | struct fuse_in_arg in_args[4]; |
d5b48543 | 331 | struct fuse_arg out_args[2]; |
fcee216b | 332 | void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error); |
41748675 HT |
333 | /* Used for kvec iter backed by vmalloc address */ |
334 | void *vmap_base; | |
7078187a MS |
335 | }; |
336 | ||
68583165 MS |
337 | struct fuse_args_pages { |
338 | struct fuse_args args; | |
68bfb7eb JK |
339 | struct folio **folios; |
340 | struct fuse_folio_desc *descs; | |
341 | unsigned int num_folios; | |
68583165 MS |
342 | }; |
343 | ||
fc8ff397 AG |
344 | struct fuse_release_args { |
345 | struct fuse_args args; | |
346 | struct fuse_release_in inarg; | |
347 | struct inode *inode; | |
348 | }; | |
349 | ||
350 | union fuse_file_args { | |
351 | /* Used during open() */ | |
352 | struct fuse_open_out open_outarg; | |
353 | /* Used during release() */ | |
354 | struct fuse_release_args release_args; | |
355 | }; | |
356 | ||
7078187a MS |
357 | #define FUSE_ARGS(args) struct fuse_args args = {} |
358 | ||
01e9d11a MP |
359 | /** The request IO state (for asynchronous processing) */ |
360 | struct fuse_io_priv { | |
744742d6 | 361 | struct kref refcnt; |
01e9d11a MP |
362 | int async; |
363 | spinlock_t lock; | |
364 | unsigned reqs; | |
365 | ssize_t bytes; | |
366 | size_t size; | |
367 | __u64 offset; | |
368 | bool write; | |
61c12b49 | 369 | bool should_dirty; |
01e9d11a MP |
370 | int err; |
371 | struct kiocb *iocb; | |
9d5722b7 | 372 | struct completion *done; |
7879c4e5 | 373 | bool blocking; |
01e9d11a MP |
374 | }; |
375 | ||
e1c0eecb | 376 | #define FUSE_IO_PRIV_SYNC(i) \ |
744742d6 | 377 | { \ |
1e24edca | 378 | .refcnt = KREF_INIT(1), \ |
744742d6 | 379 | .async = 0, \ |
e1c0eecb | 380 | .iocb = i, \ |
744742d6 SF |
381 | } |
382 | ||
825d6d33 MS |
383 | /** |
384 | * Request flags | |
385 | * | |
386 | * FR_ISREPLY: set if the request has reply | |
387 | * FR_FORCE: force sending of the request even if interrupted | |
388 | * FR_BACKGROUND: request is sent in the background | |
389 | * FR_WAITING: request is counted as "waiting" | |
390 | * FR_ABORTED: the request was aborted | |
391 | * FR_INTERRUPTED: the request has been interrupted | |
392 | * FR_LOCKED: data is being copied to/from the request | |
33e14b4d MS |
393 | * FR_PENDING: request is not yet in userspace |
394 | * FR_SENT: request is in userspace, waiting for an answer | |
395 | * FR_FINISHED: request is finished | |
77cd9d48 | 396 | * FR_PRIVATE: request is on private list |
3e8cb8b2 | 397 | * FR_ASYNC: request is asynchronous |
09098e62 | 398 | * FR_URING: request is handled through fuse-io-uring |
825d6d33 MS |
399 | */ |
400 | enum fuse_req_flag { | |
401 | FR_ISREPLY, | |
402 | FR_FORCE, | |
403 | FR_BACKGROUND, | |
404 | FR_WAITING, | |
405 | FR_ABORTED, | |
406 | FR_INTERRUPTED, | |
407 | FR_LOCKED, | |
33e14b4d MS |
408 | FR_PENDING, |
409 | FR_SENT, | |
410 | FR_FINISHED, | |
77cd9d48 | 411 | FR_PRIVATE, |
3e8cb8b2 | 412 | FR_ASYNC, |
09098e62 | 413 | FR_URING, |
825d6d33 MS |
414 | }; |
415 | ||
334f485d MS |
416 | /** |
417 | * A request to the client | |
dc00809a MS |
418 | * |
419 | * .waitq.lock protects the following fields: | |
420 | * - FR_ABORTED | |
421 | * - FR_LOCKED (may also be modified under fc->lock, tested under both) | |
334f485d MS |
422 | */ |
423 | struct fuse_req { | |
ce1d5a49 MS |
424 | /** This can be on either pending processing or io lists in |
425 | fuse_conn */ | |
334f485d MS |
426 | struct list_head list; |
427 | ||
a4d27e75 MS |
428 | /** Entry on the interrupts list */ |
429 | struct list_head intr_entry; | |
430 | ||
12597287 MS |
431 | /* Input/output arguments */ |
432 | struct fuse_args *args; | |
433 | ||
334f485d | 434 | /** refcount */ |
ec99f6d3 | 435 | refcount_t count; |
334f485d | 436 | |
825d6d33 MS |
437 | /* Request flags, updated with test/set/clear_bit() */ |
438 | unsigned long flags; | |
9bc5ddda | 439 | |
d4993774 MS |
440 | /* The request input header */ |
441 | struct { | |
442 | struct fuse_in_header h; | |
443 | } in; | |
334f485d | 444 | |
d4993774 MS |
445 | /* The request output header */ |
446 | struct { | |
447 | struct fuse_out_header h; | |
448 | } out; | |
334f485d MS |
449 | |
450 | /** Used to wake up the task waiting for completion of request*/ | |
451 | wait_queue_head_t waitq; | |
452 | ||
a62a8ef9 SH |
453 | #if IS_ENABLED(CONFIG_VIRTIO_FS) |
454 | /** virtio-fs's physically contiguous buffer for in and out args */ | |
455 | void *argbuf; | |
456 | #endif | |
24754db2 | 457 | |
fcee216b MR |
458 | /** fuse_mount this request belongs to */ |
459 | struct fuse_mount *fm; | |
c090c8ab BS |
460 | |
461 | #ifdef CONFIG_FUSE_IO_URING | |
462 | void *ring_entry; | |
09098e62 | 463 | void *ring_queue; |
c090c8ab | 464 | #endif |
0f6439f6 JK |
465 | /** When (in jiffies) the request was created */ |
466 | unsigned long create_time; | |
334f485d MS |
467 | }; |
468 | ||
ae3aad77 SH |
469 | struct fuse_iqueue; |
470 | ||
471 | /** | |
472 | * Input queue callbacks | |
473 | * | |
474 | * Input queue signalling is device-specific. For example, the /dev/fuse file | |
475 | * uses fiq->waitq and fasync to wake processes that are waiting on queue | |
476 | * readiness. These callbacks allow other device types to respond to input | |
477 | * queue activity. | |
478 | */ | |
479 | struct fuse_iqueue_ops { | |
480 | /** | |
5de8acb4 | 481 | * Send one forget |
ae3aad77 | 482 | */ |
5de8acb4 | 483 | void (*send_forget)(struct fuse_iqueue *fiq, struct fuse_forget_link *link); |
ae3aad77 SH |
484 | |
485 | /** | |
5de8acb4 | 486 | * Send interrupt for request |
ae3aad77 | 487 | */ |
5de8acb4 | 488 | void (*send_interrupt)(struct fuse_iqueue *fiq, struct fuse_req *req); |
ae3aad77 SH |
489 | |
490 | /** | |
5de8acb4 | 491 | * Send one request |
ae3aad77 | 492 | */ |
5de8acb4 | 493 | void (*send_req)(struct fuse_iqueue *fiq, struct fuse_req *req); |
a62a8ef9 SH |
494 | |
495 | /** | |
496 | * Clean up when fuse_iqueue is destroyed | |
497 | */ | |
498 | void (*release)(struct fuse_iqueue *fiq); | |
ae3aad77 SH |
499 | }; |
500 | ||
501 | /** /dev/fuse input queue operations */ | |
502 | extern const struct fuse_iqueue_ops fuse_dev_fiq_ops; | |
503 | ||
f88996a9 | 504 | struct fuse_iqueue { |
e16714d8 MS |
505 | /** Connection established */ |
506 | unsigned connected; | |
507 | ||
76e43c8c EB |
508 | /** Lock protecting accesses to members of this structure */ |
509 | spinlock_t lock; | |
510 | ||
f88996a9 MS |
511 | /** Readers of the connection are waiting on this */ |
512 | wait_queue_head_t waitq; | |
513 | ||
514 | /** The next unique request id */ | |
515 | u64 reqctr; | |
516 | ||
517 | /** The list of pending requests */ | |
518 | struct list_head pending; | |
519 | ||
520 | /** Pending interrupts */ | |
521 | struct list_head interrupts; | |
522 | ||
523 | /** Queue of pending forgets */ | |
524 | struct fuse_forget_link forget_list_head; | |
525 | struct fuse_forget_link *forget_list_tail; | |
526 | ||
527 | /** Batching of FORGET requests (positive indicates FORGET batch) */ | |
528 | int forget_batch; | |
529 | ||
530 | /** O_ASYNC requests */ | |
531 | struct fasync_struct *fasync; | |
ae3aad77 SH |
532 | |
533 | /** Device-specific callbacks */ | |
534 | const struct fuse_iqueue_ops *ops; | |
535 | ||
536 | /** Device-specific state */ | |
537 | void *priv; | |
f88996a9 MS |
538 | }; |
539 | ||
be2ff42c KT |
540 | #define FUSE_PQ_HASH_BITS 8 |
541 | #define FUSE_PQ_HASH_SIZE (1 << FUSE_PQ_HASH_BITS) | |
542 | ||
3a2b5b9c | 543 | struct fuse_pqueue { |
e96edd94 MS |
544 | /** Connection established */ |
545 | unsigned connected; | |
546 | ||
45a91cb1 MS |
547 | /** Lock protecting accessess to members of this structure */ |
548 | spinlock_t lock; | |
549 | ||
be2ff42c KT |
550 | /** Hash table of requests being processed */ |
551 | struct list_head *processing; | |
3a2b5b9c MS |
552 | |
553 | /** The list of requests under I/O */ | |
554 | struct list_head io; | |
555 | }; | |
556 | ||
cc080e9e MS |
557 | /** |
558 | * Fuse device instance | |
559 | */ | |
560 | struct fuse_dev { | |
561 | /** Fuse connection for this device */ | |
562 | struct fuse_conn *fc; | |
563 | ||
c3696046 MS |
564 | /** Processing queue */ |
565 | struct fuse_pqueue pq; | |
566 | ||
cc080e9e MS |
567 | /** list entry on fc->devices */ |
568 | struct list_head entry; | |
569 | }; | |
570 | ||
780b1b95 JX |
571 | enum fuse_dax_mode { |
572 | FUSE_DAX_INODE_DEFAULT, /* default */ | |
573 | FUSE_DAX_ALWAYS, /* "-o dax=always" */ | |
574 | FUSE_DAX_NEVER, /* "-o dax=never" */ | |
575 | FUSE_DAX_INODE_USER, /* "-o dax=inode" */ | |
576 | }; | |
577 | ||
578 | static inline bool fuse_is_inode_dax_mode(enum fuse_dax_mode mode) | |
579 | { | |
580 | return mode == FUSE_DAX_INODE_DEFAULT || mode == FUSE_DAX_INODE_USER; | |
581 | } | |
582 | ||
0cc2656c SH |
583 | struct fuse_fs_context { |
584 | int fd; | |
62dd1fc8 | 585 | struct file *file; |
0cc2656c SH |
586 | unsigned int rootmode; |
587 | kuid_t user_id; | |
588 | kgid_t group_id; | |
589 | bool is_bdev:1; | |
590 | bool fd_present:1; | |
591 | bool rootmode_present:1; | |
592 | bool user_id_present:1; | |
593 | bool group_id_present:1; | |
594 | bool default_permissions:1; | |
595 | bool allow_other:1; | |
783863d6 | 596 | bool destroy:1; |
15c8e72e VG |
597 | bool no_control:1; |
598 | bool no_force_umount:1; | |
f4fd4ae3 | 599 | bool legacy_opts_show:1; |
780b1b95 | 600 | enum fuse_dax_mode dax_mode; |
0cc2656c SH |
601 | unsigned int max_read; |
602 | unsigned int blksize; | |
603 | const char *subtype; | |
604 | ||
1dd53957 VG |
605 | /* DAX device, may be NULL */ |
606 | struct dax_device *dax_dev; | |
607 | ||
0cc2656c SH |
608 | /* fuse_dev pointer to fill in, should contain NULL on entry */ |
609 | void **fudptr; | |
610 | }; | |
611 | ||
660585b5 MS |
612 | struct fuse_sync_bucket { |
613 | /* count is a possible scalability bottleneck */ | |
614 | atomic_t count; | |
615 | wait_queue_head_t waitq; | |
616 | struct rcu_head rcu; | |
617 | }; | |
618 | ||
d8a5ba45 MS |
619 | /** |
620 | * A Fuse connection. | |
621 | * | |
fcee216b MR |
622 | * This structure is created, when the root filesystem is mounted, and |
623 | * is destroyed, when the client device is closed and the last | |
624 | * fuse_mount is destroyed. | |
d8a5ba45 MS |
625 | */ |
626 | struct fuse_conn { | |
d7133114 MS |
627 | /** Lock protecting accessess to members of this structure */ |
628 | spinlock_t lock; | |
629 | ||
bafa9654 | 630 | /** Refcount */ |
095fc40a | 631 | refcount_t count; |
bafa9654 | 632 | |
c3696046 MS |
633 | /** Number of fuse_dev's */ |
634 | atomic_t dev_count; | |
635 | ||
2396356a LH |
636 | /** Current epoch for up-to-date dentries */ |
637 | atomic_t epoch; | |
638 | ||
dd3e2c55 AV |
639 | struct rcu_head rcu; |
640 | ||
d8a5ba45 | 641 | /** The user id for this mount */ |
499dcf20 | 642 | kuid_t user_id; |
d8a5ba45 | 643 | |
87729a55 | 644 | /** The group id for this mount */ |
499dcf20 | 645 | kgid_t group_id; |
87729a55 | 646 | |
0b6e9ea0 SF |
647 | /** The pid namespace for this mount */ |
648 | struct pid_namespace *pid_ns; | |
649 | ||
8cb08329 EB |
650 | /** The user namespace for this mount */ |
651 | struct user_namespace *user_ns; | |
652 | ||
db50b96c MS |
653 | /** Maximum read size */ |
654 | unsigned max_read; | |
655 | ||
413ef8cb MS |
656 | /** Maximum write size */ |
657 | unsigned max_write; | |
658 | ||
4b91459a | 659 | /** Maximum number of pages that can be used in a single request */ |
5da784cc CS |
660 | unsigned int max_pages; |
661 | ||
a7f0d7aa CK |
662 | /** Constrain ->max_pages to this value during feature negotiation */ |
663 | unsigned int max_pages_limit; | |
664 | ||
f88996a9 MS |
665 | /** Input queue */ |
666 | struct fuse_iqueue iq; | |
334f485d | 667 | |
acf99433 | 668 | /** The next unique kernel file handle */ |
75126f55 | 669 | atomic64_t khctr; |
acf99433 | 670 | |
95668a69 TH |
671 | /** rbtree of fuse_files waiting for poll events indexed by ph */ |
672 | struct rb_root polled_files; | |
673 | ||
7a6d3c8b CH |
674 | /** Maximum number of outstanding background requests */ |
675 | unsigned max_background; | |
676 | ||
677 | /** Number of background requests at which congestion starts */ | |
678 | unsigned congestion_threshold; | |
679 | ||
08a53cdc MS |
680 | /** Number of requests currently in the background */ |
681 | unsigned num_background; | |
682 | ||
d12def1b MS |
683 | /** Number of background requests currently queued for userspace */ |
684 | unsigned active_background; | |
685 | ||
686 | /** The list of background requests set aside for later queuing */ | |
687 | struct list_head bg_queue; | |
688 | ||
ae2dffa3 KT |
689 | /** Protects: max_background, congestion_threshold, num_background, |
690 | * active_background, bg_queue, blocked */ | |
691 | spinlock_t bg_lock; | |
692 | ||
796523fb MP |
693 | /** Flag indicating that INIT reply has been received. Allocating |
694 | * any fuse request will be suspended until the flag is set */ | |
695 | int initialized; | |
696 | ||
08a53cdc MS |
697 | /** Flag indicating if connection is blocked. This will be |
698 | the case before the INIT reply is received, and if there | |
699 | are too many outstading backgrounds requests */ | |
700 | int blocked; | |
701 | ||
702 | /** waitq for blocked connection */ | |
703 | wait_queue_head_t blocked_waitq; | |
de5e3dec | 704 | |
69a53bf2 MS |
705 | /** Connection established, cleared on umount, connection |
706 | abort and device release */ | |
095da6cb | 707 | unsigned connected; |
1e9a4ed9 | 708 | |
3b7008b2 SL |
709 | /** Connection aborted via sysfs */ |
710 | bool aborted; | |
711 | ||
095da6cb MS |
712 | /** Connection failed (version mismatch). Cannot race with |
713 | setting other bitfields since it is only set once in INIT | |
714 | reply, before any other request, and never cleared */ | |
1729a16c | 715 | unsigned conn_error:1; |
334f485d | 716 | |
0ec7ca41 | 717 | /** Connection successful. Only set in INIT */ |
1729a16c | 718 | unsigned conn_init:1; |
0ec7ca41 | 719 | |
704528d8 | 720 | /** Do readahead asynchronously? Only set in INIT */ |
1729a16c | 721 | unsigned async_read:1; |
9cd68455 | 722 | |
3b7008b2 SL |
723 | /** Return an unique read error after abort. Only set in INIT */ |
724 | unsigned abort_err:1; | |
725 | ||
6ff958ed | 726 | /** Do not send separate SETATTR request before open(O_TRUNC) */ |
1729a16c | 727 | unsigned atomic_o_trunc:1; |
6ff958ed | 728 | |
33670fa2 | 729 | /** Filesystem supports NFS exporting. Only set in INIT */ |
1729a16c | 730 | unsigned export_support:1; |
33670fa2 | 731 | |
d5cd66c5 PE |
732 | /** write-back cache policy (default is write-through) */ |
733 | unsigned writeback_cache:1; | |
734 | ||
5c672ab3 MS |
735 | /** allow parallel lookups and readdir (default is serialized) */ |
736 | unsigned parallel_dirops:1; | |
737 | ||
5e940c1d MS |
738 | /** handle fs handles killing suid/sgid/cap on write/chown/trunc */ |
739 | unsigned handle_killpriv:1; | |
740 | ||
5571f1e6 DS |
741 | /** cache READLINK responses in page cache */ |
742 | unsigned cache_symlinks:1; | |
743 | ||
f4fd4ae3 VG |
744 | /* show legacy mount options */ |
745 | unsigned int legacy_opts_show:1; | |
746 | ||
63f9909f VG |
747 | /* |
748 | * fs kills suid/sgid/cap on write/chown/trunc. suid is killed on | |
749 | * write/trunc only if caller did not have CAP_FSETID. sgid is killed | |
750 | * on write/truncate only if caller did not have CAP_FSETID as well as | |
751 | * file has group execute permission. | |
752 | */ | |
753 | unsigned handle_killpriv_v2:1; | |
754 | ||
095da6cb MS |
755 | /* |
756 | * The following bitfields are only for optimization purposes | |
757 | * and hence races in setting them will not cause malfunction | |
758 | */ | |
759 | ||
7678ac50 AG |
760 | /** Is open/release not implemented by fs? */ |
761 | unsigned no_open:1; | |
762 | ||
d9a9ea94 CA |
763 | /** Is opendir/releasedir not implemented by fs? */ |
764 | unsigned no_opendir:1; | |
765 | ||
b6aeaded | 766 | /** Is fsync not implemented by fs? */ |
1729a16c | 767 | unsigned no_fsync:1; |
b6aeaded | 768 | |
82547981 | 769 | /** Is fsyncdir not implemented by fs? */ |
1729a16c | 770 | unsigned no_fsyncdir:1; |
82547981 | 771 | |
b6aeaded | 772 | /** Is flush not implemented by fs? */ |
1729a16c | 773 | unsigned no_flush:1; |
b6aeaded | 774 | |
92a8780e | 775 | /** Is setxattr not implemented by fs? */ |
1729a16c | 776 | unsigned no_setxattr:1; |
92a8780e | 777 | |
52a4c95f VG |
778 | /** Does file server support extended setxattr */ |
779 | unsigned setxattr_ext:1; | |
780 | ||
92a8780e | 781 | /** Is getxattr not implemented by fs? */ |
1729a16c | 782 | unsigned no_getxattr:1; |
92a8780e MS |
783 | |
784 | /** Is listxattr not implemented by fs? */ | |
1729a16c | 785 | unsigned no_listxattr:1; |
92a8780e MS |
786 | |
787 | /** Is removexattr not implemented by fs? */ | |
1729a16c | 788 | unsigned no_removexattr:1; |
92a8780e | 789 | |
37fb3a30 | 790 | /** Are posix file locking primitives not implemented by fs? */ |
1729a16c | 791 | unsigned no_lock:1; |
71421259 | 792 | |
31d40d74 | 793 | /** Is access not implemented by fs? */ |
1729a16c | 794 | unsigned no_access:1; |
31d40d74 | 795 | |
fd72faac | 796 | /** Is create not implemented by fs? */ |
1729a16c | 797 | unsigned no_create:1; |
fd72faac | 798 | |
a4d27e75 | 799 | /** Is interrupt not implemented by fs? */ |
1729a16c | 800 | unsigned no_interrupt:1; |
a4d27e75 | 801 | |
b2d2272f | 802 | /** Is bmap not implemented by fs? */ |
1729a16c | 803 | unsigned no_bmap:1; |
b2d2272f | 804 | |
95668a69 TH |
805 | /** Is poll not implemented by fs? */ |
806 | unsigned no_poll:1; | |
807 | ||
78bb6cb9 | 808 | /** Do multi-page cached writes */ |
1729a16c | 809 | unsigned big_writes:1; |
78bb6cb9 | 810 | |
e0a43ddc MS |
811 | /** Don't apply umask to creation modes */ |
812 | unsigned dont_mask:1; | |
813 | ||
37fb3a30 MS |
814 | /** Are BSD file locking primitives not implemented by fs? */ |
815 | unsigned no_flock:1; | |
816 | ||
519c6040 MS |
817 | /** Is fallocate not implemented by fs? */ |
818 | unsigned no_fallocate:1; | |
819 | ||
1560c974 MS |
820 | /** Is rename with flags implemented by fs? */ |
821 | unsigned no_rename2:1; | |
822 | ||
72d0d248 BF |
823 | /** Use enhanced/automatic page cache invalidation. */ |
824 | unsigned auto_inval_data:1; | |
825 | ||
aa6ff555 | 826 | /** Filesystem is fully responsible for page cache invalidation. */ |
ad2ba64d KS |
827 | unsigned explicit_inval_data:1; |
828 | ||
634734b6 | 829 | /** Does the filesystem support readdirplus? */ |
0b05b183 AA |
830 | unsigned do_readdirplus:1; |
831 | ||
634734b6 EW |
832 | /** Does the filesystem want adaptive readdirplus? */ |
833 | unsigned readdirplus_auto:1; | |
834 | ||
60b9df7a MS |
835 | /** Does the filesystem support asynchronous direct-IO submission? */ |
836 | unsigned async_dio:1; | |
837 | ||
0b5da8db R |
838 | /** Is lseek not implemented by fs? */ |
839 | unsigned no_lseek:1; | |
840 | ||
60bcc88a SF |
841 | /** Does the filesystem support posix acls? */ |
842 | unsigned posix_acl:1; | |
843 | ||
29433a29 MS |
844 | /** Check permissions based on the file mode or not? */ |
845 | unsigned default_permissions:1; | |
846 | ||
847 | /** Allow other than the mounter user to access the filesystem ? */ | |
848 | unsigned allow_other:1; | |
849 | ||
88bc7d50 NV |
850 | /** Does the filesystem support copy_file_range? */ |
851 | unsigned no_copy_file_range:1; | |
852 | ||
1ccd1ea2 MS |
853 | /* Send DESTROY request */ |
854 | unsigned int destroy:1; | |
855 | ||
8fab0106 MS |
856 | /* Delete dentries that have gone stale */ |
857 | unsigned int delete_stale:1; | |
858 | ||
15c8e72e VG |
859 | /** Do not create entry in fusectl fs */ |
860 | unsigned int no_control:1; | |
861 | ||
862 | /** Do not allow MNT_FORCE umount */ | |
863 | unsigned int no_force_umount:1; | |
864 | ||
bf109c64 MR |
865 | /* Auto-mount submounts announced by the server */ |
866 | unsigned int auto_submounts:1; | |
867 | ||
2d82ab25 GK |
868 | /* Propagate syncfs() to server */ |
869 | unsigned int sync_fs:1; | |
870 | ||
3e2b6fdb VG |
871 | /* Initialize security xattrs when creating a new inode */ |
872 | unsigned int init_security:1; | |
873 | ||
8ed7cb3f MS |
874 | /* Add supplementary group info when creating a new inode */ |
875 | unsigned int create_supp_group:1; | |
876 | ||
2ee019fa JX |
877 | /* Does the filesystem support per inode DAX? */ |
878 | unsigned int inode_dax:1; | |
879 | ||
7d375390 MS |
880 | /* Is tmpfile not implemented by fs? */ |
881 | unsigned int no_tmpfile:1; | |
882 | ||
c55e0a55 TF |
883 | /* Relax restrictions to allow shared mmap in FOPEN_DIRECT_IO mode */ |
884 | unsigned int direct_io_allow_mmap:1; | |
e78662e8 | 885 | |
d3045530 MS |
886 | /* Is statx not implemented by fs? */ |
887 | unsigned int no_statx:1; | |
888 | ||
7dc4e97a AG |
889 | /** Passthrough support for read/write IO */ |
890 | unsigned int passthrough:1; | |
891 | ||
41748675 HT |
892 | /* Use pages instead of pointer for kernel I/O */ |
893 | unsigned int use_pages_for_kvec_io:1; | |
894 | ||
eef36cf6 MS |
895 | /* Is link not implemented by fs? */ |
896 | unsigned int no_link:1; | |
897 | ||
3393ff96 BS |
898 | /* Use io_uring for communication */ |
899 | unsigned int io_uring; | |
900 | ||
7dc4e97a AG |
901 | /** Maximum stack depth for passthrough backing files */ |
902 | int max_stack_depth; | |
903 | ||
0cd5b885 MS |
904 | /** The number of requests waiting for completion */ |
905 | atomic_t num_waiting; | |
906 | ||
45714d65 MS |
907 | /** Negotiated minor version */ |
908 | unsigned minor; | |
909 | ||
506b21c9 | 910 | /** Entry on the fuse_conn_list */ |
bafa9654 MS |
911 | struct list_head entry; |
912 | ||
fcee216b | 913 | /** Device ID from the root super block */ |
b6f2fcbc | 914 | dev_t dev; |
bafa9654 MS |
915 | |
916 | /** Dentries in the control filesystem */ | |
917 | struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES]; | |
918 | ||
919 | /** number of dentries used in the above array */ | |
920 | int ctl_ndents; | |
385a17bf | 921 | |
9c8ef561 MS |
922 | /** Key for lock owner ID scrambling */ |
923 | u32 scramble_key[4]; | |
0ec7ca41 | 924 | |
1fb69e78 | 925 | /** Version counter for attribute changes */ |
4510d86f | 926 | atomic64_t attr_version; |
43901aab | 927 | |
69eb56f6 ZT |
928 | /** Version counter for evict inode */ |
929 | atomic64_t evict_ctr; | |
930 | ||
27992ef8 BS |
931 | /* maximum file name length */ |
932 | u32 name_max; | |
933 | ||
43901aab TH |
934 | /** Called on final put */ |
935 | void (*release)(struct fuse_conn *); | |
3b463ae0 | 936 | |
fcee216b MR |
937 | /** |
938 | * Read/write semaphore to hold when accessing the sb of any | |
939 | * fuse_mount belonging to this connection | |
940 | */ | |
3b463ae0 | 941 | struct rw_semaphore killsb; |
cc080e9e MS |
942 | |
943 | /** List of device instances belonging to this connection */ | |
944 | struct list_head devices; | |
1dd53957 VG |
945 | |
946 | #ifdef CONFIG_FUSE_DAX | |
780b1b95 JX |
947 | /* Dax mode */ |
948 | enum fuse_dax_mode dax_mode; | |
949 | ||
1dd53957 VG |
950 | /* Dax specific conn data, non-NULL if DAX is enabled */ |
951 | struct fuse_conn_dax *dax; | |
952 | #endif | |
fcee216b MR |
953 | |
954 | /** List of filesystems using this connection */ | |
955 | struct list_head mounts; | |
660585b5 MS |
956 | |
957 | /* New writepages go into this bucket */ | |
958 | struct fuse_sync_bucket __rcu *curr_bucket; | |
44350256 AG |
959 | |
960 | #ifdef CONFIG_FUSE_PASSTHROUGH | |
961 | /** IDR for backing files ids */ | |
962 | struct idr backing_files_map; | |
963 | #endif | |
24fe962c BS |
964 | |
965 | #ifdef CONFIG_FUSE_IO_URING | |
966 | /** uring connection information*/ | |
967 | struct fuse_ring *ring; | |
968 | #endif | |
0f6439f6 JK |
969 | |
970 | /** Only used if the connection opts into request timeouts */ | |
971 | struct { | |
972 | /* Worker for checking if any requests have timed out */ | |
973 | struct delayed_work work; | |
974 | ||
975 | /* Request timeout (in jiffies). 0 = no timeout */ | |
976 | unsigned int req_timeout; | |
977 | } timeout; | |
d8a5ba45 MS |
978 | }; |
979 | ||
fcee216b MR |
980 | /* |
981 | * Represents a mounted filesystem, potentially a submount. | |
982 | * | |
983 | * This object allows sharing a fuse_conn between separate mounts to | |
984 | * allow submounts with dedicated superblocks and thus separate device | |
985 | * IDs. | |
986 | */ | |
987 | struct fuse_mount { | |
988 | /* Underlying (potentially shared) connection to the FUSE server */ | |
989 | struct fuse_conn *fc; | |
990 | ||
fcee216b MR |
991 | /* |
992 | * Super block for this connection (fc->killsb must be held when | |
993 | * accessing this). | |
994 | */ | |
995 | struct super_block *sb; | |
996 | ||
997 | /* Entry on fc->mounts */ | |
998 | struct list_head fc_entry; | |
053fc4f7 | 999 | struct rcu_head rcu; |
fcee216b MR |
1000 | }; |
1001 | ||
7ccd86ba BS |
1002 | /* |
1003 | * Empty header for FUSE opcodes without specific header needs. | |
1004 | * Used as a placeholder in args->in_args[0] for consistency | |
1005 | * across all FUSE operations, simplifying request handling. | |
1006 | */ | |
1007 | struct fuse_zero_header {}; | |
1008 | ||
1009 | static inline void fuse_set_zero_arg0(struct fuse_args *args) | |
1010 | { | |
1011 | args->in_args[0].size = sizeof(struct fuse_zero_header); | |
1012 | args->in_args[0].value = NULL; | |
1013 | } | |
1014 | ||
fcee216b | 1015 | static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb) |
d8a5ba45 | 1016 | { |
6383bdaa | 1017 | return sb->s_fs_info; |
d8a5ba45 MS |
1018 | } |
1019 | ||
fcee216b MR |
1020 | static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) |
1021 | { | |
bd3bf1e8 | 1022 | return get_fuse_mount_super(sb)->fc; |
fcee216b MR |
1023 | } |
1024 | ||
1025 | static inline struct fuse_mount *get_fuse_mount(struct inode *inode) | |
1026 | { | |
1027 | return get_fuse_mount_super(inode->i_sb); | |
1028 | } | |
1029 | ||
d8a5ba45 MS |
1030 | static inline struct fuse_conn *get_fuse_conn(struct inode *inode) |
1031 | { | |
bd3bf1e8 | 1032 | return get_fuse_mount_super(inode->i_sb)->fc; |
d8a5ba45 MS |
1033 | } |
1034 | ||
1035 | static inline struct fuse_inode *get_fuse_inode(struct inode *inode) | |
1036 | { | |
1037 | return container_of(inode, struct fuse_inode, inode); | |
1038 | } | |
1039 | ||
1040 | static inline u64 get_node_id(struct inode *inode) | |
1041 | { | |
1042 | return get_fuse_inode(inode)->nodeid; | |
1043 | } | |
1044 | ||
d123d8e1 MS |
1045 | static inline int invalid_nodeid(u64 nodeid) |
1046 | { | |
1047 | return !nodeid || nodeid == FUSE_ROOT_ID; | |
1048 | } | |
1049 | ||
4510d86f KT |
1050 | static inline u64 fuse_get_attr_version(struct fuse_conn *fc) |
1051 | { | |
1052 | return atomic64_read(&fc->attr_version); | |
1053 | } | |
1054 | ||
69eb56f6 ZT |
1055 | static inline u64 fuse_get_evict_ctr(struct fuse_conn *fc) |
1056 | { | |
1057 | return atomic64_read(&fc->evict_ctr); | |
1058 | } | |
1059 | ||
15db1683 AG |
1060 | static inline bool fuse_stale_inode(const struct inode *inode, int generation, |
1061 | struct fuse_attr *attr) | |
1062 | { | |
1063 | return inode->i_generation != generation || | |
1064 | inode_wrong_type(inode, attr->mode); | |
1065 | } | |
1066 | ||
5d069dbe MS |
1067 | static inline void fuse_make_bad(struct inode *inode) |
1068 | { | |
1069 | set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state); | |
1070 | } | |
1071 | ||
1072 | static inline bool fuse_is_bad(struct inode *inode) | |
1073 | { | |
1074 | return unlikely(test_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state)); | |
1075 | } | |
1076 | ||
51b02530 JK |
1077 | static inline struct folio **fuse_folios_alloc(unsigned int nfolios, gfp_t flags, |
1078 | struct fuse_folio_desc **desc) | |
1079 | { | |
1080 | struct folio **folios; | |
1081 | ||
1082 | folios = kzalloc(nfolios * (sizeof(struct folio *) + | |
1083 | sizeof(struct fuse_folio_desc)), flags); | |
1084 | *desc = (void *) (folios + nfolios); | |
1085 | ||
1086 | return folios; | |
1087 | } | |
1088 | ||
ac1cf6e3 JK |
1089 | static inline void fuse_folio_descs_length_init(struct fuse_folio_desc *descs, |
1090 | unsigned int index, | |
1091 | unsigned int nr_folios) | |
1092 | { | |
1093 | int i; | |
1094 | ||
1095 | for (i = index; i < index + nr_folios; i++) | |
1096 | descs[i].length = PAGE_SIZE - descs[i].offset; | |
1097 | } | |
1098 | ||
660585b5 MS |
1099 | static inline void fuse_sync_bucket_dec(struct fuse_sync_bucket *bucket) |
1100 | { | |
1101 | /* Need RCU protection to prevent use after free after the decrement */ | |
1102 | rcu_read_lock(); | |
1103 | if (atomic_dec_and_test(&bucket->count)) | |
1104 | wake_up(&bucket->waitq); | |
1105 | rcu_read_unlock(); | |
1106 | } | |
1107 | ||
334f485d | 1108 | /** Device operations */ |
4b6f5d20 | 1109 | extern const struct file_operations fuse_dev_operations; |
334f485d | 1110 | |
4269590a | 1111 | extern const struct dentry_operations fuse_dentry_operations; |
0ce267ff | 1112 | extern const struct dentry_operations fuse_root_dentry_operations; |
dbd561d2 | 1113 | |
e5e5558e MS |
1114 | /** |
1115 | * Get a filled in inode | |
1116 | */ | |
b48badf0 | 1117 | struct inode *fuse_iget(struct super_block *sb, u64 nodeid, |
1fb69e78 | 1118 | int generation, struct fuse_attr *attr, |
69eb56f6 ZT |
1119 | u64 attr_valid, u64 attr_version, |
1120 | u64 evict_ctr); | |
e5e5558e | 1121 | |
13983d06 | 1122 | int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name, |
33670fa2 MS |
1123 | struct fuse_entry_out *outarg, struct inode **inode); |
1124 | ||
e5e5558e MS |
1125 | /** |
1126 | * Send FORGET command | |
1127 | */ | |
07e77dca MS |
1128 | void fuse_queue_forget(struct fuse_conn *fc, struct fuse_forget_link *forget, |
1129 | u64 nodeid, u64 nlookup); | |
1130 | ||
1131 | struct fuse_forget_link *fuse_alloc_forget(void); | |
e5e5558e | 1132 | |
43f5098e | 1133 | /* |
361b1eb5 | 1134 | * Initialize READ or READDIR request |
04730fef | 1135 | */ |
43f5098e MS |
1136 | struct fuse_io_args { |
1137 | union { | |
1138 | struct { | |
1139 | struct fuse_read_in in; | |
1140 | u64 attr_ver; | |
1141 | } read; | |
1142 | struct { | |
1143 | struct fuse_write_in in; | |
1144 | struct fuse_write_out out; | |
f2ef459b | 1145 | bool folio_locked; |
43f5098e MS |
1146 | } write; |
1147 | }; | |
1148 | struct fuse_args_pages ap; | |
1149 | struct fuse_io_priv *io; | |
1150 | struct fuse_file *ff; | |
1151 | }; | |
1152 | ||
1153 | void fuse_read_args_fill(struct fuse_io_args *ia, struct file *file, loff_t pos, | |
1154 | size_t count, int opcode); | |
1155 | ||
04730fef | 1156 | |
e26ee4ef | 1157 | struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release); |
fd72faac | 1158 | void fuse_file_free(struct fuse_file *ff); |
d2c487f1 | 1159 | int fuse_finish_open(struct inode *inode, struct file *file); |
fd72faac | 1160 | |
54d601cb MS |
1161 | void fuse_sync_release(struct fuse_inode *fi, struct fuse_file *ff, |
1162 | unsigned int flags); | |
c756e0a4 | 1163 | |
04730fef MS |
1164 | /** |
1165 | * Send RELEASE or RELEASEDIR request | |
1166 | */ | |
2e64ff15 | 1167 | void fuse_release_common(struct file *file, bool isdir); |
04730fef | 1168 | |
82547981 MS |
1169 | /** |
1170 | * Send FSYNC or FSYNCDIR request | |
1171 | */ | |
02c24a82 | 1172 | int fuse_fsync_common(struct file *file, loff_t start, loff_t end, |
a9c2d1e8 | 1173 | int datasync, int opcode); |
82547981 | 1174 | |
95668a69 TH |
1175 | /** |
1176 | * Notify poll wakeup | |
1177 | */ | |
1178 | int fuse_notify_poll_wakeup(struct fuse_conn *fc, | |
1179 | struct fuse_notify_poll_wakeup_out *outarg); | |
1180 | ||
b6aeaded | 1181 | /** |
1779381d | 1182 | * Initialize file operations on a regular file |
b6aeaded | 1183 | */ |
93a497b9 | 1184 | void fuse_init_file_inode(struct inode *inode, unsigned int flags); |
b6aeaded | 1185 | |
e5e5558e | 1186 | /** |
1779381d | 1187 | * Initialize inode operations on regular files and special files |
e5e5558e MS |
1188 | */ |
1189 | void fuse_init_common(struct inode *inode); | |
1190 | ||
1191 | /** | |
1779381d | 1192 | * Initialize inode and file operations on a directory |
e5e5558e MS |
1193 | */ |
1194 | void fuse_init_dir(struct inode *inode); | |
1195 | ||
1196 | /** | |
1779381d | 1197 | * Initialize inode operations on a symlink |
e5e5558e MS |
1198 | */ |
1199 | void fuse_init_symlink(struct inode *inode); | |
1200 | ||
1201 | /** | |
1202 | * Change attributes of an inode | |
1203 | */ | |
1fb69e78 | 1204 | void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, |
972f4c46 | 1205 | struct fuse_statx *sx, |
1fb69e78 | 1206 | u64 attr_valid, u64 attr_version); |
e5e5558e | 1207 | |
3be5a52b | 1208 | void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, |
972f4c46 | 1209 | struct fuse_statx *sx, |
69eb56f6 ZT |
1210 | u64 attr_valid, u32 cache_mask, |
1211 | u64 evict_ctr); | |
4b52f059 MS |
1212 | |
1213 | u32 fuse_get_cache_mask(struct inode *inode); | |
3be5a52b | 1214 | |
334f485d MS |
1215 | /** |
1216 | * Initialize the client device | |
1217 | */ | |
1218 | int fuse_dev_init(void); | |
1219 | ||
1220 | /** | |
1221 | * Cleanup the client device | |
1222 | */ | |
1223 | void fuse_dev_cleanup(void); | |
1224 | ||
bafa9654 | 1225 | int fuse_ctl_init(void); |
7736e8cc | 1226 | void __exit fuse_ctl_cleanup(void); |
bafa9654 | 1227 | |
7078187a MS |
1228 | /** |
1229 | * Simple request sending that does request allocation and freeing | |
1230 | */ | |
0c679382 AM |
1231 | ssize_t __fuse_simple_request(struct mnt_idmap *idmap, |
1232 | struct fuse_mount *fm, | |
1233 | struct fuse_args *args); | |
1234 | ||
1235 | static inline ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_args *args) | |
1236 | { | |
106e4593 | 1237 | return __fuse_simple_request(&invalid_mnt_idmap, fm, args); |
0c679382 AM |
1238 | } |
1239 | ||
1240 | static inline ssize_t fuse_simple_idmap_request(struct mnt_idmap *idmap, | |
1241 | struct fuse_mount *fm, | |
1242 | struct fuse_args *args) | |
1243 | { | |
1244 | return __fuse_simple_request(idmap, fm, args); | |
1245 | } | |
1246 | ||
fcee216b | 1247 | int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args, |
12597287 | 1248 | gfp_t gfp_flags); |
7078187a | 1249 | |
04ec5af0 SH |
1250 | /** |
1251 | * End a finished request | |
1252 | */ | |
8f622e94 | 1253 | void fuse_request_end(struct fuse_req *req); |
04ec5af0 | 1254 | |
5a5fb1ea | 1255 | /* Abort all requests */ |
eb98e3bd | 1256 | void fuse_abort_conn(struct fuse_conn *fc); |
b8f95e5d | 1257 | void fuse_wait_aborted(struct fuse_conn *fc); |
69a53bf2 | 1258 | |
0f6439f6 JK |
1259 | /* Check if any requests timed out */ |
1260 | void fuse_check_timeout(struct work_struct *work); | |
1261 | ||
e5e5558e MS |
1262 | /** |
1263 | * Invalidate inode attributes | |
1264 | */ | |
fa5eee57 MS |
1265 | |
1266 | /* Attributes possibly changed on data modification */ | |
1267 | #define FUSE_STATX_MODIFY (STATX_MTIME | STATX_CTIME | STATX_BLOCKS) | |
1268 | ||
1269 | /* Attributes possibly changed on data and/or size modification */ | |
1270 | #define FUSE_STATX_MODSIZE (FUSE_STATX_MODIFY | STATX_SIZE) | |
1271 | ||
e5e5558e | 1272 | void fuse_invalidate_attr(struct inode *inode); |
fa5eee57 | 1273 | void fuse_invalidate_attr_mask(struct inode *inode, u32 mask); |
bafa9654 | 1274 | |
dbd561d2 MS |
1275 | void fuse_invalidate_entry_cache(struct dentry *entry); |
1276 | ||
451418fc AG |
1277 | void fuse_invalidate_atime(struct inode *inode); |
1278 | ||
9dc10a54 MS |
1279 | u64 fuse_time_to_jiffies(u64 sec, u32 nsec); |
1280 | #define ATTR_TIMEOUT(o) \ | |
1281 | fuse_time_to_jiffies((o)->attr_valid, (o)->attr_valid_nsec) | |
1282 | ||
d123d8e1 MS |
1283 | void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o); |
1284 | ||
bafa9654 MS |
1285 | /** |
1286 | * Acquire reference to fuse_conn | |
1287 | */ | |
1288 | struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); | |
1289 | ||
38213365 BS |
1290 | /** |
1291 | * Initialize the fuse processing queue | |
1292 | */ | |
1293 | void fuse_pqueue_init(struct fuse_pqueue *fpq); | |
1294 | ||
0d179aa5 TH |
1295 | /** |
1296 | * Initialize fuse_conn | |
1297 | */ | |
fcee216b MR |
1298 | void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm, |
1299 | struct user_namespace *user_ns, | |
ae3aad77 | 1300 | const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv); |
0d179aa5 | 1301 | |
bafa9654 MS |
1302 | /** |
1303 | * Release reference to fuse_conn | |
1304 | */ | |
1305 | void fuse_conn_put(struct fuse_conn *fc); | |
1306 | ||
0cd1eb9a VG |
1307 | struct fuse_dev *fuse_dev_alloc_install(struct fuse_conn *fc); |
1308 | struct fuse_dev *fuse_dev_alloc(void); | |
1309 | void fuse_dev_install(struct fuse_dev *fud, struct fuse_conn *fc); | |
cc080e9e | 1310 | void fuse_dev_free(struct fuse_dev *fud); |
fcee216b | 1311 | void fuse_send_init(struct fuse_mount *fm); |
cc080e9e | 1312 | |
0cc2656c SH |
1313 | /** |
1314 | * Fill in superblock and initialize fuse connection | |
1315 | * @sb: partially-initialized superblock to fill in | |
1316 | * @ctx: mount context | |
1317 | */ | |
1318 | int fuse_fill_super_common(struct super_block *sb, struct fuse_fs_context *ctx); | |
1319 | ||
fcee216b MR |
1320 | /* |
1321 | * Remove the mount from the connection | |
783863d6 | 1322 | * |
fcee216b MR |
1323 | * Returns whether this was the last mount |
1324 | */ | |
1325 | bool fuse_mount_remove(struct fuse_mount *fm); | |
1326 | ||
fe0a7bd8 GK |
1327 | /* |
1328 | * Setup context ops for submounts | |
1329 | */ | |
1330 | int fuse_init_fs_context_submount(struct fs_context *fsc); | |
1331 | ||
fcee216b MR |
1332 | /* |
1333 | * Shut down the connection (possibly sending DESTROY request). | |
783863d6 | 1334 | */ |
fcee216b | 1335 | void fuse_conn_destroy(struct fuse_mount *fm); |
783863d6 | 1336 | |
a27c061a MS |
1337 | /* Drop the connection and free the fuse mount */ |
1338 | void fuse_mount_destroy(struct fuse_mount *fm); | |
1339 | ||
bafa9654 MS |
1340 | /** |
1341 | * Add connection to control filesystem | |
1342 | */ | |
1343 | int fuse_ctl_add_conn(struct fuse_conn *fc); | |
1344 | ||
1345 | /** | |
1346 | * Remove connection from control filesystem | |
1347 | */ | |
1348 | void fuse_ctl_remove_conn(struct fuse_conn *fc); | |
a5bfffac TS |
1349 | |
1350 | /** | |
1351 | * Is file type valid? | |
1352 | */ | |
1353 | int fuse_valid_type(int m); | |
e57ac683 | 1354 | |
eb59bd17 MS |
1355 | bool fuse_invalid_attr(struct fuse_attr *attr); |
1356 | ||
e57ac683 | 1357 | /** |
c2132c1b | 1358 | * Is current process allowed to perform filesystem operation? |
e57ac683 | 1359 | */ |
b1387777 | 1360 | bool fuse_allow_current_process(struct fuse_conn *fc); |
f3332114 MS |
1361 | |
1362 | u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id); | |
bcb4be80 | 1363 | |
5c791fe1 | 1364 | void fuse_flush_time_update(struct inode *inode); |
703c7362 SF |
1365 | void fuse_update_ctime(struct inode *inode); |
1366 | ||
c6c745b8 | 1367 | int fuse_update_attributes(struct inode *inode, struct file *file, u32 mask); |
3be5a52b MS |
1368 | |
1369 | void fuse_flush_writepages(struct inode *inode); | |
1370 | ||
1371 | void fuse_set_nowrite(struct inode *inode); | |
1372 | void fuse_release_nowrite(struct inode *inode); | |
5c5c5e51 | 1373 | |
fcee216b MR |
1374 | /** |
1375 | * Scan all fuse_mounts belonging to fc to find the first where | |
1376 | * ilookup5() returns a result. Return that result and the | |
1377 | * respective fuse_mount in *fm (unless fm is NULL). | |
1378 | * | |
1379 | * The caller must hold fc->killsb. | |
1380 | */ | |
1381 | struct inode *fuse_ilookup(struct fuse_conn *fc, u64 nodeid, | |
1382 | struct fuse_mount **fm); | |
1383 | ||
3b463ae0 JM |
1384 | /** |
1385 | * File-system tells the kernel to invalidate cache for the given node id. | |
1386 | */ | |
fcee216b | 1387 | int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid, |
3b463ae0 JM |
1388 | loff_t offset, loff_t len); |
1389 | ||
1390 | /** | |
1391 | * File-system tells the kernel to invalidate parent attributes and | |
1392 | * the dentry matching parent/name. | |
451d0f59 JM |
1393 | * |
1394 | * If the child_nodeid is non-zero and: | |
1395 | * - matches the inode number for the dentry matching parent/name, | |
1396 | * - is not a mount point | |
1397 | * - is a file or oan empty directory | |
1398 | * then the dentry is unhashed (d_delete()). | |
3b463ae0 | 1399 | */ |
fcee216b | 1400 | int fuse_reverse_inval_entry(struct fuse_conn *fc, u64 parent_nodeid, |
4f8d3702 | 1401 | u64 child_nodeid, struct qstr *name, u32 flags); |
3b463ae0 | 1402 | |
fcee216b | 1403 | int fuse_do_open(struct fuse_mount *fm, u64 nodeid, struct file *file, |
08cbf542 | 1404 | bool isdir); |
ea8cd333 PE |
1405 | |
1406 | /** | |
1407 | * fuse_direct_io() flags | |
1408 | */ | |
1409 | ||
1410 | /** If set, it is WRITE; otherwise - READ */ | |
1411 | #define FUSE_DIO_WRITE (1 << 0) | |
1412 | ||
1413 | /** CUSE pass fuse_direct_io() a file which f_mapping->host is not from FUSE */ | |
1414 | #define FUSE_DIO_CUSE (1 << 1) | |
1415 | ||
d22a943f AV |
1416 | ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, |
1417 | loff_t *ppos, int flags); | |
08cbf542 TH |
1418 | long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, |
1419 | unsigned int flags); | |
b18da0c5 MS |
1420 | long fuse_ioctl_common(struct file *file, unsigned int cmd, |
1421 | unsigned long arg, unsigned int flags); | |
076ccb76 | 1422 | __poll_t fuse_file_poll(struct file *file, poll_table *wait); |
08cbf542 TH |
1423 | int fuse_dev_release(struct inode *inode, struct file *file); |
1424 | ||
d347739a | 1425 | bool fuse_write_update_attr(struct inode *inode, loff_t pos, ssize_t written); |
b0aa7606 | 1426 | |
ab9e13f7 | 1427 | int fuse_flush_times(struct inode *inode, struct fuse_file *ff); |
1e18bda8 | 1428 | int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); |
a1d75f25 | 1429 | |
276a0256 AM |
1430 | int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry, |
1431 | struct iattr *attr, struct file *file); | |
efb9fa9e | 1432 | |
9759bd51 MS |
1433 | void fuse_set_initialized(struct fuse_conn *fc); |
1434 | ||
63576c13 MS |
1435 | void fuse_unlock_inode(struct inode *inode, bool locked); |
1436 | bool fuse_lock_inode(struct inode *inode); | |
5c672ab3 | 1437 | |
60bcc88a | 1438 | int fuse_setxattr(struct inode *inode, const char *name, const void *value, |
52a4c95f | 1439 | size_t size, int flags, unsigned int extra_flags); |
60bcc88a SF |
1440 | ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value, |
1441 | size_t size); | |
703c7362 | 1442 | ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size); |
60bcc88a | 1443 | int fuse_removexattr(struct inode *inode, const char *name); |
34271edb | 1444 | extern const struct xattr_handler * const fuse_xattr_handlers[]; |
60bcc88a SF |
1445 | |
1446 | struct posix_acl; | |
facd6105 | 1447 | struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu); |
05e6295f | 1448 | struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap, |
facd6105 | 1449 | struct dentry *dentry, int type); |
05e6295f | 1450 | int fuse_set_acl(struct mnt_idmap *, struct dentry *dentry, |
549c7297 | 1451 | struct posix_acl *acl, int type); |
d123d8e1 MS |
1452 | |
1453 | /* readdir.c */ | |
1454 | int fuse_readdir(struct file *file, struct dir_context *ctx); | |
1455 | ||
14d46d7a SH |
1456 | /** |
1457 | * Return the number of bytes in an arguments list | |
1458 | */ | |
1459 | unsigned int fuse_len_args(unsigned int numargs, struct fuse_arg *args); | |
1460 | ||
79d96eff SH |
1461 | /** |
1462 | * Get the next unique ID for a request | |
1463 | */ | |
1464 | u64 fuse_get_unique(struct fuse_iqueue *fiq); | |
783863d6 | 1465 | void fuse_free_conn(struct fuse_conn *fc); |
79d96eff | 1466 | |
1dd53957 VG |
1467 | /* dax.c */ |
1468 | ||
c2d0ad00 VG |
1469 | #define FUSE_IS_DAX(inode) (IS_ENABLED(CONFIG_FUSE_DAX) && IS_DAX(inode)) |
1470 | ||
1471 | ssize_t fuse_dax_read_iter(struct kiocb *iocb, struct iov_iter *to); | |
1472 | ssize_t fuse_dax_write_iter(struct kiocb *iocb, struct iov_iter *from); | |
1473 | int fuse_dax_mmap(struct file *file, struct vm_area_struct *vma); | |
6ae330ca | 1474 | int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, u64 dmap_end); |
780b1b95 JX |
1475 | int fuse_dax_conn_alloc(struct fuse_conn *fc, enum fuse_dax_mode mode, |
1476 | struct dax_device *dax_dev); | |
1dd53957 | 1477 | void fuse_dax_conn_free(struct fuse_conn *fc); |
c2d0ad00 | 1478 | bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi); |
93a497b9 | 1479 | void fuse_dax_inode_init(struct inode *inode, unsigned int flags); |
c2d0ad00 | 1480 | void fuse_dax_inode_cleanup(struct inode *inode); |
c3cb6f93 | 1481 | void fuse_dax_dontcache(struct inode *inode, unsigned int flags); |
fd1a1dc6 | 1482 | bool fuse_dax_check_alignment(struct fuse_conn *fc, unsigned int map_alignment); |
9a752d18 | 1483 | void fuse_dax_cancel_work(struct fuse_conn *fc); |
1dd53957 | 1484 | |
9ac29fd3 MS |
1485 | /* ioctl.c */ |
1486 | long fuse_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg); | |
1487 | long fuse_file_compat_ioctl(struct file *file, unsigned int cmd, | |
1488 | unsigned long arg); | |
72227eac | 1489 | int fuse_fileattr_get(struct dentry *dentry, struct fileattr *fa); |
8782a9ae | 1490 | int fuse_fileattr_set(struct mnt_idmap *idmap, |
72227eac | 1491 | struct dentry *dentry, struct fileattr *fa); |
9ac29fd3 | 1492 | |
cb098dd2 | 1493 | /* iomode.c */ |
4864a6dd AG |
1494 | int fuse_file_cached_io_open(struct inode *inode, struct fuse_file *ff); |
1495 | int fuse_inode_uncached_io_start(struct fuse_inode *fi, | |
1496 | struct fuse_backing *fb); | |
1497 | void fuse_inode_uncached_io_end(struct fuse_inode *fi); | |
b9d54c6f | 1498 | |
cb098dd2 AG |
1499 | int fuse_file_io_open(struct file *file, struct inode *inode); |
1500 | void fuse_file_io_release(struct fuse_file *ff, struct inode *inode); | |
b9d54c6f | 1501 | |
cb098dd2 | 1502 | /* file.c */ |
b9d54c6f MS |
1503 | struct fuse_file *fuse_file_open(struct fuse_mount *fm, u64 nodeid, |
1504 | unsigned int open_flags, bool isdir); | |
1505 | void fuse_file_release(struct inode *inode, struct fuse_file *ff, | |
1506 | unsigned int open_flags, fl_owner_t id, bool isdir); | |
1507 | ||
7dc4e97a AG |
1508 | /* passthrough.c */ |
1509 | static inline struct fuse_backing *fuse_inode_backing(struct fuse_inode *fi) | |
1510 | { | |
1511 | #ifdef CONFIG_FUSE_PASSTHROUGH | |
1512 | return READ_ONCE(fi->fb); | |
1513 | #else | |
1514 | return NULL; | |
1515 | #endif | |
1516 | } | |
1517 | ||
1518 | static inline struct fuse_backing *fuse_inode_backing_set(struct fuse_inode *fi, | |
1519 | struct fuse_backing *fb) | |
1520 | { | |
1521 | #ifdef CONFIG_FUSE_PASSTHROUGH | |
1522 | return xchg(&fi->fb, fb); | |
1523 | #else | |
1524 | return NULL; | |
1525 | #endif | |
1526 | } | |
1527 | ||
4a90451b | 1528 | #ifdef CONFIG_FUSE_PASSTHROUGH |
7dc4e97a AG |
1529 | struct fuse_backing *fuse_backing_get(struct fuse_backing *fb); |
1530 | void fuse_backing_put(struct fuse_backing *fb); | |
4a90451b AG |
1531 | #else |
1532 | ||
1533 | static inline struct fuse_backing *fuse_backing_get(struct fuse_backing *fb) | |
1534 | { | |
1535 | return NULL; | |
1536 | } | |
1537 | ||
1538 | static inline void fuse_backing_put(struct fuse_backing *fb) | |
1539 | { | |
1540 | } | |
1541 | #endif | |
1542 | ||
44350256 AG |
1543 | void fuse_backing_files_init(struct fuse_conn *fc); |
1544 | void fuse_backing_files_free(struct fuse_conn *fc); | |
1545 | int fuse_backing_open(struct fuse_conn *fc, struct fuse_backing_map *map); | |
1546 | int fuse_backing_close(struct fuse_conn *fc, int backing_id); | |
7dc4e97a | 1547 | |
4a90451b AG |
1548 | struct fuse_backing *fuse_passthrough_open(struct file *file, |
1549 | struct inode *inode, | |
1550 | int backing_id); | |
1551 | void fuse_passthrough_release(struct fuse_file *ff, struct fuse_backing *fb); | |
1552 | ||
1553 | static inline struct file *fuse_file_passthrough(struct fuse_file *ff) | |
1554 | { | |
1555 | #ifdef CONFIG_FUSE_PASSTHROUGH | |
1556 | return ff->passthrough; | |
1557 | #else | |
1558 | return NULL; | |
1559 | #endif | |
1560 | } | |
1561 | ||
57e1176e AG |
1562 | ssize_t fuse_passthrough_read_iter(struct kiocb *iocb, struct iov_iter *iter); |
1563 | ssize_t fuse_passthrough_write_iter(struct kiocb *iocb, struct iov_iter *iter); | |
5ca73468 AG |
1564 | ssize_t fuse_passthrough_splice_read(struct file *in, loff_t *ppos, |
1565 | struct pipe_inode_info *pipe, | |
1566 | size_t len, unsigned int flags); | |
1567 | ssize_t fuse_passthrough_splice_write(struct pipe_inode_info *pipe, | |
1568 | struct file *out, loff_t *ppos, | |
1569 | size_t len, unsigned int flags); | |
fda0b98e | 1570 | ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma); |
57e1176e | 1571 | |
2b3933b1 JK |
1572 | #ifdef CONFIG_SYSCTL |
1573 | extern int fuse_sysctl_register(void); | |
1574 | extern void fuse_sysctl_unregister(void); | |
1575 | #else | |
1576 | #define fuse_sysctl_register() (0) | |
1577 | #define fuse_sysctl_unregister() do { } while (0) | |
1578 | #endif /* CONFIG_SYSCTL */ | |
1579 | ||
29d434b3 | 1580 | #endif /* _FS_FUSE_I_H */ |