1 | /* |
---|---|
2 | FUSE: Filesystem in Userspace |
3 | Copyright (C) 2001-2008 Miklos Szeredi <miklos@szeredi.hu> |
4 | |
5 | This program can be distributed under the terms of the GNU GPL. |
6 | See the file COPYING. |
7 | */ |
8 | |
9 | #ifndef _FS_FUSE_I_H |
10 | #define _FS_FUSE_I_H |
11 | |
12 | #ifndef pr_fmt |
13 | # define pr_fmt(fmt) "fuse: " fmt |
14 | #endif |
15 | |
16 | #include <linux/fuse.h> |
17 | #include <linux/fs.h> |
18 | #include <linux/mount.h> |
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> |
24 | #include <linux/mutex.h> |
25 | #include <linux/rwsem.h> |
26 | #include <linux/rbtree.h> |
27 | #include <linux/poll.h> |
28 | #include <linux/workqueue.h> |
29 | #include <linux/kref.h> |
30 | #include <linux/xattr.h> |
31 | #include <linux/pid_namespace.h> |
32 | #include <linux/refcount.h> |
33 | #include <linux/user_namespace.h> |
34 | |
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 | |
38 | /** Bias for fi->writectr, meaning new writepages must not be sent */ |
39 | #define FUSE_NOWRITE INT_MIN |
40 | |
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) |
47 | |
48 | /** Number of dentries for each connection in the control filesystem */ |
49 | #define FUSE_CTL_NUM_DENTRIES 5 |
50 | |
51 | /* Frequency (in seconds) of request timeout checks, if opted into */ |
52 | #define FUSE_TIMEOUT_TIMER_FREQ 15 |
53 | |
54 | /** Frequency (in jiffies) of request timeout checks, if opted into */ |
55 | extern const unsigned long fuse_timeout_timer_freq; |
56 | |
57 | /** Maximum of max_pages received in init_out */ |
58 | extern unsigned int fuse_max_pages_limit; |
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; |
69 | |
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; |
75 | |
76 | /** Module parameters */ |
77 | extern unsigned int max_user_bgreq; |
78 | extern unsigned int max_user_congthresh; |
79 | |
80 | /* One forget request */ |
81 | struct fuse_forget_link { |
82 | struct fuse_forget_one forget_one; |
83 | struct fuse_forget_link *next; |
84 | }; |
85 | |
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 | |
99 | /** Container for data related to mapping to backing file */ |
100 | struct fuse_backing { |
101 | struct file *file; |
102 | struct cred *cred; |
103 | |
104 | /** refcount */ |
105 | refcount_t count; |
106 | struct rcu_head rcu; |
107 | }; |
108 | |
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 | |
118 | /** Number of lookups on this inode */ |
119 | u64 nlookup; |
120 | |
121 | /** The request used for sending the FORGET message */ |
122 | struct fuse_forget_link *forget; |
123 | |
124 | /** Time in jiffies until the file attributes are valid */ |
125 | u64 i_time; |
126 | |
127 | /* Which attributes are invalid */ |
128 | u32 inval_mask; |
129 | |
130 | /** The sticky bit in inode->i_mode may have been removed, so |
131 | preserve the original mode */ |
132 | umode_t orig_i_mode; |
133 | |
134 | /* Cache birthtime */ |
135 | struct timespec64 i_btime; |
136 | |
137 | /** 64 bit inode number */ |
138 | u64 orig_ino; |
139 | |
140 | /** Version of last attribute change */ |
141 | u64 attr_version; |
142 | |
143 | union { |
144 | /* read/write io cache (regular file only) */ |
145 | struct { |
146 | /* Files usable in writepage. Protected by fi->lock */ |
147 | struct list_head write_files; |
148 | |
149 | /* Writepages pending on truncate or fsync */ |
150 | struct list_head queued_writes; |
151 | |
152 | /* Number of sent writes, a negative bias |
153 | * (FUSE_NOWRITE) means more writes are blocked */ |
154 | int writectr; |
155 | |
156 | /** Number of files/maps using page cache */ |
157 | int iocachectr; |
158 | |
159 | /* Waitq for writepage completion */ |
160 | wait_queue_head_t page_waitq; |
161 | |
162 | /* waitq for direct-io completion */ |
163 | wait_queue_head_t direct_io_waitq; |
164 | }; |
165 | |
166 | /* readdir cache (directory only) */ |
167 | struct { |
168 | /* true if fully cached */ |
169 | bool cached; |
170 | |
171 | /* size of cache */ |
172 | loff_t size; |
173 | |
174 | /* position at end of cache (position of next entry) */ |
175 | loff_t pos; |
176 | |
177 | /* version of the cache */ |
178 | u64 version; |
179 | |
180 | /* modification time of directory when cache was |
181 | * started */ |
182 | struct timespec64 mtime; |
183 | |
184 | /* iversion of directory when cache was started */ |
185 | u64 iversion; |
186 | |
187 | /* protects above fields */ |
188 | spinlock_t lock; |
189 | } rdc; |
190 | }; |
191 | |
192 | /** Miscellaneous bits describing inode state */ |
193 | unsigned long state; |
194 | |
195 | /** Lock for serializing lookup and readdir for back compatibility*/ |
196 | struct mutex mutex; |
197 | |
198 | /** Lock to protect write related fields */ |
199 | spinlock_t lock; |
200 | |
201 | #ifdef CONFIG_FUSE_DAX |
202 | /* |
203 | * Dax specific inode data |
204 | */ |
205 | struct fuse_inode_dax *dax; |
206 | #endif |
207 | /** Submount specific lookup tracking */ |
208 | struct fuse_submount_lookup *submount_lookup; |
209 | #ifdef CONFIG_FUSE_PASSTHROUGH |
210 | /** Reference to backing file in passthrough mode */ |
211 | struct fuse_backing *fb; |
212 | #endif |
213 | }; |
214 | |
215 | /** FUSE inode state bits */ |
216 | enum { |
217 | /** Advise readdirplus */ |
218 | FUSE_I_ADVISE_RDPLUS, |
219 | /** Initialized with readdirplus */ |
220 | FUSE_I_INIT_RDPLUS, |
221 | /** An operation changing file size is in progress */ |
222 | FUSE_I_SIZE_UNSTABLE, |
223 | /* Bad inode */ |
224 | FUSE_I_BAD, |
225 | /* Has btime */ |
226 | FUSE_I_BTIME, |
227 | /* Wants or already has page cache IO */ |
228 | FUSE_I_CACHE_IO_MODE, |
229 | }; |
230 | |
231 | struct fuse_conn; |
232 | struct fuse_mount; |
233 | union fuse_file_args; |
234 | |
235 | /** FUSE specific file data */ |
236 | struct fuse_file { |
237 | /** Fuse connection for this file */ |
238 | struct fuse_mount *fm; |
239 | |
240 | /* Argument space reserved for open/release */ |
241 | union fuse_file_args *args; |
242 | |
243 | /** Kernel file handle guaranteed to be unique */ |
244 | u64 kh; |
245 | |
246 | /** File handle used by userspace */ |
247 | u64 fh; |
248 | |
249 | /** Node id of this file */ |
250 | u64 nodeid; |
251 | |
252 | /** Refcount */ |
253 | refcount_t count; |
254 | |
255 | /** FOPEN_* flags returned by open */ |
256 | u32 open_flags; |
257 | |
258 | /** Entry on inode's write_files list */ |
259 | struct list_head write_entry; |
260 | |
261 | /* Readdir related */ |
262 | struct { |
263 | /* Dir stream position */ |
264 | loff_t pos; |
265 | |
266 | /* Offset in cache */ |
267 | loff_t cache_off; |
268 | |
269 | /* Version of cache we are reading */ |
270 | u64 version; |
271 | |
272 | } readdir; |
273 | |
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; |
279 | |
280 | /** Does file hold a fi->iocachectr refcount? */ |
281 | enum { IOM_NONE, IOM_CACHED, IOM_UNCACHED } iomode; |
282 | |
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 | |
289 | /** Has flock been performed on this file? */ |
290 | bool flock:1; |
291 | }; |
292 | |
293 | /** One input argument of a request */ |
294 | struct fuse_in_arg { |
295 | unsigned size; |
296 | const void *value; |
297 | }; |
298 | |
299 | /** One output argument of a request */ |
300 | struct fuse_arg { |
301 | unsigned size; |
302 | void *value; |
303 | }; |
304 | |
305 | /** FUSE folio descriptor */ |
306 | struct fuse_folio_desc { |
307 | unsigned int length; |
308 | unsigned int offset; |
309 | }; |
310 | |
311 | struct fuse_args { |
312 | uint64_t nodeid; |
313 | uint32_t opcode; |
314 | uint8_t in_numargs; |
315 | uint8_t out_numargs; |
316 | uint8_t ext_idx; |
317 | bool force:1; |
318 | bool noreply:1; |
319 | bool nocreds:1; |
320 | bool in_pages:1; |
321 | bool out_pages:1; |
322 | bool user_pages:1; |
323 | bool out_argvar:1; |
324 | bool page_zeroing:1; |
325 | bool page_replace:1; |
326 | bool may_block:1; |
327 | bool is_ext:1; |
328 | bool is_pinned:1; |
329 | bool invalidate_vmap:1; |
330 | struct fuse_in_arg in_args[4]; |
331 | struct fuse_arg out_args[2]; |
332 | void (*end)(struct fuse_mount *fm, struct fuse_args *args, int error); |
333 | /* Used for kvec iter backed by vmalloc address */ |
334 | void *vmap_base; |
335 | }; |
336 | |
337 | struct fuse_args_pages { |
338 | struct fuse_args args; |
339 | struct folio **folios; |
340 | struct fuse_folio_desc *descs; |
341 | unsigned int num_folios; |
342 | }; |
343 | |
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 | |
357 | #define FUSE_ARGS(args) struct fuse_args args = {} |
358 | |
359 | /** The request IO state (for asynchronous processing) */ |
360 | struct fuse_io_priv { |
361 | struct kref refcnt; |
362 | int async; |
363 | spinlock_t lock; |
364 | unsigned reqs; |
365 | ssize_t bytes; |
366 | size_t size; |
367 | __u64 offset; |
368 | bool write; |
369 | bool should_dirty; |
370 | int err; |
371 | struct kiocb *iocb; |
372 | struct completion *done; |
373 | bool blocking; |
374 | }; |
375 | |
376 | #define FUSE_IO_PRIV_SYNC(i) \ |
377 | { \ |
378 | .refcnt = KREF_INIT(1), \ |
379 | .async = 0, \ |
380 | .iocb = i, \ |
381 | } |
382 | |
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 |
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 |
396 | * FR_PRIVATE: request is on private list |
397 | * FR_ASYNC: request is asynchronous |
398 | * FR_URING: request is handled through fuse-io-uring |
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, |
408 | FR_PENDING, |
409 | FR_SENT, |
410 | FR_FINISHED, |
411 | FR_PRIVATE, |
412 | FR_ASYNC, |
413 | FR_URING, |
414 | }; |
415 | |
416 | /** |
417 | * A request to the client |
418 | * |
419 | * .waitq.lock protects the following fields: |
420 | * - FR_ABORTED |
421 | * - FR_LOCKED (may also be modified under fc->lock, tested under both) |
422 | */ |
423 | struct fuse_req { |
424 | /** This can be on either pending processing or io lists in |
425 | fuse_conn */ |
426 | struct list_head list; |
427 | |
428 | /** Entry on the interrupts list */ |
429 | struct list_head intr_entry; |
430 | |
431 | /* Input/output arguments */ |
432 | struct fuse_args *args; |
433 | |
434 | /** refcount */ |
435 | refcount_t count; |
436 | |
437 | /* Request flags, updated with test/set/clear_bit() */ |
438 | unsigned long flags; |
439 | |
440 | /* The request input header */ |
441 | struct { |
442 | struct fuse_in_header h; |
443 | } in; |
444 | |
445 | /* The request output header */ |
446 | struct { |
447 | struct fuse_out_header h; |
448 | } out; |
449 | |
450 | /** Used to wake up the task waiting for completion of request*/ |
451 | wait_queue_head_t waitq; |
452 | |
453 | #if IS_ENABLED(CONFIG_VIRTIO_FS) |
454 | /** virtio-fs's physically contiguous buffer for in and out args */ |
455 | void *argbuf; |
456 | #endif |
457 | |
458 | /** fuse_mount this request belongs to */ |
459 | struct fuse_mount *fm; |
460 | |
461 | #ifdef CONFIG_FUSE_IO_URING |
462 | void *ring_entry; |
463 | void *ring_queue; |
464 | #endif |
465 | /** When (in jiffies) the request was created */ |
466 | unsigned long create_time; |
467 | }; |
468 | |
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 | /** |
481 | * Send one forget |
482 | */ |
483 | void (*send_forget)(struct fuse_iqueue *fiq, struct fuse_forget_link *link); |
484 | |
485 | /** |
486 | * Send interrupt for request |
487 | */ |
488 | void (*send_interrupt)(struct fuse_iqueue *fiq, struct fuse_req *req); |
489 | |
490 | /** |
491 | * Send one request |
492 | */ |
493 | void (*send_req)(struct fuse_iqueue *fiq, struct fuse_req *req); |
494 | |
495 | /** |
496 | * Clean up when fuse_iqueue is destroyed |
497 | */ |
498 | void (*release)(struct fuse_iqueue *fiq); |
499 | }; |
500 | |
501 | /** /dev/fuse input queue operations */ |
502 | extern const struct fuse_iqueue_ops fuse_dev_fiq_ops; |
503 | |
504 | struct fuse_iqueue { |
505 | /** Connection established */ |
506 | unsigned connected; |
507 | |
508 | /** Lock protecting accesses to members of this structure */ |
509 | spinlock_t lock; |
510 | |
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; |
532 | |
533 | /** Device-specific callbacks */ |
534 | const struct fuse_iqueue_ops *ops; |
535 | |
536 | /** Device-specific state */ |
537 | void *priv; |
538 | }; |
539 | |
540 | #define FUSE_PQ_HASH_BITS 8 |
541 | #define FUSE_PQ_HASH_SIZE (1 << FUSE_PQ_HASH_BITS) |
542 | |
543 | struct fuse_pqueue { |
544 | /** Connection established */ |
545 | unsigned connected; |
546 | |
547 | /** Lock protecting accessess to members of this structure */ |
548 | spinlock_t lock; |
549 | |
550 | /** Hash table of requests being processed */ |
551 | struct list_head *processing; |
552 | |
553 | /** The list of requests under I/O */ |
554 | struct list_head io; |
555 | }; |
556 | |
557 | /** |
558 | * Fuse device instance |
559 | */ |
560 | struct fuse_dev { |
561 | /** Fuse connection for this device */ |
562 | struct fuse_conn *fc; |
563 | |
564 | /** Processing queue */ |
565 | struct fuse_pqueue pq; |
566 | |
567 | /** list entry on fc->devices */ |
568 | struct list_head entry; |
569 | }; |
570 | |
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 | |
583 | struct fuse_fs_context { |
584 | int fd; |
585 | struct file *file; |
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; |
596 | bool destroy:1; |
597 | bool no_control:1; |
598 | bool no_force_umount:1; |
599 | bool legacy_opts_show:1; |
600 | enum fuse_dax_mode dax_mode; |
601 | unsigned int max_read; |
602 | unsigned int blksize; |
603 | const char *subtype; |
604 | |
605 | /* DAX device, may be NULL */ |
606 | struct dax_device *dax_dev; |
607 | |
608 | /* fuse_dev pointer to fill in, should contain NULL on entry */ |
609 | void **fudptr; |
610 | }; |
611 | |
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 | |
619 | /** |
620 | * A Fuse connection. |
621 | * |
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. |
625 | */ |
626 | struct fuse_conn { |
627 | /** Lock protecting accessess to members of this structure */ |
628 | spinlock_t lock; |
629 | |
630 | /** Refcount */ |
631 | refcount_t count; |
632 | |
633 | /** Number of fuse_dev's */ |
634 | atomic_t dev_count; |
635 | |
636 | /** Current epoch for up-to-date dentries */ |
637 | atomic_t epoch; |
638 | |
639 | struct rcu_head rcu; |
640 | |
641 | /** The user id for this mount */ |
642 | kuid_t user_id; |
643 | |
644 | /** The group id for this mount */ |
645 | kgid_t group_id; |
646 | |
647 | /** The pid namespace for this mount */ |
648 | struct pid_namespace *pid_ns; |
649 | |
650 | /** The user namespace for this mount */ |
651 | struct user_namespace *user_ns; |
652 | |
653 | /** Maximum read size */ |
654 | unsigned max_read; |
655 | |
656 | /** Maximum write size */ |
657 | unsigned max_write; |
658 | |
659 | /** Maximum number of pages that can be used in a single request */ |
660 | unsigned int max_pages; |
661 | |
662 | /** Constrain ->max_pages to this value during feature negotiation */ |
663 | unsigned int max_pages_limit; |
664 | |
665 | /** Input queue */ |
666 | struct fuse_iqueue iq; |
667 | |
668 | /** The next unique kernel file handle */ |
669 | atomic64_t khctr; |
670 | |
671 | /** rbtree of fuse_files waiting for poll events indexed by ph */ |
672 | struct rb_root polled_files; |
673 | |
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 | |
680 | /** Number of requests currently in the background */ |
681 | unsigned num_background; |
682 | |
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 | |
689 | /** Protects: max_background, congestion_threshold, num_background, |
690 | * active_background, bg_queue, blocked */ |
691 | spinlock_t bg_lock; |
692 | |
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 | |
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; |
704 | |
705 | /** Connection established, cleared on umount, connection |
706 | abort and device release */ |
707 | unsigned connected; |
708 | |
709 | /** Connection aborted via sysfs */ |
710 | bool aborted; |
711 | |
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 */ |
715 | unsigned conn_error:1; |
716 | |
717 | /** Connection successful. Only set in INIT */ |
718 | unsigned conn_init:1; |
719 | |
720 | /** Do readahead asynchronously? Only set in INIT */ |
721 | unsigned async_read:1; |
722 | |
723 | /** Return an unique read error after abort. Only set in INIT */ |
724 | unsigned abort_err:1; |
725 | |
726 | /** Do not send separate SETATTR request before open(O_TRUNC) */ |
727 | unsigned atomic_o_trunc:1; |
728 | |
729 | /** Filesystem supports NFS exporting. Only set in INIT */ |
730 | unsigned export_support:1; |
731 | |
732 | /** write-back cache policy (default is write-through) */ |
733 | unsigned writeback_cache:1; |
734 | |
735 | /** allow parallel lookups and readdir (default is serialized) */ |
736 | unsigned parallel_dirops:1; |
737 | |
738 | /** handle fs handles killing suid/sgid/cap on write/chown/trunc */ |
739 | unsigned handle_killpriv:1; |
740 | |
741 | /** cache READLINK responses in page cache */ |
742 | unsigned cache_symlinks:1; |
743 | |
744 | /* show legacy mount options */ |
745 | unsigned int legacy_opts_show:1; |
746 | |
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 | |
755 | /* |
756 | * The following bitfields are only for optimization purposes |
757 | * and hence races in setting them will not cause malfunction |
758 | */ |
759 | |
760 | /** Is open/release not implemented by fs? */ |
761 | unsigned no_open:1; |
762 | |
763 | /** Is opendir/releasedir not implemented by fs? */ |
764 | unsigned no_opendir:1; |
765 | |
766 | /** Is fsync not implemented by fs? */ |
767 | unsigned no_fsync:1; |
768 | |
769 | /** Is fsyncdir not implemented by fs? */ |
770 | unsigned no_fsyncdir:1; |
771 | |
772 | /** Is flush not implemented by fs? */ |
773 | unsigned no_flush:1; |
774 | |
775 | /** Is setxattr not implemented by fs? */ |
776 | unsigned no_setxattr:1; |
777 | |
778 | /** Does file server support extended setxattr */ |
779 | unsigned setxattr_ext:1; |
780 | |
781 | /** Is getxattr not implemented by fs? */ |
782 | unsigned no_getxattr:1; |
783 | |
784 | /** Is listxattr not implemented by fs? */ |
785 | unsigned no_listxattr:1; |
786 | |
787 | /** Is removexattr not implemented by fs? */ |
788 | unsigned no_removexattr:1; |
789 | |
790 | /** Are posix file locking primitives not implemented by fs? */ |
791 | unsigned no_lock:1; |
792 | |
793 | /** Is access not implemented by fs? */ |
794 | unsigned no_access:1; |
795 | |
796 | /** Is create not implemented by fs? */ |
797 | unsigned no_create:1; |
798 | |
799 | /** Is interrupt not implemented by fs? */ |
800 | unsigned no_interrupt:1; |
801 | |
802 | /** Is bmap not implemented by fs? */ |
803 | unsigned no_bmap:1; |
804 | |
805 | /** Is poll not implemented by fs? */ |
806 | unsigned no_poll:1; |
807 | |
808 | /** Do multi-page cached writes */ |
809 | unsigned big_writes:1; |
810 | |
811 | /** Don't apply umask to creation modes */ |
812 | unsigned dont_mask:1; |
813 | |
814 | /** Are BSD file locking primitives not implemented by fs? */ |
815 | unsigned no_flock:1; |
816 | |
817 | /** Is fallocate not implemented by fs? */ |
818 | unsigned no_fallocate:1; |
819 | |
820 | /** Is rename with flags implemented by fs? */ |
821 | unsigned no_rename2:1; |
822 | |
823 | /** Use enhanced/automatic page cache invalidation. */ |
824 | unsigned auto_inval_data:1; |
825 | |
826 | /** Filesystem is fully responsible for page cache invalidation. */ |
827 | unsigned explicit_inval_data:1; |
828 | |
829 | /** Does the filesystem support readdirplus? */ |
830 | unsigned do_readdirplus:1; |
831 | |
832 | /** Does the filesystem want adaptive readdirplus? */ |
833 | unsigned readdirplus_auto:1; |
834 | |
835 | /** Does the filesystem support asynchronous direct-IO submission? */ |
836 | unsigned async_dio:1; |
837 | |
838 | /** Is lseek not implemented by fs? */ |
839 | unsigned no_lseek:1; |
840 | |
841 | /** Does the filesystem support posix acls? */ |
842 | unsigned posix_acl:1; |
843 | |
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 | |
850 | /** Does the filesystem support copy_file_range? */ |
851 | unsigned no_copy_file_range:1; |
852 | |
853 | /* Send DESTROY request */ |
854 | unsigned int destroy:1; |
855 | |
856 | /* Delete dentries that have gone stale */ |
857 | unsigned int delete_stale:1; |
858 | |
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 | |
865 | /* Auto-mount submounts announced by the server */ |
866 | unsigned int auto_submounts:1; |
867 | |
868 | /* Propagate syncfs() to server */ |
869 | unsigned int sync_fs:1; |
870 | |
871 | /* Initialize security xattrs when creating a new inode */ |
872 | unsigned int init_security:1; |
873 | |
874 | /* Add supplementary group info when creating a new inode */ |
875 | unsigned int create_supp_group:1; |
876 | |
877 | /* Does the filesystem support per inode DAX? */ |
878 | unsigned int inode_dax:1; |
879 | |
880 | /* Is tmpfile not implemented by fs? */ |
881 | unsigned int no_tmpfile:1; |
882 | |
883 | /* Relax restrictions to allow shared mmap in FOPEN_DIRECT_IO mode */ |
884 | unsigned int direct_io_allow_mmap:1; |
885 | |
886 | /* Is statx not implemented by fs? */ |
887 | unsigned int no_statx:1; |
888 | |
889 | /** Passthrough support for read/write IO */ |
890 | unsigned int passthrough:1; |
891 | |
892 | /* Use pages instead of pointer for kernel I/O */ |
893 | unsigned int use_pages_for_kvec_io:1; |
894 | |
895 | /* Is link not implemented by fs? */ |
896 | unsigned int no_link:1; |
897 | |
898 | /* Use io_uring for communication */ |
899 | unsigned int io_uring; |
900 | |
901 | /** Maximum stack depth for passthrough backing files */ |
902 | int max_stack_depth; |
903 | |
904 | /** The number of requests waiting for completion */ |
905 | atomic_t num_waiting; |
906 | |
907 | /** Negotiated minor version */ |
908 | unsigned minor; |
909 | |
910 | /** Entry on the fuse_conn_list */ |
911 | struct list_head entry; |
912 | |
913 | /** Device ID from the root super block */ |
914 | dev_t dev; |
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; |
921 | |
922 | /** Key for lock owner ID scrambling */ |
923 | u32 scramble_key[4]; |
924 | |
925 | /** Version counter for attribute changes */ |
926 | atomic64_t attr_version; |
927 | |
928 | /** Version counter for evict inode */ |
929 | atomic64_t evict_ctr; |
930 | |
931 | /* maximum file name length */ |
932 | u32 name_max; |
933 | |
934 | /** Called on final put */ |
935 | void (*release)(struct fuse_conn *); |
936 | |
937 | /** |
938 | * Read/write semaphore to hold when accessing the sb of any |
939 | * fuse_mount belonging to this connection |
940 | */ |
941 | struct rw_semaphore killsb; |
942 | |
943 | /** List of device instances belonging to this connection */ |
944 | struct list_head devices; |
945 | |
946 | #ifdef CONFIG_FUSE_DAX |
947 | /* Dax mode */ |
948 | enum fuse_dax_mode dax_mode; |
949 | |
950 | /* Dax specific conn data, non-NULL if DAX is enabled */ |
951 | struct fuse_conn_dax *dax; |
952 | #endif |
953 | |
954 | /** List of filesystems using this connection */ |
955 | struct list_head mounts; |
956 | |
957 | /* New writepages go into this bucket */ |
958 | struct fuse_sync_bucket __rcu *curr_bucket; |
959 | |
960 | #ifdef CONFIG_FUSE_PASSTHROUGH |
961 | /** IDR for backing files ids */ |
962 | struct idr backing_files_map; |
963 | #endif |
964 | |
965 | #ifdef CONFIG_FUSE_IO_URING |
966 | /** uring connection information*/ |
967 | struct fuse_ring *ring; |
968 | #endif |
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; |
978 | }; |
979 | |
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 | |
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; |
999 | struct rcu_head rcu; |
1000 | }; |
1001 | |
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 | |
1015 | static inline struct fuse_mount *get_fuse_mount_super(struct super_block *sb) |
1016 | { |
1017 | return sb->s_fs_info; |
1018 | } |
1019 | |
1020 | static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb) |
1021 | { |
1022 | return get_fuse_mount_super(sb)->fc; |
1023 | } |
1024 | |
1025 | static inline struct fuse_mount *get_fuse_mount(struct inode *inode) |
1026 | { |
1027 | return get_fuse_mount_super(sb: inode->i_sb); |
1028 | } |
1029 | |
1030 | static inline struct fuse_conn *get_fuse_conn(struct inode *inode) |
1031 | { |
1032 | return get_fuse_mount_super(sb: inode->i_sb)->fc; |
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 | |
1045 | static inline int invalid_nodeid(u64 nodeid) |
1046 | { |
1047 | return !nodeid || nodeid == FUSE_ROOT_ID; |
1048 | } |
1049 | |
1050 | static inline u64 fuse_get_attr_version(struct fuse_conn *fc) |
1051 | { |
1052 | return atomic64_read(v: &fc->attr_version); |
1053 | } |
1054 | |
1055 | static inline u64 fuse_get_evict_ctr(struct fuse_conn *fc) |
1056 | { |
1057 | return atomic64_read(v: &fc->evict_ctr); |
1058 | } |
1059 | |
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, mode: attr->mode); |
1065 | } |
1066 | |
1067 | static inline void fuse_make_bad(struct inode *inode) |
1068 | { |
1069 | set_bit(nr: FUSE_I_BAD, addr: &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 | |
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 | |
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 | |
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(v: &bucket->count)) |
1104 | wake_up(&bucket->waitq); |
1105 | rcu_read_unlock(); |
1106 | } |
1107 | |
1108 | /** Device operations */ |
1109 | extern const struct file_operations fuse_dev_operations; |
1110 | |
1111 | extern const struct dentry_operations fuse_dentry_operations; |
1112 | extern const struct dentry_operations fuse_root_dentry_operations; |
1113 | |
1114 | /** |
1115 | * Get a filled in inode |
1116 | */ |
1117 | struct inode *fuse_iget(struct super_block *sb, u64 nodeid, |
1118 | int generation, struct fuse_attr *attr, |
1119 | u64 attr_valid, u64 attr_version, |
1120 | u64 evict_ctr); |
1121 | |
1122 | int fuse_lookup_name(struct super_block *sb, u64 nodeid, const struct qstr *name, |
1123 | struct fuse_entry_out *outarg, struct inode **inode); |
1124 | |
1125 | /** |
1126 | * Send FORGET command |
1127 | */ |
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); |
1132 | |
1133 | /* |
1134 | * Initialize READ or READDIR request |
1135 | */ |
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; |
1145 | bool folio_locked; |
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 | |
1156 | |
1157 | struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release); |
1158 | void fuse_file_free(struct fuse_file *ff); |
1159 | int fuse_finish_open(struct inode *inode, struct file *file); |
1160 | |
1161 | void fuse_sync_release(struct fuse_inode *fi, struct fuse_file *ff, |
1162 | unsigned int flags); |
1163 | |
1164 | /** |
1165 | * Send RELEASE or RELEASEDIR request |
1166 | */ |
1167 | void fuse_release_common(struct file *file, bool isdir); |
1168 | |
1169 | /** |
1170 | * Send FSYNC or FSYNCDIR request |
1171 | */ |
1172 | int fuse_fsync_common(struct file *file, loff_t start, loff_t end, |
1173 | int datasync, int opcode); |
1174 | |
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 | |
1181 | /** |
1182 | * Initialize file operations on a regular file |
1183 | */ |
1184 | void fuse_init_file_inode(struct inode *inode, unsigned int flags); |
1185 | |
1186 | /** |
1187 | * Initialize inode operations on regular files and special files |
1188 | */ |
1189 | void fuse_init_common(struct inode *inode); |
1190 | |
1191 | /** |
1192 | * Initialize inode and file operations on a directory |
1193 | */ |
1194 | void fuse_init_dir(struct inode *inode); |
1195 | |
1196 | /** |
1197 | * Initialize inode operations on a symlink |
1198 | */ |
1199 | void fuse_init_symlink(struct inode *inode); |
1200 | |
1201 | /** |
1202 | * Change attributes of an inode |
1203 | */ |
1204 | void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr, |
1205 | struct fuse_statx *sx, |
1206 | u64 attr_valid, u64 attr_version); |
1207 | |
1208 | void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr, |
1209 | struct fuse_statx *sx, |
1210 | u64 attr_valid, u32 cache_mask, |
1211 | u64 evict_ctr); |
1212 | |
1213 | u32 fuse_get_cache_mask(struct inode *inode); |
1214 | |
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 | |
1225 | int fuse_ctl_init(void); |
1226 | void __exit fuse_ctl_cleanup(void); |
1227 | |
1228 | /** |
1229 | * Simple request sending that does request allocation and freeing |
1230 | */ |
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 | { |
1237 | return __fuse_simple_request(idmap: &invalid_mnt_idmap, fm, args); |
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 | |
1247 | int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args, |
1248 | gfp_t gfp_flags); |
1249 | |
1250 | /** |
1251 | * End a finished request |
1252 | */ |
1253 | void fuse_request_end(struct fuse_req *req); |
1254 | |
1255 | /* Abort all requests */ |
1256 | void fuse_abort_conn(struct fuse_conn *fc); |
1257 | void fuse_wait_aborted(struct fuse_conn *fc); |
1258 | |
1259 | /* Check if any requests timed out */ |
1260 | void fuse_check_timeout(struct work_struct *work); |
1261 | |
1262 | /** |
1263 | * Invalidate inode attributes |
1264 | */ |
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 | |
1272 | void fuse_invalidate_attr(struct inode *inode); |
1273 | void fuse_invalidate_attr_mask(struct inode *inode, u32 mask); |
1274 | |
1275 | void fuse_invalidate_entry_cache(struct dentry *entry); |
1276 | |
1277 | void fuse_invalidate_atime(struct inode *inode); |
1278 | |
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 | |
1283 | void fuse_change_entry_timeout(struct dentry *entry, struct fuse_entry_out *o); |
1284 | |
1285 | /** |
1286 | * Acquire reference to fuse_conn |
1287 | */ |
1288 | struct fuse_conn *fuse_conn_get(struct fuse_conn *fc); |
1289 | |
1290 | /** |
1291 | * Initialize the fuse processing queue |
1292 | */ |
1293 | void fuse_pqueue_init(struct fuse_pqueue *fpq); |
1294 | |
1295 | /** |
1296 | * Initialize fuse_conn |
1297 | */ |
1298 | void fuse_conn_init(struct fuse_conn *fc, struct fuse_mount *fm, |
1299 | struct user_namespace *user_ns, |
1300 | const struct fuse_iqueue_ops *fiq_ops, void *fiq_priv); |
1301 | |
1302 | /** |
1303 | * Release reference to fuse_conn |
1304 | */ |
1305 | void fuse_conn_put(struct fuse_conn *fc); |
1306 | |
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); |
1310 | void fuse_dev_free(struct fuse_dev *fud); |
1311 | void fuse_send_init(struct fuse_mount *fm); |
1312 | |
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 | |
1320 | /* |
1321 | * Remove the mount from the connection |
1322 | * |
1323 | * Returns whether this was the last mount |
1324 | */ |
1325 | bool fuse_mount_remove(struct fuse_mount *fm); |
1326 | |
1327 | /* |
1328 | * Setup context ops for submounts |
1329 | */ |
1330 | int fuse_init_fs_context_submount(struct fs_context *fsc); |
1331 | |
1332 | /* |
1333 | * Shut down the connection (possibly sending DESTROY request). |
1334 | */ |
1335 | void fuse_conn_destroy(struct fuse_mount *fm); |
1336 | |
1337 | /* Drop the connection and free the fuse mount */ |
1338 | void fuse_mount_destroy(struct fuse_mount *fm); |
1339 | |
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); |
1349 | |
1350 | /** |
1351 | * Is file type valid? |
1352 | */ |
1353 | int fuse_valid_type(int m); |
1354 | |
1355 | bool fuse_invalid_attr(struct fuse_attr *attr); |
1356 | |
1357 | /** |
1358 | * Is current process allowed to perform filesystem operation? |
1359 | */ |
1360 | bool fuse_allow_current_process(struct fuse_conn *fc); |
1361 | |
1362 | u64 fuse_lock_owner_id(struct fuse_conn *fc, fl_owner_t id); |
1363 | |
1364 | void fuse_flush_time_update(struct inode *inode); |
1365 | void fuse_update_ctime(struct inode *inode); |
1366 | |
1367 | int fuse_update_attributes(struct inode *inode, struct file *file, u32 mask); |
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); |
1373 | |
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 | |
1384 | /** |
1385 | * File-system tells the kernel to invalidate cache for the given node id. |
1386 | */ |
1387 | int fuse_reverse_inval_inode(struct fuse_conn *fc, u64 nodeid, |
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. |
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()). |
1399 | */ |
1400 | int fuse_reverse_inval_entry(struct fuse_conn *fc, u64 parent_nodeid, |
1401 | u64 child_nodeid, struct qstr *name, u32 flags); |
1402 | |
1403 | int fuse_do_open(struct fuse_mount *fm, u64 nodeid, struct file *file, |
1404 | bool isdir); |
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 | |
1416 | ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter, |
1417 | loff_t *ppos, int flags); |
1418 | long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg, |
1419 | unsigned int flags); |
1420 | long fuse_ioctl_common(struct file *file, unsigned int cmd, |
1421 | unsigned long arg, unsigned int flags); |
1422 | __poll_t fuse_file_poll(struct file *file, poll_table *wait); |
1423 | int fuse_dev_release(struct inode *inode, struct file *file); |
1424 | |
1425 | bool fuse_write_update_attr(struct inode *inode, loff_t pos, ssize_t written); |
1426 | |
1427 | int fuse_flush_times(struct inode *inode, struct fuse_file *ff); |
1428 | int fuse_write_inode(struct inode *inode, struct writeback_control *wbc); |
1429 | |
1430 | int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry, |
1431 | struct iattr *attr, struct file *file); |
1432 | |
1433 | void fuse_set_initialized(struct fuse_conn *fc); |
1434 | |
1435 | void fuse_unlock_inode(struct inode *inode, bool locked); |
1436 | bool fuse_lock_inode(struct inode *inode); |
1437 | |
1438 | int fuse_setxattr(struct inode *inode, const char *name, const void *value, |
1439 | size_t size, int flags, unsigned int extra_flags); |
1440 | ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value, |
1441 | size_t size); |
1442 | ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size); |
1443 | int fuse_removexattr(struct inode *inode, const char *name); |
1444 | extern const struct xattr_handler * const fuse_xattr_handlers[]; |
1445 | |
1446 | struct posix_acl; |
1447 | struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu); |
1448 | struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap, |
1449 | struct dentry *dentry, int type); |
1450 | int fuse_set_acl(struct mnt_idmap *, struct dentry *dentry, |
1451 | struct posix_acl *acl, int type); |
1452 | |
1453 | /* readdir.c */ |
1454 | int fuse_readdir(struct file *file, struct dir_context *ctx); |
1455 | |
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 | |
1461 | /** |
1462 | * Get the next unique ID for a request |
1463 | */ |
1464 | u64 fuse_get_unique(struct fuse_iqueue *fiq); |
1465 | void fuse_free_conn(struct fuse_conn *fc); |
1466 | |
1467 | /* dax.c */ |
1468 | |
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); |
1474 | int fuse_dax_break_layouts(struct inode *inode, u64 dmap_start, u64 dmap_end); |
1475 | int fuse_dax_conn_alloc(struct fuse_conn *fc, enum fuse_dax_mode mode, |
1476 | struct dax_device *dax_dev); |
1477 | void fuse_dax_conn_free(struct fuse_conn *fc); |
1478 | bool fuse_dax_inode_alloc(struct super_block *sb, struct fuse_inode *fi); |
1479 | void fuse_dax_inode_init(struct inode *inode, unsigned int flags); |
1480 | void fuse_dax_inode_cleanup(struct inode *inode); |
1481 | void fuse_dax_dontcache(struct inode *inode, unsigned int flags); |
1482 | bool fuse_dax_check_alignment(struct fuse_conn *fc, unsigned int map_alignment); |
1483 | void fuse_dax_cancel_work(struct fuse_conn *fc); |
1484 | |
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); |
1489 | int fuse_fileattr_get(struct dentry *dentry, struct fileattr *fa); |
1490 | int fuse_fileattr_set(struct mnt_idmap *idmap, |
1491 | struct dentry *dentry, struct fileattr *fa); |
1492 | |
1493 | /* iomode.c */ |
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); |
1498 | |
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); |
1501 | |
1502 | /* file.c */ |
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 | |
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 | |
1528 | #ifdef CONFIG_FUSE_PASSTHROUGH |
1529 | struct fuse_backing *fuse_backing_get(struct fuse_backing *fb); |
1530 | void fuse_backing_put(struct fuse_backing *fb); |
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 | |
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); |
1547 | |
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 | |
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); |
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); |
1570 | ssize_t fuse_passthrough_mmap(struct file *file, struct vm_area_struct *vma); |
1571 | |
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 | |
1580 | #endif /* _FS_FUSE_I_H */ |
1581 |
Definitions
- fuse_forget_link
- fuse_submount_lookup
- fuse_backing
- fuse_inode
- fuse_file
- fuse_in_arg
- fuse_arg
- fuse_folio_desc
- fuse_args
- fuse_args_pages
- fuse_release_args
- fuse_file_args
- fuse_io_priv
- fuse_req_flag
- fuse_req
- fuse_iqueue_ops
- fuse_iqueue
- fuse_pqueue
- fuse_dev
- fuse_dax_mode
- fuse_is_inode_dax_mode
- fuse_fs_context
- fuse_sync_bucket
- fuse_conn
- fuse_mount
- fuse_zero_header
- fuse_set_zero_arg0
- get_fuse_mount_super
- get_fuse_conn_super
- get_fuse_mount
- get_fuse_conn
- get_fuse_inode
- get_node_id
- invalid_nodeid
- fuse_get_attr_version
- fuse_get_evict_ctr
- fuse_stale_inode
- fuse_make_bad
- fuse_is_bad
- fuse_folios_alloc
- fuse_folio_descs_length_init
- fuse_sync_bucket_dec
- fuse_io_args
- fuse_simple_request
- fuse_simple_idmap_request
- fuse_inode_backing
- fuse_inode_backing_set
Improve your Profiling and Debugging skills
Find out more