.. | .. |
---|
24 | 24 | #include <linux/capability.h> |
---|
25 | 25 | #include <linux/semaphore.h> |
---|
26 | 26 | #include <linux/fcntl.h> |
---|
27 | | -#include <linux/fiemap.h> |
---|
28 | 27 | #include <linux/rculist_bl.h> |
---|
29 | 28 | #include <linux/atomic.h> |
---|
30 | 29 | #include <linux/shrinker.h> |
---|
.. | .. |
---|
37 | 36 | #include <linux/uuid.h> |
---|
38 | 37 | #include <linux/errseq.h> |
---|
39 | 38 | #include <linux/ioprio.h> |
---|
| 39 | +#include <linux/fs_types.h> |
---|
| 40 | +#include <linux/build_bug.h> |
---|
| 41 | +#include <linux/stddef.h> |
---|
40 | 42 | #include <linux/android_kabi.h> |
---|
41 | 43 | |
---|
42 | 44 | #include <asm/byteorder.h> |
---|
43 | 45 | #include <uapi/linux/fs.h> |
---|
| 46 | +#include <linux/android_vendor.h> |
---|
44 | 47 | |
---|
45 | 48 | struct backing_dev_info; |
---|
46 | 49 | struct bdi_writeback; |
---|
47 | 50 | struct bio; |
---|
48 | 51 | struct export_operations; |
---|
| 52 | +struct fiemap_extent_info; |
---|
49 | 53 | struct hd_geometry; |
---|
50 | 54 | struct iovec; |
---|
51 | 55 | struct kiocb; |
---|
.. | .. |
---|
64 | 68 | struct fscrypt_operations; |
---|
65 | 69 | struct fsverity_info; |
---|
66 | 70 | struct fsverity_operations; |
---|
| 71 | +struct fs_context; |
---|
| 72 | +struct fs_parameter_spec; |
---|
67 | 73 | |
---|
68 | 74 | extern void __init inode_init(void); |
---|
69 | 75 | extern void __init inode_init_early(void); |
---|
.. | .. |
---|
163 | 169 | #define FMODE_NONOTIFY ((__force fmode_t)0x4000000) |
---|
164 | 170 | |
---|
165 | 171 | /* File is capable of returning -EAGAIN if I/O will block */ |
---|
166 | | -#define FMODE_NOWAIT ((__force fmode_t)0x8000000) |
---|
| 172 | +#define FMODE_NOWAIT ((__force fmode_t)0x8000000) |
---|
| 173 | + |
---|
| 174 | +/* File represents mount that needs unmounting */ |
---|
| 175 | +#define FMODE_NEED_UNMOUNT ((__force fmode_t)0x10000000) |
---|
167 | 176 | |
---|
168 | 177 | /* File does not contribute to nr_files count */ |
---|
169 | | -#define FMODE_NOACCOUNT ((__force fmode_t)0x20000000) |
---|
| 178 | +#define FMODE_NOACCOUNT ((__force fmode_t)0x20000000) |
---|
170 | 179 | |
---|
171 | | -/* |
---|
172 | | - * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector |
---|
173 | | - * that indicates that they should check the contents of the iovec are |
---|
174 | | - * valid, but not check the memory that the iovec elements |
---|
175 | | - * points too. |
---|
176 | | - */ |
---|
177 | | -#define CHECK_IOVEC_ONLY -1 |
---|
| 180 | +/* File supports async buffered reads */ |
---|
| 181 | +#define FMODE_BUF_RASYNC ((__force fmode_t)0x40000000) |
---|
178 | 182 | |
---|
179 | 183 | /* |
---|
180 | 184 | * Attribute flags. These should be or-ed together to figure out what |
---|
.. | .. |
---|
285 | 289 | struct page; |
---|
286 | 290 | struct address_space; |
---|
287 | 291 | struct writeback_control; |
---|
| 292 | +struct readahead_control; |
---|
288 | 293 | |
---|
289 | 294 | /* |
---|
290 | 295 | * Write life time hint values. |
---|
.. | .. |
---|
299 | 304 | WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME, |
---|
300 | 305 | }; |
---|
301 | 306 | |
---|
302 | | -#define IOCB_EVENTFD (1 << 0) |
---|
303 | | -#define IOCB_APPEND (1 << 1) |
---|
304 | | -#define IOCB_DIRECT (1 << 2) |
---|
305 | | -#define IOCB_HIPRI (1 << 3) |
---|
306 | | -#define IOCB_DSYNC (1 << 4) |
---|
307 | | -#define IOCB_SYNC (1 << 5) |
---|
308 | | -#define IOCB_WRITE (1 << 6) |
---|
309 | | -#define IOCB_NOWAIT (1 << 7) |
---|
| 307 | +/* Match RWF_* bits to IOCB bits */ |
---|
| 308 | +#define IOCB_HIPRI (__force int) RWF_HIPRI |
---|
| 309 | +#define IOCB_DSYNC (__force int) RWF_DSYNC |
---|
| 310 | +#define IOCB_SYNC (__force int) RWF_SYNC |
---|
| 311 | +#define IOCB_NOWAIT (__force int) RWF_NOWAIT |
---|
| 312 | +#define IOCB_APPEND (__force int) RWF_APPEND |
---|
| 313 | + |
---|
| 314 | +/* non-RWF related bits - start at 16 */ |
---|
| 315 | +#define IOCB_EVENTFD (1 << 16) |
---|
| 316 | +#define IOCB_DIRECT (1 << 17) |
---|
| 317 | +#define IOCB_WRITE (1 << 18) |
---|
| 318 | +/* iocb->ki_waitq is valid */ |
---|
| 319 | +#define IOCB_WAITQ (1 << 19) |
---|
| 320 | +#define IOCB_NOIO (1 << 20) |
---|
310 | 321 | |
---|
311 | 322 | struct kiocb { |
---|
312 | 323 | struct file *ki_filp; |
---|
.. | .. |
---|
320 | 331 | int ki_flags; |
---|
321 | 332 | u16 ki_hint; |
---|
322 | 333 | u16 ki_ioprio; /* See linux/ioprio.h */ |
---|
| 334 | + union { |
---|
| 335 | + unsigned int ki_cookie; /* for ->iopoll */ |
---|
| 336 | + struct wait_page_queue *ki_waitq; /* for async buffered IO */ |
---|
| 337 | + }; |
---|
323 | 338 | |
---|
324 | 339 | randomized_struct_fields_end |
---|
325 | 340 | }; |
---|
.. | .. |
---|
367 | 382 | */ |
---|
368 | 383 | int (*readpages)(struct file *filp, struct address_space *mapping, |
---|
369 | 384 | struct list_head *pages, unsigned nr_pages); |
---|
| 385 | + void (*readahead)(struct readahead_control *); |
---|
370 | 386 | |
---|
371 | 387 | int (*write_begin)(struct file *, struct address_space *mapping, |
---|
372 | 388 | loff_t pos, unsigned len, unsigned flags, |
---|
.. | .. |
---|
420 | 436 | loff_t pos, unsigned len, unsigned copied, |
---|
421 | 437 | struct page *page, void *fsdata); |
---|
422 | 438 | |
---|
| 439 | +/** |
---|
| 440 | + * struct address_space - Contents of a cacheable, mappable object. |
---|
| 441 | + * @host: Owner, either the inode or the block_device. |
---|
| 442 | + * @i_pages: Cached pages. |
---|
| 443 | + * @gfp_mask: Memory allocation flags to use for allocating pages. |
---|
| 444 | + * @i_mmap_writable: Number of VM_SHARED mappings. |
---|
| 445 | + * @nr_thps: Number of THPs in the pagecache (non-shmem only). |
---|
| 446 | + * @i_mmap: Tree of private and shared mappings. |
---|
| 447 | + * @i_mmap_rwsem: Protects @i_mmap and @i_mmap_writable. |
---|
| 448 | + * @nrpages: Number of page entries, protected by the i_pages lock. |
---|
| 449 | + * @nrexceptional: Shadow or DAX entries, protected by the i_pages lock. |
---|
| 450 | + * @writeback_index: Writeback starts here. |
---|
| 451 | + * @a_ops: Methods. |
---|
| 452 | + * @flags: Error bits and flags (AS_*). |
---|
| 453 | + * @wb_err: The most recent error which has occurred. |
---|
| 454 | + * @private_lock: For use by the owner of the address_space. |
---|
| 455 | + * @private_list: For use by the owner of the address_space. |
---|
| 456 | + * @private_data: For use by the owner of the address_space. |
---|
| 457 | + */ |
---|
423 | 458 | struct address_space { |
---|
424 | | - struct inode *host; /* owner: inode, block_device */ |
---|
425 | | - struct radix_tree_root i_pages; /* cached pages */ |
---|
426 | | - atomic_t i_mmap_writable;/* count VM_SHARED mappings */ |
---|
427 | | - struct rb_root_cached i_mmap; /* tree of private and shared mappings */ |
---|
428 | | - struct rw_semaphore i_mmap_rwsem; /* protect tree, count, list */ |
---|
429 | | - /* Protected by the i_pages lock */ |
---|
430 | | - unsigned long nrpages; /* number of total pages */ |
---|
431 | | - /* number of shadow or DAX exceptional entries */ |
---|
| 459 | + struct inode *host; |
---|
| 460 | + struct xarray i_pages; |
---|
| 461 | + gfp_t gfp_mask; |
---|
| 462 | + atomic_t i_mmap_writable; |
---|
| 463 | +#ifdef CONFIG_READ_ONLY_THP_FOR_FS |
---|
| 464 | + /* number of thp, only for non-shmem files */ |
---|
| 465 | + atomic_t nr_thps; |
---|
| 466 | +#endif |
---|
| 467 | + struct rb_root_cached i_mmap; |
---|
| 468 | + struct rw_semaphore i_mmap_rwsem; |
---|
| 469 | + unsigned long nrpages; |
---|
432 | 470 | unsigned long nrexceptional; |
---|
433 | | - pgoff_t writeback_index;/* writeback starts here */ |
---|
434 | | - const struct address_space_operations *a_ops; /* methods */ |
---|
435 | | - unsigned long flags; /* error bits */ |
---|
436 | | - spinlock_t private_lock; /* for use by the address_space */ |
---|
437 | | - gfp_t gfp_mask; /* implicit gfp mask for allocations */ |
---|
438 | | - struct list_head private_list; /* for use by the address_space */ |
---|
439 | | - void *private_data; /* ditto */ |
---|
| 471 | + pgoff_t writeback_index; |
---|
| 472 | + const struct address_space_operations *a_ops; |
---|
| 473 | + unsigned long flags; |
---|
440 | 474 | errseq_t wb_err; |
---|
| 475 | + spinlock_t private_lock; |
---|
| 476 | + struct list_head private_list; |
---|
| 477 | + void *private_data; |
---|
441 | 478 | |
---|
442 | 479 | ANDROID_KABI_RESERVE(1); |
---|
443 | 480 | ANDROID_KABI_RESERVE(2); |
---|
.. | .. |
---|
449 | 486 | * must be enforced here for CRIS, to let the least significant bit |
---|
450 | 487 | * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON. |
---|
451 | 488 | */ |
---|
452 | | -struct request_queue; |
---|
453 | 489 | |
---|
454 | | -struct block_device { |
---|
455 | | - dev_t bd_dev; /* not a kdev_t - it's a search key */ |
---|
456 | | - int bd_openers; |
---|
457 | | - struct inode * bd_inode; /* will die */ |
---|
458 | | - struct super_block * bd_super; |
---|
459 | | - struct mutex bd_mutex; /* open/close mutex */ |
---|
460 | | - void * bd_claiming; |
---|
461 | | - void * bd_holder; |
---|
462 | | - int bd_holders; |
---|
463 | | - bool bd_write_holder; |
---|
464 | | -#ifdef CONFIG_SYSFS |
---|
465 | | - struct list_head bd_holder_disks; |
---|
466 | | -#endif |
---|
467 | | - struct block_device * bd_contains; |
---|
468 | | - unsigned bd_block_size; |
---|
469 | | - u8 bd_partno; |
---|
470 | | - struct hd_struct * bd_part; |
---|
471 | | - /* number of times partitions within this device have been opened. */ |
---|
472 | | - unsigned bd_part_count; |
---|
473 | | - int bd_invalidated; |
---|
474 | | - struct gendisk * bd_disk; |
---|
475 | | - struct request_queue * bd_queue; |
---|
476 | | - struct backing_dev_info *bd_bdi; |
---|
477 | | - struct list_head bd_list; |
---|
478 | | - /* |
---|
479 | | - * Private data. You must have bd_claim'ed the block_device |
---|
480 | | - * to use this. NOTE: bd_claim allows an owner to claim |
---|
481 | | - * the same device multiple times, the owner must take special |
---|
482 | | - * care to not mess up bd_private for that case. |
---|
483 | | - */ |
---|
484 | | - unsigned long bd_private; |
---|
485 | | - |
---|
486 | | - /* The counter of freeze processes */ |
---|
487 | | - int bd_fsfreeze_count; |
---|
488 | | - /* Mutex for freeze */ |
---|
489 | | - struct mutex bd_fsfreeze_mutex; |
---|
490 | | - |
---|
491 | | - ANDROID_KABI_RESERVE(1); |
---|
492 | | - ANDROID_KABI_RESERVE(2); |
---|
493 | | - ANDROID_KABI_RESERVE(3); |
---|
494 | | - ANDROID_KABI_RESERVE(4); |
---|
495 | | -} __randomize_layout; |
---|
| 490 | +/* XArray tags, for tagging dirty and writeback pages in the pagecache. */ |
---|
| 491 | +#define PAGECACHE_TAG_DIRTY XA_MARK_0 |
---|
| 492 | +#define PAGECACHE_TAG_WRITEBACK XA_MARK_1 |
---|
| 493 | +#define PAGECACHE_TAG_TOWRITE XA_MARK_2 |
---|
496 | 494 | |
---|
497 | 495 | /* |
---|
498 | | - * Radix-tree tags, for tagging dirty and writeback pages within the pagecache |
---|
499 | | - * radix trees |
---|
| 496 | + * Returns true if any of the pages in the mapping are marked with the tag. |
---|
500 | 497 | */ |
---|
501 | | -#define PAGECACHE_TAG_DIRTY 0 |
---|
502 | | -#define PAGECACHE_TAG_WRITEBACK 1 |
---|
503 | | -#define PAGECACHE_TAG_TOWRITE 2 |
---|
504 | | - |
---|
505 | | -int mapping_tagged(struct address_space *mapping, int tag); |
---|
| 498 | +static inline bool mapping_tagged(struct address_space *mapping, xa_mark_t tag) |
---|
| 499 | +{ |
---|
| 500 | + return xa_marked(&mapping->i_pages, tag); |
---|
| 501 | +} |
---|
506 | 502 | |
---|
507 | 503 | static inline void i_mmap_lock_write(struct address_space *mapping) |
---|
508 | 504 | { |
---|
509 | 505 | down_write(&mapping->i_mmap_rwsem); |
---|
510 | 506 | } |
---|
511 | 507 | |
---|
| 508 | +static inline int i_mmap_trylock_write(struct address_space *mapping) |
---|
| 509 | +{ |
---|
| 510 | + return down_write_trylock(&mapping->i_mmap_rwsem); |
---|
| 511 | +} |
---|
| 512 | + |
---|
512 | 513 | static inline void i_mmap_unlock_write(struct address_space *mapping) |
---|
513 | 514 | { |
---|
514 | 515 | up_write(&mapping->i_mmap_rwsem); |
---|
| 516 | +} |
---|
| 517 | + |
---|
| 518 | +static inline int i_mmap_trylock_read(struct address_space *mapping) |
---|
| 519 | +{ |
---|
| 520 | + return down_read_trylock(&mapping->i_mmap_rwsem); |
---|
515 | 521 | } |
---|
516 | 522 | |
---|
517 | 523 | static inline void i_mmap_lock_read(struct address_space *mapping) |
---|
.. | .. |
---|
524 | 530 | up_read(&mapping->i_mmap_rwsem); |
---|
525 | 531 | } |
---|
526 | 532 | |
---|
| 533 | +static inline void i_mmap_assert_locked(struct address_space *mapping) |
---|
| 534 | +{ |
---|
| 535 | + lockdep_assert_held(&mapping->i_mmap_rwsem); |
---|
| 536 | +} |
---|
| 537 | + |
---|
| 538 | +static inline void i_mmap_assert_write_locked(struct address_space *mapping) |
---|
| 539 | +{ |
---|
| 540 | + lockdep_assert_held_write(&mapping->i_mmap_rwsem); |
---|
| 541 | +} |
---|
| 542 | + |
---|
527 | 543 | /* |
---|
528 | 544 | * Might pages of this file be mapped into userspace? |
---|
529 | 545 | */ |
---|
.. | .. |
---|
534 | 550 | |
---|
535 | 551 | /* |
---|
536 | 552 | * Might pages of this file have been modified in userspace? |
---|
537 | | - * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap_pgoff |
---|
| 553 | + * Note that i_mmap_writable counts all VM_SHARED vmas: do_mmap |
---|
538 | 554 | * marks vma as VM_SHARED if it is shared, and the file was opened for |
---|
539 | 555 | * writing i.e. vma may be mprotected writable even if now readonly. |
---|
540 | 556 | * |
---|
.. | .. |
---|
685 | 701 | atomic_t i_count; |
---|
686 | 702 | atomic_t i_dio_count; |
---|
687 | 703 | atomic_t i_writecount; |
---|
688 | | -#ifdef CONFIG_IMA |
---|
| 704 | +#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING) |
---|
689 | 705 | atomic_t i_readcount; /* struct files open RO */ |
---|
690 | 706 | #endif |
---|
691 | | - const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ |
---|
| 707 | + union { |
---|
| 708 | + const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ |
---|
| 709 | + void (*free_inode)(struct inode *); |
---|
| 710 | + }; |
---|
692 | 711 | struct file_lock_context *i_flctx; |
---|
693 | 712 | struct address_space i_data; |
---|
694 | 713 | struct list_head i_devices; |
---|
.. | .. |
---|
720 | 739 | ANDROID_KABI_RESERVE(1); |
---|
721 | 740 | ANDROID_KABI_RESERVE(2); |
---|
722 | 741 | } __randomize_layout; |
---|
| 742 | + |
---|
| 743 | +struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode); |
---|
723 | 744 | |
---|
724 | 745 | static inline unsigned int i_blocksize(const struct inode *node) |
---|
725 | 746 | { |
---|
.. | .. |
---|
837 | 858 | i_size = inode->i_size; |
---|
838 | 859 | } while (read_seqcount_retry(&inode->i_size_seqcount, seq)); |
---|
839 | 860 | return i_size; |
---|
840 | | -#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT) |
---|
| 861 | +#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) |
---|
841 | 862 | loff_t i_size; |
---|
842 | 863 | |
---|
843 | 864 | preempt_disable(); |
---|
.. | .. |
---|
862 | 883 | inode->i_size = i_size; |
---|
863 | 884 | write_seqcount_end(&inode->i_size_seqcount); |
---|
864 | 885 | preempt_enable(); |
---|
865 | | -#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT) |
---|
| 886 | +#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION) |
---|
866 | 887 | preempt_disable(); |
---|
867 | 888 | inode->i_size = i_size; |
---|
868 | 889 | preempt_enable(); |
---|
.. | .. |
---|
880 | 901 | { |
---|
881 | 902 | return MAJOR(inode->i_rdev); |
---|
882 | 903 | } |
---|
883 | | - |
---|
884 | | -extern struct block_device *I_BDEV(struct inode *inode); |
---|
885 | 904 | |
---|
886 | 905 | struct fown_struct { |
---|
887 | 906 | rwlock_t lock; /* protects pid, uid, euid fields */ |
---|
.. | .. |
---|
952 | 971 | #endif /* #ifdef CONFIG_EPOLL */ |
---|
953 | 972 | struct address_space *f_mapping; |
---|
954 | 973 | errseq_t f_wb_err; |
---|
| 974 | + errseq_t f_sb_err; /* for syncfs */ |
---|
| 975 | + |
---|
| 976 | + ANDROID_KABI_RESERVE(1); |
---|
| 977 | + ANDROID_KABI_RESERVE(2); |
---|
| 978 | + ANDROID_OEM_DATA(1); |
---|
955 | 979 | } __randomize_layout |
---|
956 | 980 | __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ |
---|
957 | 981 | |
---|
.. | .. |
---|
970 | 994 | #define get_file_rcu_many(x, cnt) \ |
---|
971 | 995 | atomic_long_add_unless(&(x)->f_count, (cnt), 0) |
---|
972 | 996 | #define get_file_rcu(x) get_file_rcu_many((x), 1) |
---|
973 | | -#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) |
---|
974 | 997 | #define file_count(x) atomic_long_read(&(x)->f_count) |
---|
975 | 998 | |
---|
976 | 999 | #define MAX_NON_LFS ((1UL<<31) - 1) |
---|
.. | .. |
---|
1018 | 1041 | }; |
---|
1019 | 1042 | |
---|
1020 | 1043 | struct lock_manager_operations { |
---|
1021 | | - int (*lm_compare_owner)(struct file_lock *, struct file_lock *); |
---|
1022 | | - unsigned long (*lm_owner_key)(struct file_lock *); |
---|
1023 | 1044 | fl_owner_t (*lm_get_owner)(fl_owner_t); |
---|
1024 | 1045 | void (*lm_put_owner)(fl_owner_t); |
---|
1025 | 1046 | void (*lm_notify)(struct file_lock *); /* unblock callback */ |
---|
.. | .. |
---|
1027 | 1048 | bool (*lm_break)(struct file_lock *); |
---|
1028 | 1049 | int (*lm_change)(struct file_lock *, int, struct list_head *); |
---|
1029 | 1050 | void (*lm_setup)(struct file_lock *, void **); |
---|
| 1051 | + bool (*lm_breaker_owns_lease)(struct file_lock *); |
---|
1030 | 1052 | |
---|
1031 | 1053 | ANDROID_KABI_RESERVE(1); |
---|
1032 | 1054 | ANDROID_KABI_RESERVE(2); |
---|
.. | .. |
---|
1068 | 1090 | * Obviously, the last two criteria only matter for POSIX locks. |
---|
1069 | 1091 | */ |
---|
1070 | 1092 | struct file_lock { |
---|
1071 | | - struct file_lock *fl_next; /* singly linked list for this inode */ |
---|
| 1093 | + struct file_lock *fl_blocker; /* The lock, that is blocking us */ |
---|
1072 | 1094 | struct list_head fl_list; /* link into file_lock_context */ |
---|
1073 | 1095 | struct hlist_node fl_link; /* node in global lists */ |
---|
1074 | | - struct list_head fl_block; /* circular list of blocked processes */ |
---|
| 1096 | + struct list_head fl_blocked_requests; /* list of requests with |
---|
| 1097 | + * ->fl_blocker pointing here |
---|
| 1098 | + */ |
---|
| 1099 | + struct list_head fl_blocked_member; /* node in |
---|
| 1100 | + * ->fl_blocker->fl_blocked_requests |
---|
| 1101 | + */ |
---|
1075 | 1102 | fl_owner_t fl_owner; |
---|
1076 | 1103 | unsigned int fl_flags; |
---|
1077 | 1104 | unsigned char fl_type; |
---|
.. | .. |
---|
1095 | 1122 | struct { |
---|
1096 | 1123 | struct list_head link; /* link in AFS vnode's pending_locks list */ |
---|
1097 | 1124 | int state; /* state of grant or error if -ve */ |
---|
| 1125 | + unsigned int debug_id; |
---|
1098 | 1126 | } afs; |
---|
1099 | 1127 | } fl_u; |
---|
1100 | 1128 | |
---|
.. | .. |
---|
1147 | 1175 | extern void locks_release_private(struct file_lock *); |
---|
1148 | 1176 | extern void posix_test_lock(struct file *, struct file_lock *); |
---|
1149 | 1177 | extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *); |
---|
1150 | | -extern int posix_unblock_lock(struct file_lock *); |
---|
| 1178 | +extern int locks_delete_block(struct file_lock *); |
---|
1151 | 1179 | extern int vfs_test_lock(struct file *, struct file_lock *); |
---|
1152 | 1180 | extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *); |
---|
1153 | 1181 | extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl); |
---|
.. | .. |
---|
1157 | 1185 | extern int generic_setlease(struct file *, long, struct file_lock **, void **priv); |
---|
1158 | 1186 | extern int vfs_setlease(struct file *, long, struct file_lock **, void **); |
---|
1159 | 1187 | extern int lease_modify(struct file_lock *, int, struct list_head *); |
---|
| 1188 | + |
---|
| 1189 | +struct notifier_block; |
---|
| 1190 | +extern int lease_register_notifier(struct notifier_block *); |
---|
| 1191 | +extern void lease_unregister_notifier(struct notifier_block *); |
---|
| 1192 | + |
---|
1160 | 1193 | struct files_struct; |
---|
1161 | 1194 | extern void show_fd_locks(struct seq_file *f, |
---|
1162 | 1195 | struct file *filp, struct files_struct *files); |
---|
.. | .. |
---|
1237 | 1270 | return -ENOLCK; |
---|
1238 | 1271 | } |
---|
1239 | 1272 | |
---|
1240 | | -static inline int posix_unblock_lock(struct file_lock *waiter) |
---|
| 1273 | +static inline int locks_delete_block(struct file_lock *waiter) |
---|
1241 | 1274 | { |
---|
1242 | 1275 | return -ENOENT; |
---|
1243 | 1276 | } |
---|
.. | .. |
---|
1354 | 1387 | #define SB_NODIRATIME 2048 /* Do not update directory access times */ |
---|
1355 | 1388 | #define SB_SILENT 32768 |
---|
1356 | 1389 | #define SB_POSIXACL (1<<16) /* VFS does not apply the umask */ |
---|
| 1390 | +#define SB_INLINECRYPT (1<<17) /* Use blk-crypto for encrypted files */ |
---|
1357 | 1391 | #define SB_KERNMOUNT (1<<22) /* this is a kern_mount call */ |
---|
1358 | 1392 | #define SB_I_VERSION (1<<23) /* Update inode I_version field */ |
---|
1359 | 1393 | #define SB_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ |
---|
1360 | 1394 | |
---|
1361 | 1395 | /* These sb flags are internal to the kernel */ |
---|
1362 | 1396 | #define SB_SUBMOUNT (1<<26) |
---|
| 1397 | +#define SB_FORCE (1<<27) |
---|
1363 | 1398 | #define SB_NOSEC (1<<28) |
---|
1364 | 1399 | #define SB_BORN (1<<29) |
---|
1365 | 1400 | #define SB_ACTIVE (1<<30) |
---|
.. | .. |
---|
1368 | 1403 | /* These flags relate to encoding and casefolding */ |
---|
1369 | 1404 | #define SB_ENC_STRICT_MODE_FL (1 << 0) |
---|
1370 | 1405 | |
---|
1371 | | -#define sb_has_enc_strict_mode(sb) \ |
---|
| 1406 | +#define sb_has_strict_encoding(sb) \ |
---|
1372 | 1407 | (sb->s_encoding_flags & SB_ENC_STRICT_MODE_FL) |
---|
1373 | 1408 | |
---|
1374 | 1409 | /* |
---|
.. | .. |
---|
1385 | 1420 | #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ |
---|
1386 | 1421 | #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ |
---|
1387 | 1422 | #define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */ |
---|
1388 | | -#define SB_I_MULTIROOT 0x00000008 /* Multiple roots to the dentry tree */ |
---|
| 1423 | +#define SB_I_STABLE_WRITES 0x00000008 /* don't modify blks until WB is done */ |
---|
1389 | 1424 | |
---|
1390 | 1425 | /* sb->s_iflags to limit user namespace mounts */ |
---|
1391 | 1426 | #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ |
---|
1392 | 1427 | #define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020 |
---|
1393 | 1428 | #define SB_I_UNTRUSTED_MOUNTER 0x00000040 |
---|
| 1429 | + |
---|
| 1430 | +#define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */ |
---|
1394 | 1431 | |
---|
1395 | 1432 | /* Possible states of 'frozen' field */ |
---|
1396 | 1433 | enum { |
---|
.. | .. |
---|
1434 | 1471 | const struct xattr_handler **s_xattr; |
---|
1435 | 1472 | #ifdef CONFIG_FS_ENCRYPTION |
---|
1436 | 1473 | const struct fscrypt_operations *s_cop; |
---|
| 1474 | +#ifdef __GENKSYMS__ |
---|
| 1475 | + /* |
---|
| 1476 | + * Android ABI CRC preservation due to commit 391cceee6d43 ("fscrypt: |
---|
| 1477 | + * stop using keyrings subsystem for fscrypt_master_key") changing this |
---|
| 1478 | + * type. Size is the same, this is a private field. |
---|
| 1479 | + */ |
---|
1437 | 1480 | struct key *s_master_keys; /* master crypto keys in use */ |
---|
| 1481 | +#else |
---|
| 1482 | + struct fscrypt_keyring *s_master_keys; /* master crypto keys in use */ |
---|
| 1483 | +#endif |
---|
1438 | 1484 | #endif |
---|
1439 | 1485 | #ifdef CONFIG_FS_VERITY |
---|
1440 | 1486 | const struct fsverity_operations *s_vop; |
---|
.. | .. |
---|
1454 | 1500 | |
---|
1455 | 1501 | struct sb_writers s_writers; |
---|
1456 | 1502 | |
---|
| 1503 | + /* |
---|
| 1504 | + * Keep s_fs_info, s_time_gran, s_fsnotify_mask, and |
---|
| 1505 | + * s_fsnotify_marks together for cache efficiency. They are frequently |
---|
| 1506 | + * accessed and rarely modified. |
---|
| 1507 | + */ |
---|
| 1508 | + void *s_fs_info; /* Filesystem private info */ |
---|
| 1509 | + |
---|
| 1510 | + /* Granularity of c/m/atime in ns (cannot be worse than a second) */ |
---|
| 1511 | + u32 s_time_gran; |
---|
| 1512 | + /* Time limits for c/m/atime in seconds */ |
---|
| 1513 | + time64_t s_time_min; |
---|
| 1514 | + time64_t s_time_max; |
---|
| 1515 | +#ifdef CONFIG_FSNOTIFY |
---|
| 1516 | + __u32 s_fsnotify_mask; |
---|
| 1517 | + struct fsnotify_mark_connector __rcu *s_fsnotify_marks; |
---|
| 1518 | +#endif |
---|
| 1519 | + |
---|
1457 | 1520 | char s_id[32]; /* Informational name */ |
---|
1458 | 1521 | uuid_t s_uuid; /* UUID */ |
---|
1459 | 1522 | |
---|
1460 | | - void *s_fs_info; /* Filesystem private info */ |
---|
1461 | 1523 | unsigned int s_max_links; |
---|
1462 | 1524 | fmode_t s_mode; |
---|
1463 | | - |
---|
1464 | | - /* Granularity of c/m/atime in ns. |
---|
1465 | | - Cannot be worse than a second */ |
---|
1466 | | - u32 s_time_gran; |
---|
1467 | 1525 | |
---|
1468 | 1526 | /* |
---|
1469 | 1527 | * The next field is for VFS *only*. No filesystems have any business |
---|
.. | .. |
---|
1475 | 1533 | * Filesystem subtype. If non-empty the filesystem type field |
---|
1476 | 1534 | * in /proc/mounts will be "type.subtype" |
---|
1477 | 1535 | */ |
---|
1478 | | - char *s_subtype; |
---|
| 1536 | + const char *s_subtype; |
---|
1479 | 1537 | |
---|
1480 | 1538 | const struct dentry_operations *s_d_op; /* default d_op for dentries */ |
---|
1481 | 1539 | |
---|
.. | .. |
---|
1495 | 1553 | /* Being remounted read-only */ |
---|
1496 | 1554 | int s_readonly_remount; |
---|
1497 | 1555 | |
---|
| 1556 | + /* per-sb errseq_t for reporting writeback errors via syncfs */ |
---|
| 1557 | + errseq_t s_wb_err; |
---|
| 1558 | + |
---|
1498 | 1559 | /* AIO completions deferred from interrupt context */ |
---|
1499 | 1560 | struct workqueue_struct *s_dio_done_wq; |
---|
1500 | 1561 | struct hlist_head s_pins; |
---|
.. | .. |
---|
1507 | 1568 | struct user_namespace *s_user_ns; |
---|
1508 | 1569 | |
---|
1509 | 1570 | /* |
---|
1510 | | - * Keep the lru lists last in the structure so they always sit on their |
---|
1511 | | - * own individual cachelines. |
---|
| 1571 | + * The list_lru structure is essentially just a pointer to a table |
---|
| 1572 | + * of per-node lru lists, each of which has its own spinlock. |
---|
| 1573 | + * There is no need to put them into separate cachelines. |
---|
1512 | 1574 | */ |
---|
1513 | | - struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; |
---|
1514 | | - struct list_lru s_inode_lru ____cacheline_aligned_in_smp; |
---|
| 1575 | + struct list_lru s_dentry_lru; |
---|
| 1576 | + struct list_lru s_inode_lru; |
---|
1515 | 1577 | struct rcu_head rcu; |
---|
1516 | 1578 | struct work_struct destroy_work; |
---|
1517 | 1579 | |
---|
.. | .. |
---|
1560 | 1622 | inode->i_gid = make_kgid(inode->i_sb->s_user_ns, gid); |
---|
1561 | 1623 | } |
---|
1562 | 1624 | |
---|
1563 | | -extern struct timespec64 timespec64_trunc(struct timespec64 t, unsigned gran); |
---|
1564 | 1625 | extern struct timespec64 current_time(struct inode *inode); |
---|
1565 | 1626 | |
---|
1566 | 1627 | /* |
---|
1567 | 1628 | * Snapshotting support. |
---|
1568 | 1629 | */ |
---|
1569 | 1630 | |
---|
1570 | | -void __sb_end_write(struct super_block *sb, int level); |
---|
1571 | | -int __sb_start_write(struct super_block *sb, int level, bool wait); |
---|
| 1631 | +/* |
---|
| 1632 | + * These are internal functions, please use sb_start_{write,pagefault,intwrite} |
---|
| 1633 | + * instead. |
---|
| 1634 | + */ |
---|
| 1635 | +static inline void __sb_end_write(struct super_block *sb, int level) |
---|
| 1636 | +{ |
---|
| 1637 | + percpu_up_read(sb->s_writers.rw_sem + level-1); |
---|
| 1638 | +} |
---|
| 1639 | + |
---|
| 1640 | +static inline void __sb_start_write(struct super_block *sb, int level) |
---|
| 1641 | +{ |
---|
| 1642 | + percpu_down_read(sb->s_writers.rw_sem + level - 1); |
---|
| 1643 | +} |
---|
| 1644 | + |
---|
| 1645 | +static inline bool __sb_start_write_trylock(struct super_block *sb, int level) |
---|
| 1646 | +{ |
---|
| 1647 | + return percpu_down_read_trylock(sb->s_writers.rw_sem + level - 1); |
---|
| 1648 | +} |
---|
1572 | 1649 | |
---|
1573 | 1650 | #define __sb_writers_acquired(sb, lev) \ |
---|
1574 | 1651 | percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_) |
---|
.. | .. |
---|
1632 | 1709 | */ |
---|
1633 | 1710 | static inline void sb_start_write(struct super_block *sb) |
---|
1634 | 1711 | { |
---|
1635 | | - __sb_start_write(sb, SB_FREEZE_WRITE, true); |
---|
| 1712 | + __sb_start_write(sb, SB_FREEZE_WRITE); |
---|
1636 | 1713 | } |
---|
1637 | 1714 | |
---|
1638 | | -static inline int sb_start_write_trylock(struct super_block *sb) |
---|
| 1715 | +static inline bool sb_start_write_trylock(struct super_block *sb) |
---|
1639 | 1716 | { |
---|
1640 | | - return __sb_start_write(sb, SB_FREEZE_WRITE, false); |
---|
| 1717 | + return __sb_start_write_trylock(sb, SB_FREEZE_WRITE); |
---|
1641 | 1718 | } |
---|
1642 | 1719 | |
---|
1643 | 1720 | /** |
---|
.. | .. |
---|
1653 | 1730 | * |
---|
1654 | 1731 | * Since page fault freeze protection behaves as a lock, users have to preserve |
---|
1655 | 1732 | * ordering of freeze protection and other filesystem locks. It is advised to |
---|
1656 | | - * put sb_start_pagefault() close to mmap_sem in lock ordering. Page fault |
---|
| 1733 | + * put sb_start_pagefault() close to mmap_lock in lock ordering. Page fault |
---|
1657 | 1734 | * handling code implies lock dependency: |
---|
1658 | 1735 | * |
---|
1659 | | - * mmap_sem |
---|
| 1736 | + * mmap_lock |
---|
1660 | 1737 | * -> sb_start_pagefault |
---|
1661 | 1738 | */ |
---|
1662 | 1739 | static inline void sb_start_pagefault(struct super_block *sb) |
---|
1663 | 1740 | { |
---|
1664 | | - __sb_start_write(sb, SB_FREEZE_PAGEFAULT, true); |
---|
| 1741 | + __sb_start_write(sb, SB_FREEZE_PAGEFAULT); |
---|
1665 | 1742 | } |
---|
1666 | 1743 | |
---|
1667 | 1744 | /* |
---|
.. | .. |
---|
1679 | 1756 | */ |
---|
1680 | 1757 | static inline void sb_start_intwrite(struct super_block *sb) |
---|
1681 | 1758 | { |
---|
1682 | | - __sb_start_write(sb, SB_FREEZE_FS, true); |
---|
| 1759 | + __sb_start_write(sb, SB_FREEZE_FS); |
---|
1683 | 1760 | } |
---|
1684 | 1761 | |
---|
1685 | | -static inline int sb_start_intwrite_trylock(struct super_block *sb) |
---|
| 1762 | +static inline bool sb_start_intwrite_trylock(struct super_block *sb) |
---|
1686 | 1763 | { |
---|
1687 | | - return __sb_start_write(sb, SB_FREEZE_FS, false); |
---|
| 1764 | + return __sb_start_write_trylock(sb, SB_FREEZE_FS); |
---|
1688 | 1765 | } |
---|
1689 | 1766 | |
---|
1690 | 1767 | |
---|
.. | .. |
---|
1694 | 1771 | * VFS helper functions.. |
---|
1695 | 1772 | */ |
---|
1696 | 1773 | extern int vfs_create(struct inode *, struct dentry *, umode_t, bool); |
---|
1697 | | -extern int vfs_create2(struct vfsmount *, struct inode *, struct dentry *, umode_t, bool); |
---|
1698 | 1774 | extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); |
---|
1699 | | -extern int vfs_mkdir2(struct vfsmount *, struct inode *, struct dentry *, umode_t); |
---|
1700 | 1775 | extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); |
---|
1701 | | -extern int vfs_mknod2(struct vfsmount *, struct inode *, struct dentry *, umode_t, dev_t); |
---|
1702 | 1776 | extern int vfs_symlink(struct inode *, struct dentry *, const char *); |
---|
1703 | | -extern int vfs_symlink2(struct vfsmount *, struct inode *, struct dentry *, const char *); |
---|
1704 | 1777 | extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **); |
---|
1705 | | -extern int vfs_link2(struct vfsmount *, struct dentry *, struct inode *, struct dentry *, struct inode **); |
---|
1706 | 1778 | extern int vfs_rmdir(struct inode *, struct dentry *); |
---|
1707 | | -extern int vfs_rmdir2(struct vfsmount *, struct inode *, struct dentry *); |
---|
1708 | 1779 | extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); |
---|
1709 | | -extern int vfs_unlink2(struct vfsmount *, struct inode *, struct dentry *, struct inode **); |
---|
1710 | 1780 | extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int); |
---|
1711 | | -extern int vfs_rename2(struct vfsmount *, struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **, unsigned int); |
---|
1712 | | -extern int vfs_whiteout(struct inode *, struct dentry *); |
---|
| 1781 | + |
---|
| 1782 | +static inline int vfs_whiteout(struct inode *dir, struct dentry *dentry) |
---|
| 1783 | +{ |
---|
| 1784 | + return vfs_mknod(dir, dentry, S_IFCHR | WHITEOUT_MODE, WHITEOUT_DEV); |
---|
| 1785 | +} |
---|
1713 | 1786 | |
---|
1714 | 1787 | extern struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, |
---|
1715 | 1788 | int open_flag); |
---|
.. | .. |
---|
1717 | 1790 | int vfs_mkobj(struct dentry *, umode_t, |
---|
1718 | 1791 | int (*f)(struct dentry *, umode_t, void *), |
---|
1719 | 1792 | void *); |
---|
1720 | | -int vfs_mkobj2(struct vfsmount *, struct dentry *, umode_t, |
---|
1721 | | - int (*f)(struct dentry *, umode_t, void *), |
---|
1722 | | - void *); |
---|
| 1793 | + |
---|
| 1794 | +int vfs_fchown(struct file *file, uid_t user, gid_t group); |
---|
| 1795 | +int vfs_fchmod(struct file *file, umode_t mode); |
---|
| 1796 | +int vfs_utimes(const struct path *path, struct timespec64 *times); |
---|
1723 | 1797 | |
---|
1724 | 1798 | extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); |
---|
| 1799 | + |
---|
| 1800 | +#ifdef CONFIG_COMPAT |
---|
| 1801 | +extern long compat_ptr_ioctl(struct file *file, unsigned int cmd, |
---|
| 1802 | + unsigned long arg); |
---|
| 1803 | +#else |
---|
| 1804 | +#define compat_ptr_ioctl NULL |
---|
| 1805 | +#endif |
---|
1725 | 1806 | |
---|
1726 | 1807 | /* |
---|
1727 | 1808 | * VFS file helper functions. |
---|
.. | .. |
---|
1729 | 1810 | extern void inode_init_owner(struct inode *inode, const struct inode *dir, |
---|
1730 | 1811 | umode_t mode); |
---|
1731 | 1812 | extern bool may_open_dev(const struct path *path); |
---|
1732 | | -/* |
---|
1733 | | - * VFS FS_IOC_FIEMAP helper definitions. |
---|
1734 | | - */ |
---|
1735 | | -struct fiemap_extent_info { |
---|
1736 | | - unsigned int fi_flags; /* Flags as passed from user */ |
---|
1737 | | - unsigned int fi_extents_mapped; /* Number of mapped extents */ |
---|
1738 | | - unsigned int fi_extents_max; /* Size of fiemap_extent array */ |
---|
1739 | | - struct fiemap_extent __user *fi_extents_start; /* Start of |
---|
1740 | | - fiemap_extent array */ |
---|
1741 | | -}; |
---|
1742 | | -int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, |
---|
1743 | | - u64 phys, u64 len, u32 flags); |
---|
1744 | | -int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags); |
---|
1745 | | - |
---|
1746 | | -/* |
---|
1747 | | - * File types |
---|
1748 | | - * |
---|
1749 | | - * NOTE! These match bits 12..15 of stat.st_mode |
---|
1750 | | - * (ie "(i_mode >> 12) & 15"). |
---|
1751 | | - */ |
---|
1752 | | -#define DT_UNKNOWN 0 |
---|
1753 | | -#define DT_FIFO 1 |
---|
1754 | | -#define DT_CHR 2 |
---|
1755 | | -#define DT_DIR 4 |
---|
1756 | | -#define DT_BLK 6 |
---|
1757 | | -#define DT_REG 8 |
---|
1758 | | -#define DT_LNK 10 |
---|
1759 | | -#define DT_SOCK 12 |
---|
1760 | | -#define DT_WHT 14 |
---|
1761 | 1813 | |
---|
1762 | 1814 | /* |
---|
1763 | 1815 | * This is the "filldir" function type, used by readdir() to let |
---|
.. | .. |
---|
1773 | 1825 | filldir_t actor; |
---|
1774 | 1826 | loff_t pos; |
---|
1775 | 1827 | }; |
---|
1776 | | - |
---|
1777 | | -struct block_device_operations; |
---|
1778 | | - |
---|
1779 | | -/* These macros are for out of kernel modules to test that |
---|
1780 | | - * the kernel supports the unlocked_ioctl and compat_ioctl |
---|
1781 | | - * fields in struct file_operations. */ |
---|
1782 | | -#define HAVE_COMPAT_IOCTL 1 |
---|
1783 | | -#define HAVE_UNLOCKED_IOCTL 1 |
---|
1784 | 1828 | |
---|
1785 | 1829 | /* |
---|
1786 | 1830 | * These flags let !MMU mmap() govern direct device mapping vs immediate |
---|
.. | .. |
---|
1801 | 1845 | #define NOMMU_VMFLAGS \ |
---|
1802 | 1846 | (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC) |
---|
1803 | 1847 | |
---|
| 1848 | +/* |
---|
| 1849 | + * These flags control the behavior of the remap_file_range function pointer. |
---|
| 1850 | + * If it is called with len == 0 that means "remap to end of source file". |
---|
| 1851 | + * See Documentation/filesystems/vfs.rst for more details about this call. |
---|
| 1852 | + * |
---|
| 1853 | + * REMAP_FILE_DEDUP: only remap if contents identical (i.e. deduplicate) |
---|
| 1854 | + * REMAP_FILE_CAN_SHORTEN: caller can handle a shortened request |
---|
| 1855 | + */ |
---|
| 1856 | +#define REMAP_FILE_DEDUP (1 << 0) |
---|
| 1857 | +#define REMAP_FILE_CAN_SHORTEN (1 << 1) |
---|
| 1858 | + |
---|
| 1859 | +/* |
---|
| 1860 | + * These flags signal that the caller is ok with altering various aspects of |
---|
| 1861 | + * the behavior of the remap operation. The changes must be made by the |
---|
| 1862 | + * implementation; the vfs remap helper functions can take advantage of them. |
---|
| 1863 | + * Flags in this category exist to preserve the quirky behavior of the hoisted |
---|
| 1864 | + * btrfs clone/dedupe ioctls. |
---|
| 1865 | + */ |
---|
| 1866 | +#define REMAP_FILE_ADVISORY (REMAP_FILE_CAN_SHORTEN) |
---|
| 1867 | + |
---|
| 1868 | +/* |
---|
| 1869 | + * These flags control the behavior of vfs_copy_file_range(). |
---|
| 1870 | + * They are not available to the user via syscall. |
---|
| 1871 | + * |
---|
| 1872 | + * COPY_FILE_SPLICE: call splice direct instead of fs clone/copy ops |
---|
| 1873 | + */ |
---|
| 1874 | +#define COPY_FILE_SPLICE (1 << 0) |
---|
1804 | 1875 | |
---|
1805 | 1876 | struct iov_iter; |
---|
1806 | 1877 | |
---|
.. | .. |
---|
1811 | 1882 | ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); |
---|
1812 | 1883 | ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); |
---|
1813 | 1884 | ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); |
---|
| 1885 | + int (*iopoll)(struct kiocb *kiocb, bool spin); |
---|
1814 | 1886 | int (*iterate) (struct file *, struct dir_context *); |
---|
1815 | 1887 | int (*iterate_shared) (struct file *, struct dir_context *); |
---|
1816 | 1888 | __poll_t (*poll) (struct file *, struct poll_table_struct *); |
---|
.. | .. |
---|
1839 | 1911 | #endif |
---|
1840 | 1912 | ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, |
---|
1841 | 1913 | loff_t, size_t, unsigned int); |
---|
1842 | | - int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, |
---|
1843 | | - u64); |
---|
1844 | | - int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, |
---|
1845 | | - u64); |
---|
| 1914 | + loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in, |
---|
| 1915 | + struct file *file_out, loff_t pos_out, |
---|
| 1916 | + loff_t len, unsigned int remap_flags); |
---|
1846 | 1917 | int (*fadvise)(struct file *, loff_t, loff_t, int); |
---|
1847 | 1918 | |
---|
1848 | 1919 | ANDROID_KABI_RESERVE(1); |
---|
.. | .. |
---|
1855 | 1926 | struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); |
---|
1856 | 1927 | const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *); |
---|
1857 | 1928 | int (*permission) (struct inode *, int); |
---|
1858 | | - int (*permission2) (struct vfsmount *, struct inode *, int); |
---|
1859 | 1929 | struct posix_acl * (*get_acl)(struct inode *, int); |
---|
1860 | 1930 | |
---|
1861 | 1931 | int (*readlink) (struct dentry *, char __user *,int); |
---|
.. | .. |
---|
1870 | 1940 | int (*rename) (struct inode *, struct dentry *, |
---|
1871 | 1941 | struct inode *, struct dentry *, unsigned int); |
---|
1872 | 1942 | int (*setattr) (struct dentry *, struct iattr *); |
---|
1873 | | - int (*setattr2) (struct vfsmount *, struct dentry *, struct iattr *); |
---|
1874 | | - int (*getattr) (const struct path *, struct kstat *, u32, unsigned int); |
---|
| 1943 | + int (*getattr) (const struct path *, struct kstat *, u32, unsigned int); |
---|
1875 | 1944 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
---|
1876 | 1945 | int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, |
---|
1877 | 1946 | u64 len); |
---|
.. | .. |
---|
1905 | 1974 | return file->f_op->mmap(file, vma); |
---|
1906 | 1975 | } |
---|
1907 | 1976 | |
---|
1908 | | -ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, |
---|
1909 | | - unsigned long nr_segs, unsigned long fast_segs, |
---|
1910 | | - struct iovec *fast_pointer, |
---|
1911 | | - struct iovec **ret_pointer); |
---|
1912 | | - |
---|
1913 | | -extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *); |
---|
1914 | 1977 | extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); |
---|
1915 | 1978 | extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); |
---|
1916 | | -extern ssize_t vfs_readv(struct file *, const struct iovec __user *, |
---|
1917 | | - unsigned long, loff_t *, rwf_t); |
---|
1918 | 1979 | extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, |
---|
1919 | 1980 | loff_t, size_t, unsigned int); |
---|
1920 | | -extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, |
---|
1921 | | - struct inode *inode_out, loff_t pos_out, |
---|
1922 | | - u64 *len, bool is_dedupe); |
---|
1923 | | -extern int do_clone_file_range(struct file *file_in, loff_t pos_in, |
---|
1924 | | - struct file *file_out, loff_t pos_out, u64 len); |
---|
1925 | | -extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, |
---|
1926 | | - struct file *file_out, loff_t pos_out, u64 len); |
---|
1927 | | -extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, |
---|
1928 | | - struct inode *dest, loff_t destoff, |
---|
1929 | | - loff_t len, bool *is_same); |
---|
| 1981 | +extern ssize_t generic_copy_file_range(struct file *file_in, loff_t pos_in, |
---|
| 1982 | + struct file *file_out, loff_t pos_out, |
---|
| 1983 | + size_t len, unsigned int flags); |
---|
| 1984 | +extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, |
---|
| 1985 | + struct file *file_out, loff_t pos_out, |
---|
| 1986 | + loff_t *count, |
---|
| 1987 | + unsigned int remap_flags); |
---|
| 1988 | +extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, |
---|
| 1989 | + struct file *file_out, loff_t pos_out, |
---|
| 1990 | + loff_t len, unsigned int remap_flags); |
---|
| 1991 | +extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, |
---|
| 1992 | + struct file *file_out, loff_t pos_out, |
---|
| 1993 | + loff_t len, unsigned int remap_flags); |
---|
1930 | 1994 | extern int vfs_dedupe_file_range(struct file *file, |
---|
1931 | 1995 | struct file_dedupe_range *same); |
---|
1932 | | -extern int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, |
---|
1933 | | - struct file *dst_file, loff_t dst_pos, |
---|
1934 | | - u64 len); |
---|
| 1996 | +extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, |
---|
| 1997 | + struct file *dst_file, loff_t dst_pos, |
---|
| 1998 | + loff_t len, unsigned int remap_flags); |
---|
1935 | 1999 | |
---|
1936 | 2000 | |
---|
1937 | 2001 | struct super_operations { |
---|
1938 | 2002 | struct inode *(*alloc_inode)(struct super_block *sb); |
---|
1939 | 2003 | void (*destroy_inode)(struct inode *); |
---|
| 2004 | + void (*free_inode)(struct inode *); |
---|
1940 | 2005 | |
---|
1941 | 2006 | void (*dirty_inode) (struct inode *, int flags); |
---|
1942 | 2007 | int (*write_inode) (struct inode *, struct writeback_control *wbc); |
---|
.. | .. |
---|
1950 | 2015 | int (*unfreeze_fs) (struct super_block *); |
---|
1951 | 2016 | int (*statfs) (struct dentry *, struct kstatfs *); |
---|
1952 | 2017 | int (*remount_fs) (struct super_block *, int *, char *); |
---|
1953 | | - int (*remount_fs2) (struct vfsmount *, struct super_block *, int *, char *); |
---|
1954 | | - void *(*clone_mnt_data) (void *); |
---|
1955 | | - void (*copy_mnt_data) (void *, void *); |
---|
1956 | 2018 | void (*umount_begin) (struct super_block *); |
---|
1957 | | - void (*umount_end)(struct super_block *sb, int flags); |
---|
1958 | 2019 | |
---|
1959 | 2020 | int (*show_options)(struct seq_file *, struct dentry *); |
---|
1960 | | - int (*show_options2)(struct vfsmount *,struct seq_file *, struct dentry *); |
---|
1961 | 2021 | int (*show_devname)(struct seq_file *, struct dentry *); |
---|
1962 | 2022 | int (*show_path)(struct seq_file *, struct dentry *); |
---|
1963 | 2023 | int (*show_stats)(struct seq_file *, struct dentry *); |
---|
.. | .. |
---|
1981 | 2041 | /* |
---|
1982 | 2042 | * Inode flags - they have no relation to superblock flags now |
---|
1983 | 2043 | */ |
---|
1984 | | -#define S_SYNC 1 /* Writes are synced at once */ |
---|
1985 | | -#define S_NOATIME 2 /* Do not update access times */ |
---|
1986 | | -#define S_APPEND 4 /* Append-only file */ |
---|
1987 | | -#define S_IMMUTABLE 8 /* Immutable file */ |
---|
1988 | | -#define S_DEAD 16 /* removed, but still open directory */ |
---|
1989 | | -#define S_NOQUOTA 32 /* Inode is not counted to quota */ |
---|
1990 | | -#define S_DIRSYNC 64 /* Directory modifications are synchronous */ |
---|
1991 | | -#define S_NOCMTIME 128 /* Do not update file c/mtime */ |
---|
1992 | | -#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ |
---|
1993 | | -#define S_PRIVATE 512 /* Inode is fs-internal */ |
---|
1994 | | -#define S_IMA 1024 /* Inode has an associated IMA struct */ |
---|
1995 | | -#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ |
---|
1996 | | -#define S_NOSEC 4096 /* no suid or xattr security attributes */ |
---|
| 2044 | +#define S_SYNC (1 << 0) /* Writes are synced at once */ |
---|
| 2045 | +#define S_NOATIME (1 << 1) /* Do not update access times */ |
---|
| 2046 | +#define S_APPEND (1 << 2) /* Append-only file */ |
---|
| 2047 | +#define S_IMMUTABLE (1 << 3) /* Immutable file */ |
---|
| 2048 | +#define S_DEAD (1 << 4) /* removed, but still open directory */ |
---|
| 2049 | +#define S_NOQUOTA (1 << 5) /* Inode is not counted to quota */ |
---|
| 2050 | +#define S_DIRSYNC (1 << 6) /* Directory modifications are synchronous */ |
---|
| 2051 | +#define S_NOCMTIME (1 << 7) /* Do not update file c/mtime */ |
---|
| 2052 | +#define S_SWAPFILE (1 << 8) /* Do not truncate: swapon got its bmaps */ |
---|
| 2053 | +#define S_PRIVATE (1 << 9) /* Inode is fs-internal */ |
---|
| 2054 | +#define S_IMA (1 << 10) /* Inode has an associated IMA struct */ |
---|
| 2055 | +#define S_AUTOMOUNT (1 << 11) /* Automount/referral quasi-directory */ |
---|
| 2056 | +#define S_NOSEC (1 << 12) /* no suid or xattr security attributes */ |
---|
1997 | 2057 | #ifdef CONFIG_FS_DAX |
---|
1998 | | -#define S_DAX 8192 /* Direct Access, avoiding the page cache */ |
---|
| 2058 | +#define S_DAX (1 << 13) /* Direct Access, avoiding the page cache */ |
---|
1999 | 2059 | #else |
---|
2000 | | -#define S_DAX 0 /* Make all the DAX code disappear */ |
---|
| 2060 | +#define S_DAX 0 /* Make all the DAX code disappear */ |
---|
2001 | 2061 | #endif |
---|
2002 | | -#define S_ENCRYPTED 16384 /* Encrypted file (using fs/crypto/) */ |
---|
2003 | | -#define S_CASEFOLD 32768 /* Casefolded file */ |
---|
2004 | | -#define S_VERITY 65536 /* Verity file (using fs/verity/) */ |
---|
| 2062 | +#define S_ENCRYPTED (1 << 14) /* Encrypted file (using fs/crypto/) */ |
---|
| 2063 | +#define S_CASEFOLD (1 << 15) /* Casefolded file */ |
---|
| 2064 | +#define S_VERITY (1 << 16) /* Verity file (using fs/verity/) */ |
---|
2005 | 2065 | |
---|
2006 | 2066 | /* |
---|
2007 | 2067 | * Note that nosuid etc flags are inode-specific: setting some file-system |
---|
.. | .. |
---|
2078 | 2138 | .ki_filp = filp, |
---|
2079 | 2139 | .ki_flags = iocb_flags(filp), |
---|
2080 | 2140 | .ki_hint = ki_hint_validate(file_write_hint(filp)), |
---|
2081 | | - .ki_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_NONE, 0), |
---|
| 2141 | + .ki_ioprio = get_current_ioprio(), |
---|
| 2142 | + }; |
---|
| 2143 | +} |
---|
| 2144 | + |
---|
| 2145 | +static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src, |
---|
| 2146 | + struct file *filp) |
---|
| 2147 | +{ |
---|
| 2148 | + *kiocb = (struct kiocb) { |
---|
| 2149 | + .ki_filp = filp, |
---|
| 2150 | + .ki_flags = kiocb_src->ki_flags, |
---|
| 2151 | + .ki_hint = kiocb_src->ki_hint, |
---|
| 2152 | + .ki_ioprio = kiocb_src->ki_ioprio, |
---|
| 2153 | + .ki_pos = kiocb_src->ki_pos, |
---|
2082 | 2154 | }; |
---|
2083 | 2155 | } |
---|
2084 | 2156 | |
---|
.. | .. |
---|
2136 | 2208 | * I_WB_SWITCH Cgroup bdi_writeback switching in progress. Used to |
---|
2137 | 2209 | * synchronize competing switching instances and to tell |
---|
2138 | 2210 | * wb stat updates to grab the i_pages lock. See |
---|
2139 | | - * inode_switch_wb_work_fn() for details. |
---|
| 2211 | + * inode_switch_wbs_work_fn() for details. |
---|
2140 | 2212 | * |
---|
2141 | 2213 | * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper |
---|
2142 | 2214 | * and work dirs among overlayfs mounts. |
---|
2143 | 2215 | * |
---|
2144 | 2216 | * I_CREATING New object's inode in the middle of setting up. |
---|
| 2217 | + * |
---|
| 2218 | + * I_DONTCACHE Evict inode as soon as it is not used anymore. |
---|
2145 | 2219 | * |
---|
2146 | 2220 | * I_SYNC_QUEUED Inode is queued in b_io or b_more_io writeback lists. |
---|
2147 | 2221 | * Used to detect that mark_inode_dirty() should not move |
---|
.. | .. |
---|
2167 | 2241 | #define I_WB_SWITCH (1 << 13) |
---|
2168 | 2242 | #define I_OVL_INUSE (1 << 14) |
---|
2169 | 2243 | #define I_CREATING (1 << 15) |
---|
| 2244 | +#define I_DONTCACHE (1 << 16) |
---|
2170 | 2245 | #define I_SYNC_QUEUED (1 << 17) |
---|
2171 | 2246 | |
---|
2172 | 2247 | #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC) |
---|
.. | .. |
---|
2210 | 2285 | |
---|
2211 | 2286 | extern bool atime_needs_update(const struct path *, struct inode *); |
---|
2212 | 2287 | extern void touch_atime(const struct path *); |
---|
| 2288 | +int inode_update_time(struct inode *inode, struct timespec64 *time, int flags); |
---|
| 2289 | + |
---|
2213 | 2290 | static inline void file_accessed(struct file *file) |
---|
2214 | 2291 | { |
---|
2215 | 2292 | if (!(file->f_flags & O_NOATIME)) |
---|
2216 | 2293 | touch_atime(&file->f_path); |
---|
2217 | 2294 | } |
---|
| 2295 | + |
---|
| 2296 | +extern int file_modified(struct file *file); |
---|
2218 | 2297 | |
---|
2219 | 2298 | int sync_inode(struct inode *inode, struct writeback_control *wbc); |
---|
2220 | 2299 | int sync_inode_metadata(struct inode *inode, int wait); |
---|
.. | .. |
---|
2226 | 2305 | #define FS_BINARY_MOUNTDATA 2 |
---|
2227 | 2306 | #define FS_HAS_SUBTYPE 4 |
---|
2228 | 2307 | #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ |
---|
| 2308 | +#define FS_DISALLOW_NOTIFY_PERM 16 /* Disable fanotify permission events */ |
---|
| 2309 | +#define FS_THP_SUPPORT 8192 /* Remove once all fs converted */ |
---|
2229 | 2310 | #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ |
---|
| 2311 | + int (*init_fs_context)(struct fs_context *); |
---|
| 2312 | + const struct fs_parameter_spec *parameters; |
---|
2230 | 2313 | struct dentry *(*mount) (struct file_system_type *, int, |
---|
2231 | 2314 | const char *, void *); |
---|
2232 | | - struct dentry *(*mount2) (struct vfsmount *, struct file_system_type *, int, |
---|
2233 | | - const char *, void *); |
---|
2234 | | - void *(*alloc_mnt_data) (void); |
---|
2235 | 2315 | void (*kill_sb) (struct super_block *); |
---|
2236 | 2316 | struct module *owner; |
---|
2237 | 2317 | struct file_system_type * next; |
---|
.. | .. |
---|
2254 | 2334 | |
---|
2255 | 2335 | #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME) |
---|
2256 | 2336 | |
---|
2257 | | -extern struct dentry *mount_ns(struct file_system_type *fs_type, |
---|
2258 | | - int flags, void *data, void *ns, struct user_namespace *user_ns, |
---|
2259 | | - int (*fill_super)(struct super_block *, void *, int)); |
---|
2260 | | -#ifdef CONFIG_BLOCK |
---|
2261 | 2337 | extern struct dentry *mount_bdev(struct file_system_type *fs_type, |
---|
2262 | 2338 | int flags, const char *dev_name, void *data, |
---|
2263 | 2339 | int (*fill_super)(struct super_block *, void *, int)); |
---|
2264 | | -#else |
---|
2265 | | -static inline struct dentry *mount_bdev(struct file_system_type *fs_type, |
---|
2266 | | - int flags, const char *dev_name, void *data, |
---|
2267 | | - int (*fill_super)(struct super_block *, void *, int)) |
---|
2268 | | -{ |
---|
2269 | | - return ERR_PTR(-ENODEV); |
---|
2270 | | -} |
---|
2271 | | -#endif |
---|
2272 | 2340 | extern struct dentry *mount_single(struct file_system_type *fs_type, |
---|
2273 | 2341 | int flags, void *data, |
---|
2274 | 2342 | int (*fill_super)(struct super_block *, void *, int)); |
---|
.. | .. |
---|
2277 | 2345 | int (*fill_super)(struct super_block *, void *, int)); |
---|
2278 | 2346 | extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path); |
---|
2279 | 2347 | void generic_shutdown_super(struct super_block *sb); |
---|
2280 | | -#ifdef CONFIG_BLOCK |
---|
2281 | 2348 | void kill_block_super(struct super_block *sb); |
---|
2282 | | -#else |
---|
2283 | | -static inline void kill_block_super(struct super_block *sb) |
---|
2284 | | -{ |
---|
2285 | | - BUG(); |
---|
2286 | | -} |
---|
2287 | | -#endif |
---|
2288 | 2349 | void kill_anon_super(struct super_block *sb); |
---|
2289 | 2350 | void kill_litter_super(struct super_block *sb); |
---|
2290 | 2351 | void deactivate_super(struct super_block *sb); |
---|
2291 | 2352 | void deactivate_locked_super(struct super_block *sb); |
---|
2292 | 2353 | int set_anon_super(struct super_block *s, void *data); |
---|
| 2354 | +int set_anon_super_fc(struct super_block *s, struct fs_context *fc); |
---|
2293 | 2355 | int get_anon_bdev(dev_t *); |
---|
2294 | 2356 | void free_anon_bdev(dev_t); |
---|
2295 | | -struct super_block *sget_userns(struct file_system_type *type, |
---|
2296 | | - int (*test)(struct super_block *,void *), |
---|
2297 | | - int (*set)(struct super_block *,void *), |
---|
2298 | | - int flags, struct user_namespace *user_ns, |
---|
2299 | | - void *data); |
---|
| 2357 | +struct super_block *sget_fc(struct fs_context *fc, |
---|
| 2358 | + int (*test)(struct super_block *, struct fs_context *), |
---|
| 2359 | + int (*set)(struct super_block *, struct fs_context *)); |
---|
2300 | 2360 | struct super_block *sget(struct file_system_type *type, |
---|
2301 | 2361 | int (*test)(struct super_block *,void *), |
---|
2302 | 2362 | int (*set)(struct super_block *,void *), |
---|
2303 | 2363 | int flags, void *data); |
---|
2304 | | -extern struct dentry *mount_pseudo_xattr(struct file_system_type *, char *, |
---|
2305 | | - const struct super_operations *ops, |
---|
2306 | | - const struct xattr_handler **xattr, |
---|
2307 | | - const struct dentry_operations *dops, |
---|
2308 | | - unsigned long); |
---|
2309 | | - |
---|
2310 | | -static inline struct dentry * |
---|
2311 | | -mount_pseudo(struct file_system_type *fs_type, char *name, |
---|
2312 | | - const struct super_operations *ops, |
---|
2313 | | - const struct dentry_operations *dops, unsigned long magic) |
---|
2314 | | -{ |
---|
2315 | | - return mount_pseudo_xattr(fs_type, name, ops, NULL, dops, magic); |
---|
2316 | | -} |
---|
2317 | 2364 | |
---|
2318 | 2365 | /* Alas, no aliases. Too much hassle with bringing module.h everywhere */ |
---|
2319 | 2366 | #define fops_get(fops) \ |
---|
.. | .. |
---|
2334 | 2381 | |
---|
2335 | 2382 | extern int register_filesystem(struct file_system_type *); |
---|
2336 | 2383 | extern int unregister_filesystem(struct file_system_type *); |
---|
2337 | | -extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data); |
---|
2338 | | -#define kern_mount(type) kern_mount_data(type, NULL) |
---|
| 2384 | +extern struct vfsmount *kern_mount(struct file_system_type *); |
---|
2339 | 2385 | extern void kern_unmount(struct vfsmount *mnt); |
---|
2340 | 2386 | extern int may_umount_tree(struct vfsmount *); |
---|
2341 | 2387 | extern int may_umount(struct vfsmount *); |
---|
.. | .. |
---|
2549 | 2595 | struct audit_names *aname; |
---|
2550 | 2596 | const char iname[]; |
---|
2551 | 2597 | }; |
---|
| 2598 | +static_assert(offsetof(struct filename, iname) % sizeof(long) == 0); |
---|
2552 | 2599 | |
---|
2553 | 2600 | extern long vfs_truncate(const struct path *, loff_t); |
---|
2554 | 2601 | extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, |
---|
2555 | 2602 | struct file *filp); |
---|
2556 | | -extern int do_truncate2(struct vfsmount *, struct dentry *, loff_t start, |
---|
2557 | | - unsigned int time_attrs, struct file *filp); |
---|
2558 | 2603 | extern int vfs_fallocate(struct file *file, int mode, loff_t offset, |
---|
2559 | 2604 | loff_t len); |
---|
2560 | 2605 | extern long do_sys_open(int dfd, const char __user *filename, int flags, |
---|
2561 | 2606 | umode_t mode); |
---|
2562 | 2607 | extern struct file *file_open_name(struct filename *, int, umode_t); |
---|
2563 | 2608 | extern struct file *filp_open(const char *, int, umode_t); |
---|
| 2609 | +extern struct file *filp_open_block(const char *, int, umode_t); |
---|
2564 | 2610 | extern struct file *file_open_root(struct dentry *, struct vfsmount *, |
---|
2565 | 2611 | const char *, int, umode_t); |
---|
2566 | 2612 | extern struct file * dentry_open(const struct path *, int, const struct cred *); |
---|
.. | .. |
---|
2581 | 2627 | int (*open)(struct inode *, struct file *)); |
---|
2582 | 2628 | extern int finish_no_open(struct file *file, struct dentry *dentry); |
---|
2583 | 2629 | |
---|
2584 | | -/* fs/ioctl.c */ |
---|
2585 | | - |
---|
2586 | | -extern int ioctl_preallocate(struct file *filp, void __user *argp); |
---|
2587 | | - |
---|
2588 | 2630 | /* fs/dcache.c */ |
---|
2589 | 2631 | extern void __init vfs_caches_init_early(void); |
---|
2590 | 2632 | extern void __init vfs_caches_init(void); |
---|
.. | .. |
---|
2594 | 2636 | #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) |
---|
2595 | 2637 | #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) |
---|
2596 | 2638 | |
---|
2597 | | -#ifdef CONFIG_BLOCK |
---|
2598 | | -extern int register_blkdev(unsigned int, const char *); |
---|
2599 | | -extern void unregister_blkdev(unsigned int, const char *); |
---|
2600 | | -extern void bdev_unhash_inode(dev_t dev); |
---|
2601 | | -extern struct block_device *bdget(dev_t); |
---|
2602 | | -extern struct block_device *bdgrab(struct block_device *bdev); |
---|
2603 | | -extern void bd_set_size(struct block_device *, loff_t size); |
---|
2604 | | -extern void bd_forget(struct inode *inode); |
---|
2605 | | -extern void bdput(struct block_device *); |
---|
2606 | | -extern void invalidate_bdev(struct block_device *); |
---|
2607 | | -extern void iterate_bdevs(void (*)(struct block_device *, void *), void *); |
---|
2608 | | -extern int sync_blockdev(struct block_device *bdev); |
---|
2609 | | -extern void kill_bdev(struct block_device *); |
---|
2610 | | -extern struct super_block *freeze_bdev(struct block_device *); |
---|
2611 | | -extern void emergency_thaw_all(void); |
---|
2612 | | -extern void emergency_thaw_bdev(struct super_block *sb); |
---|
2613 | | -extern int thaw_bdev(struct block_device *bdev, struct super_block *sb); |
---|
2614 | | -extern int fsync_bdev(struct block_device *); |
---|
2615 | | - |
---|
2616 | 2639 | extern struct super_block *blockdev_superblock; |
---|
2617 | | - |
---|
2618 | 2640 | static inline bool sb_is_blkdev_sb(struct super_block *sb) |
---|
2619 | 2641 | { |
---|
2620 | | - return sb == blockdev_superblock; |
---|
2621 | | -} |
---|
2622 | | -#else |
---|
2623 | | -static inline void bd_forget(struct inode *inode) {} |
---|
2624 | | -static inline int sync_blockdev(struct block_device *bdev) { return 0; } |
---|
2625 | | -static inline void kill_bdev(struct block_device *bdev) {} |
---|
2626 | | -static inline void invalidate_bdev(struct block_device *bdev) {} |
---|
2627 | | - |
---|
2628 | | -static inline struct super_block *freeze_bdev(struct block_device *sb) |
---|
2629 | | -{ |
---|
2630 | | - return NULL; |
---|
| 2642 | + return IS_ENABLED(CONFIG_BLOCK) && sb == blockdev_superblock; |
---|
2631 | 2643 | } |
---|
2632 | 2644 | |
---|
2633 | | -static inline int thaw_bdev(struct block_device *bdev, struct super_block *sb) |
---|
2634 | | -{ |
---|
2635 | | - return 0; |
---|
2636 | | -} |
---|
2637 | | - |
---|
2638 | | -static inline int emergency_thaw_bdev(struct super_block *sb) |
---|
2639 | | -{ |
---|
2640 | | - return 0; |
---|
2641 | | -} |
---|
2642 | | - |
---|
2643 | | -static inline void iterate_bdevs(void (*f)(struct block_device *, void *), void *arg) |
---|
2644 | | -{ |
---|
2645 | | -} |
---|
2646 | | - |
---|
2647 | | -static inline bool sb_is_blkdev_sb(struct super_block *sb) |
---|
2648 | | -{ |
---|
2649 | | - return false; |
---|
2650 | | -} |
---|
2651 | | -#endif |
---|
| 2645 | +void emergency_thaw_all(void); |
---|
2652 | 2646 | extern int sync_filesystem(struct super_block *); |
---|
2653 | 2647 | extern const struct file_operations def_blk_fops; |
---|
2654 | 2648 | extern const struct file_operations def_chr_fops; |
---|
2655 | | -#ifdef CONFIG_BLOCK |
---|
2656 | | -extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); |
---|
2657 | | -extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); |
---|
2658 | | -extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); |
---|
2659 | | -extern int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder); |
---|
2660 | | -extern struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, |
---|
2661 | | - void *holder); |
---|
2662 | | -extern struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, |
---|
2663 | | - void *holder); |
---|
2664 | | -extern void blkdev_put(struct block_device *bdev, fmode_t mode); |
---|
2665 | | -extern int __blkdev_reread_part(struct block_device *bdev); |
---|
2666 | | -extern int blkdev_reread_part(struct block_device *bdev); |
---|
2667 | | - |
---|
2668 | | -#ifdef CONFIG_SYSFS |
---|
2669 | | -extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk); |
---|
2670 | | -extern void bd_unlink_disk_holder(struct block_device *bdev, |
---|
2671 | | - struct gendisk *disk); |
---|
2672 | | -#else |
---|
2673 | | -static inline int bd_link_disk_holder(struct block_device *bdev, |
---|
2674 | | - struct gendisk *disk) |
---|
2675 | | -{ |
---|
2676 | | - return 0; |
---|
2677 | | -} |
---|
2678 | | -static inline void bd_unlink_disk_holder(struct block_device *bdev, |
---|
2679 | | - struct gendisk *disk) |
---|
2680 | | -{ |
---|
2681 | | -} |
---|
2682 | | -#endif |
---|
2683 | | -#endif |
---|
2684 | 2649 | |
---|
2685 | 2650 | /* fs/char_dev.c */ |
---|
2686 | 2651 | #define CHRDEV_MAJOR_MAX 512 |
---|
.. | .. |
---|
2711 | 2676 | __unregister_chrdev(major, 0, 256, name); |
---|
2712 | 2677 | } |
---|
2713 | 2678 | |
---|
2714 | | -/* fs/block_dev.c */ |
---|
2715 | | -#define BDEVNAME_SIZE 32 /* Largest string for a blockdev identifier */ |
---|
2716 | | -#define BDEVT_SIZE 10 /* Largest string for MAJ:MIN for blkdev */ |
---|
2717 | | - |
---|
2718 | | -#ifdef CONFIG_BLOCK |
---|
2719 | | -#define BLKDEV_MAJOR_MAX 512 |
---|
2720 | | -extern const char *__bdevname(dev_t, char *buffer); |
---|
2721 | | -extern const char *bdevname(struct block_device *bdev, char *buffer); |
---|
2722 | | -extern struct block_device *lookup_bdev(const char *); |
---|
2723 | | -extern void blkdev_show(struct seq_file *,off_t); |
---|
2724 | | - |
---|
2725 | | -#else |
---|
2726 | | -#define BLKDEV_MAJOR_MAX 0 |
---|
2727 | | -#endif |
---|
2728 | | - |
---|
2729 | 2679 | extern void init_special_inode(struct inode *, umode_t, dev_t); |
---|
2730 | 2680 | |
---|
2731 | 2681 | /* Invalid inode operations -- fs/bad_inode.c */ |
---|
2732 | 2682 | extern void make_bad_inode(struct inode *); |
---|
2733 | 2683 | extern bool is_bad_inode(struct inode *); |
---|
2734 | 2684 | |
---|
2735 | | -#ifdef CONFIG_BLOCK |
---|
2736 | | -extern void check_disk_size_change(struct gendisk *disk, |
---|
2737 | | - struct block_device *bdev, bool verbose); |
---|
2738 | | -extern int revalidate_disk(struct gendisk *); |
---|
2739 | | -extern int check_disk_change(struct block_device *); |
---|
2740 | | -extern int __invalidate_device(struct block_device *, bool); |
---|
2741 | | -extern int invalidate_partition(struct gendisk *, int); |
---|
2742 | | -#endif |
---|
2743 | 2685 | unsigned long invalidate_mapping_pages(struct address_space *mapping, |
---|
2744 | 2686 | pgoff_t start, pgoff_t end); |
---|
| 2687 | + |
---|
| 2688 | +void invalidate_mapping_pagevec(struct address_space *mapping, |
---|
| 2689 | + pgoff_t start, pgoff_t end, |
---|
| 2690 | + unsigned long *nr_pagevec); |
---|
2745 | 2691 | |
---|
2746 | 2692 | static inline void invalidate_remote_inode(struct inode *inode) |
---|
2747 | 2693 | { |
---|
.. | .. |
---|
2768 | 2714 | |
---|
2769 | 2715 | extern bool filemap_range_has_page(struct address_space *, loff_t lstart, |
---|
2770 | 2716 | loff_t lend); |
---|
2771 | | -extern int filemap_write_and_wait(struct address_space *mapping); |
---|
2772 | 2717 | extern int filemap_write_and_wait_range(struct address_space *mapping, |
---|
2773 | 2718 | loff_t lstart, loff_t lend); |
---|
2774 | 2719 | extern int __filemap_fdatawrite_range(struct address_space *mapping, |
---|
.. | .. |
---|
2777 | 2722 | loff_t start, loff_t end); |
---|
2778 | 2723 | extern int filemap_check_errors(struct address_space *mapping); |
---|
2779 | 2724 | extern void __filemap_set_wb_err(struct address_space *mapping, int err); |
---|
| 2725 | + |
---|
| 2726 | +static inline int filemap_write_and_wait(struct address_space *mapping) |
---|
| 2727 | +{ |
---|
| 2728 | + return filemap_write_and_wait_range(mapping, 0, LLONG_MAX); |
---|
| 2729 | +} |
---|
2780 | 2730 | |
---|
2781 | 2731 | extern int __must_check file_fdatawait_range(struct file *file, loff_t lstart, |
---|
2782 | 2732 | loff_t lend); |
---|
.. | .. |
---|
2811 | 2761 | } |
---|
2812 | 2762 | |
---|
2813 | 2763 | /** |
---|
2814 | | - * filemap_check_wb_error - has an error occurred since the mark was sampled? |
---|
| 2764 | + * filemap_check_wb_err - has an error occurred since the mark was sampled? |
---|
2815 | 2765 | * @mapping: mapping to check for writeback errors |
---|
2816 | 2766 | * @since: previously-sampled errseq_t |
---|
2817 | 2767 | * |
---|
.. | .. |
---|
2838 | 2788 | return errseq_sample(&mapping->wb_err); |
---|
2839 | 2789 | } |
---|
2840 | 2790 | |
---|
| 2791 | +/** |
---|
| 2792 | + * file_sample_sb_err - sample the current errseq_t to test for later errors |
---|
| 2793 | + * @file: file pointer to be sampled |
---|
| 2794 | + * |
---|
| 2795 | + * Grab the most current superblock-level errseq_t value for the given |
---|
| 2796 | + * struct file. |
---|
| 2797 | + */ |
---|
| 2798 | +static inline errseq_t file_sample_sb_err(struct file *file) |
---|
| 2799 | +{ |
---|
| 2800 | + return errseq_sample(&file->f_path.dentry->d_sb->s_wb_err); |
---|
| 2801 | +} |
---|
| 2802 | + |
---|
2841 | 2803 | extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end, |
---|
2842 | 2804 | int datasync); |
---|
2843 | 2805 | extern int vfs_fsync(struct file *file, int datasync); |
---|
| 2806 | + |
---|
| 2807 | +extern int sync_file_range(struct file *file, loff_t offset, loff_t nbytes, |
---|
| 2808 | + unsigned int flags); |
---|
2844 | 2809 | |
---|
2845 | 2810 | /* |
---|
2846 | 2811 | * Sync the bytes written if this was a synchronous write. Expect ki_pos |
---|
.. | .. |
---|
2862 | 2827 | |
---|
2863 | 2828 | extern void emergency_sync(void); |
---|
2864 | 2829 | extern void emergency_remount(void); |
---|
| 2830 | + |
---|
2865 | 2831 | #ifdef CONFIG_BLOCK |
---|
2866 | | -extern sector_t bmap(struct inode *, sector_t); |
---|
| 2832 | +extern int bmap(struct inode *inode, sector_t *block); |
---|
| 2833 | +#else |
---|
| 2834 | +static inline int bmap(struct inode *inode, sector_t *block) |
---|
| 2835 | +{ |
---|
| 2836 | + return -EINVAL; |
---|
| 2837 | +} |
---|
2867 | 2838 | #endif |
---|
| 2839 | + |
---|
2868 | 2840 | extern int notify_change(struct dentry *, struct iattr *, struct inode **); |
---|
2869 | | -extern int notify_change2(struct vfsmount *, struct dentry *, struct iattr *, struct inode **); |
---|
2870 | 2841 | extern int inode_permission(struct inode *, int); |
---|
2871 | | -extern int inode_permission2(struct vfsmount *, struct inode *, int); |
---|
2872 | 2842 | extern int generic_permission(struct inode *, int); |
---|
2873 | 2843 | extern int __check_sticky(struct inode *dir, struct inode *inode); |
---|
2874 | 2844 | |
---|
.. | .. |
---|
2877 | 2847 | return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode); |
---|
2878 | 2848 | } |
---|
2879 | 2849 | |
---|
| 2850 | +static inline bool inode_wrong_type(const struct inode *inode, umode_t mode) |
---|
| 2851 | +{ |
---|
| 2852 | + return (inode->i_mode ^ mode) & S_IFMT; |
---|
| 2853 | +} |
---|
| 2854 | + |
---|
2880 | 2855 | static inline void file_start_write(struct file *file) |
---|
2881 | 2856 | { |
---|
2882 | 2857 | if (!S_ISREG(file_inode(file)->i_mode)) |
---|
2883 | 2858 | return; |
---|
2884 | | - __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true); |
---|
| 2859 | + sb_start_write(file_inode(file)->i_sb); |
---|
2885 | 2860 | } |
---|
2886 | 2861 | |
---|
2887 | 2862 | static inline bool file_start_write_trylock(struct file *file) |
---|
2888 | 2863 | { |
---|
2889 | 2864 | if (!S_ISREG(file_inode(file)->i_mode)) |
---|
2890 | 2865 | return true; |
---|
2891 | | - return __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, false); |
---|
| 2866 | + return sb_start_write_trylock(file_inode(file)->i_sb); |
---|
2892 | 2867 | } |
---|
2893 | 2868 | |
---|
2894 | 2869 | static inline void file_end_write(struct file *file) |
---|
.. | .. |
---|
2937 | 2912 | return atomic_read(&inode->i_writecount) > 0; |
---|
2938 | 2913 | } |
---|
2939 | 2914 | |
---|
2940 | | -#ifdef CONFIG_IMA |
---|
| 2915 | +#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING) |
---|
2941 | 2916 | static inline void i_readcount_dec(struct inode *inode) |
---|
2942 | 2917 | { |
---|
2943 | 2918 | BUG_ON(!atomic_read(&inode->i_readcount)); |
---|
.. | .. |
---|
2959 | 2934 | #endif |
---|
2960 | 2935 | extern int do_pipe_flags(int *, int); |
---|
2961 | 2936 | |
---|
2962 | | -#define __kernel_read_file_id(id) \ |
---|
2963 | | - id(UNKNOWN, unknown) \ |
---|
2964 | | - id(FIRMWARE, firmware) \ |
---|
2965 | | - id(FIRMWARE_PREALLOC_BUFFER, firmware) \ |
---|
2966 | | - id(MODULE, kernel-module) \ |
---|
2967 | | - id(KEXEC_IMAGE, kexec-image) \ |
---|
2968 | | - id(KEXEC_INITRAMFS, kexec-initramfs) \ |
---|
2969 | | - id(POLICY, security-policy) \ |
---|
2970 | | - id(X509_CERTIFICATE, x509-certificate) \ |
---|
2971 | | - id(MAX_ID, ) |
---|
2972 | | - |
---|
2973 | | -#define __fid_enumify(ENUM, dummy) READING_ ## ENUM, |
---|
2974 | | -#define __fid_stringify(dummy, str) #str, |
---|
2975 | | - |
---|
2976 | | -enum kernel_read_file_id { |
---|
2977 | | - __kernel_read_file_id(__fid_enumify) |
---|
2978 | | -}; |
---|
2979 | | - |
---|
2980 | | -static const char * const kernel_read_file_str[] = { |
---|
2981 | | - __kernel_read_file_id(__fid_stringify) |
---|
2982 | | -}; |
---|
2983 | | - |
---|
2984 | | -static inline const char *kernel_read_file_id_str(enum kernel_read_file_id id) |
---|
2985 | | -{ |
---|
2986 | | - if ((unsigned)id >= READING_MAX_ID) |
---|
2987 | | - return kernel_read_file_str[READING_UNKNOWN]; |
---|
2988 | | - |
---|
2989 | | - return kernel_read_file_str[id]; |
---|
2990 | | -} |
---|
2991 | | - |
---|
2992 | | -extern int kernel_read_file(struct file *, void **, loff_t *, loff_t, |
---|
2993 | | - enum kernel_read_file_id); |
---|
2994 | | -extern int kernel_read_file_from_path(const char *, void **, loff_t *, loff_t, |
---|
2995 | | - enum kernel_read_file_id); |
---|
2996 | | -extern int kernel_read_file_from_fd(int, void **, loff_t *, loff_t, |
---|
2997 | | - enum kernel_read_file_id); |
---|
2998 | 2937 | extern ssize_t kernel_read(struct file *, void *, size_t, loff_t *); |
---|
| 2938 | +ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos); |
---|
2999 | 2939 | extern ssize_t kernel_write(struct file *, const void *, size_t, loff_t *); |
---|
3000 | 2940 | extern ssize_t __kernel_write(struct file *, const void *, size_t, loff_t *); |
---|
3001 | 2941 | extern struct file * open_exec(const char *); |
---|
.. | .. |
---|
3024 | 2964 | { |
---|
3025 | 2965 | return !inode->i_nlink || inode_unhashed(inode); |
---|
3026 | 2966 | } |
---|
| 2967 | +extern void d_mark_dontcache(struct inode *inode); |
---|
3027 | 2968 | |
---|
3028 | 2969 | extern struct inode *ilookup5_nowait(struct super_block *sb, |
---|
3029 | 2970 | unsigned long hashval, int (*test)(struct inode *, void *), |
---|
.. | .. |
---|
3043 | 2984 | int (*match)(struct inode *, |
---|
3044 | 2985 | unsigned long, void *), |
---|
3045 | 2986 | void *data); |
---|
| 2987 | +extern struct inode *find_inode_rcu(struct super_block *, unsigned long, |
---|
| 2988 | + int (*)(struct inode *, void *), void *); |
---|
| 2989 | +extern struct inode *find_inode_by_ino_rcu(struct super_block *, unsigned long); |
---|
3046 | 2990 | extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); |
---|
3047 | 2991 | extern int insert_inode_locked(struct inode *); |
---|
3048 | 2992 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
---|
.. | .. |
---|
3054 | 2998 | extern void discard_new_inode(struct inode *); |
---|
3055 | 2999 | extern unsigned int get_next_ino(void); |
---|
3056 | 3000 | extern void evict_inodes(struct super_block *sb); |
---|
| 3001 | + |
---|
| 3002 | +/* |
---|
| 3003 | + * Userspace may rely on the the inode number being non-zero. For example, glibc |
---|
| 3004 | + * simply ignores files with zero i_ino in unlink() and other places. |
---|
| 3005 | + * |
---|
| 3006 | + * As an additional complication, if userspace was compiled with |
---|
| 3007 | + * _FILE_OFFSET_BITS=32 on a 64-bit kernel we'll only end up reading out the |
---|
| 3008 | + * lower 32 bits, so we need to check that those aren't zero explicitly. With |
---|
| 3009 | + * _FILE_OFFSET_BITS=64, this may cause some harmless false-negatives, but |
---|
| 3010 | + * better safe than sorry. |
---|
| 3011 | + */ |
---|
| 3012 | +static inline bool is_zero_ino(ino_t ino) |
---|
| 3013 | +{ |
---|
| 3014 | + return (u32)ino == 0; |
---|
| 3015 | +} |
---|
3057 | 3016 | |
---|
3058 | 3017 | extern void __iget(struct inode * inode); |
---|
3059 | 3018 | extern void iget_failed(struct inode *); |
---|
.. | .. |
---|
3080 | 3039 | |
---|
3081 | 3040 | extern void inode_sb_list_add(struct inode *inode); |
---|
3082 | 3041 | |
---|
3083 | | -#ifdef CONFIG_BLOCK |
---|
3084 | | -extern int bdev_read_only(struct block_device *); |
---|
3085 | | -#endif |
---|
3086 | | -extern int set_blocksize(struct block_device *, int); |
---|
3087 | 3042 | extern int sb_set_blocksize(struct super_block *, int); |
---|
3088 | 3043 | extern int sb_min_blocksize(struct super_block *, int); |
---|
3089 | 3044 | |
---|
3090 | 3045 | extern int generic_file_mmap(struct file *, struct vm_area_struct *); |
---|
3091 | 3046 | extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); |
---|
3092 | 3047 | extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); |
---|
| 3048 | +extern int generic_write_check_limits(struct file *file, loff_t pos, |
---|
| 3049 | + loff_t *count); |
---|
| 3050 | +extern int generic_file_rw_checks(struct file *file_in, struct file *file_out); |
---|
| 3051 | +extern ssize_t generic_file_buffered_read(struct kiocb *iocb, |
---|
| 3052 | + struct iov_iter *to, ssize_t already_read); |
---|
3093 | 3053 | extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); |
---|
3094 | 3054 | extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); |
---|
3095 | 3055 | extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); |
---|
.. | .. |
---|
3100 | 3060 | rwf_t flags); |
---|
3101 | 3061 | ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos, |
---|
3102 | 3062 | rwf_t flags); |
---|
| 3063 | +ssize_t vfs_iocb_iter_read(struct file *file, struct kiocb *iocb, |
---|
| 3064 | + struct iov_iter *iter); |
---|
| 3065 | +ssize_t vfs_iocb_iter_write(struct file *file, struct kiocb *iocb, |
---|
| 3066 | + struct iov_iter *iter); |
---|
3103 | 3067 | |
---|
3104 | 3068 | /* fs/block_dev.c */ |
---|
3105 | 3069 | extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to); |
---|
.. | .. |
---|
3147 | 3111 | DIO_SKIP_HOLES = 0x02, |
---|
3148 | 3112 | }; |
---|
3149 | 3113 | |
---|
3150 | | -void dio_end_io(struct bio *bio); |
---|
3151 | | -void dio_warn_stale_pagecache(struct file *filp); |
---|
3152 | | - |
---|
3153 | 3114 | ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, |
---|
3154 | 3115 | struct block_device *bdev, struct iov_iter *iter, |
---|
3155 | 3116 | get_block_t get_block, |
---|
.. | .. |
---|
3193 | 3154 | wake_up_bit(&inode->i_state, __I_DIO_WAKEUP); |
---|
3194 | 3155 | } |
---|
3195 | 3156 | |
---|
| 3157 | +/* |
---|
| 3158 | + * Warn about a page cache invalidation failure diring a direct I/O write. |
---|
| 3159 | + */ |
---|
| 3160 | +void dio_warn_stale_pagecache(struct file *filp); |
---|
| 3161 | + |
---|
3196 | 3162 | extern void inode_set_flags(struct inode *inode, unsigned int flags, |
---|
3197 | 3163 | unsigned int mask); |
---|
3198 | 3164 | |
---|
.. | .. |
---|
3229 | 3195 | |
---|
3230 | 3196 | extern int iterate_dir(struct file *, struct dir_context *); |
---|
3231 | 3197 | |
---|
3232 | | -extern int vfs_statx(int, const char __user *, int, struct kstat *, u32); |
---|
3233 | | -extern int vfs_statx_fd(unsigned int, struct kstat *, u32, unsigned int); |
---|
| 3198 | +int vfs_fstatat(int dfd, const char __user *filename, struct kstat *stat, |
---|
| 3199 | + int flags); |
---|
| 3200 | +int vfs_fstat(int fd, struct kstat *stat); |
---|
3234 | 3201 | |
---|
3235 | 3202 | static inline int vfs_stat(const char __user *filename, struct kstat *stat) |
---|
3236 | 3203 | { |
---|
3237 | | - return vfs_statx(AT_FDCWD, filename, AT_NO_AUTOMOUNT, |
---|
3238 | | - stat, STATX_BASIC_STATS); |
---|
| 3204 | + return vfs_fstatat(AT_FDCWD, filename, stat, 0); |
---|
3239 | 3205 | } |
---|
3240 | 3206 | static inline int vfs_lstat(const char __user *name, struct kstat *stat) |
---|
3241 | 3207 | { |
---|
3242 | | - return vfs_statx(AT_FDCWD, name, AT_SYMLINK_NOFOLLOW | AT_NO_AUTOMOUNT, |
---|
3243 | | - stat, STATX_BASIC_STATS); |
---|
| 3208 | + return vfs_fstatat(AT_FDCWD, name, stat, AT_SYMLINK_NOFOLLOW); |
---|
3244 | 3209 | } |
---|
3245 | | -static inline int vfs_fstatat(int dfd, const char __user *filename, |
---|
3246 | | - struct kstat *stat, int flags) |
---|
3247 | | -{ |
---|
3248 | | - return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT, |
---|
3249 | | - stat, STATX_BASIC_STATS); |
---|
3250 | | -} |
---|
3251 | | -static inline int vfs_fstat(int fd, struct kstat *stat) |
---|
3252 | | -{ |
---|
3253 | | - return vfs_statx_fd(fd, stat, STATX_BASIC_STATS, 0); |
---|
3254 | | -} |
---|
3255 | | - |
---|
3256 | 3210 | |
---|
3257 | 3211 | extern const char *vfs_get_link(struct dentry *, struct delayed_call *); |
---|
3258 | 3212 | extern int vfs_readlink(struct dentry *, char __user *, int); |
---|
3259 | | - |
---|
3260 | | -extern int __generic_block_fiemap(struct inode *inode, |
---|
3261 | | - struct fiemap_extent_info *fieinfo, |
---|
3262 | | - loff_t start, loff_t len, |
---|
3263 | | - get_block_t *get_block); |
---|
3264 | | -extern int generic_block_fiemap(struct inode *inode, |
---|
3265 | | - struct fiemap_extent_info *fieinfo, u64 start, |
---|
3266 | | - u64 len, get_block_t *get_block); |
---|
3267 | 3213 | |
---|
3268 | 3214 | extern struct file_system_type *get_filesystem(struct file_system_type *fs); |
---|
3269 | 3215 | extern void put_filesystem(struct file_system_type *fs); |
---|
.. | .. |
---|
3291 | 3237 | extern int simple_rmdir(struct inode *, struct dentry *); |
---|
3292 | 3238 | extern int simple_rename(struct inode *, struct dentry *, |
---|
3293 | 3239 | struct inode *, struct dentry *, unsigned int); |
---|
| 3240 | +extern void simple_recursive_removal(struct dentry *, |
---|
| 3241 | + void (*callback)(struct dentry *)); |
---|
3294 | 3242 | extern int noop_fsync(struct file *, loff_t, loff_t, int); |
---|
3295 | 3243 | extern int noop_set_page_dirty(struct page *page); |
---|
3296 | 3244 | extern void noop_invalidatepage(struct page *page, unsigned int offset, |
---|
.. | .. |
---|
3332 | 3280 | |
---|
3333 | 3281 | extern int generic_check_addressable(unsigned, u64); |
---|
3334 | 3282 | |
---|
3335 | | -#ifdef CONFIG_UNICODE |
---|
3336 | | -extern int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str); |
---|
3337 | | -extern int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, |
---|
3338 | | - const char *str, const struct qstr *name); |
---|
3339 | | -extern bool needs_casefold(const struct inode *dir); |
---|
3340 | | -#else |
---|
3341 | | -static inline bool needs_casefold(const struct inode *dir) |
---|
3342 | | -{ |
---|
3343 | | - return 0; |
---|
3344 | | -} |
---|
3345 | | -#endif |
---|
3346 | | -extern void generic_set_encrypted_ci_d_ops(struct inode *dir, |
---|
3347 | | - struct dentry *dentry); |
---|
| 3283 | +extern void generic_set_encrypted_ci_d_ops(struct dentry *dentry); |
---|
3348 | 3284 | |
---|
3349 | 3285 | #ifdef CONFIG_MIGRATION |
---|
3350 | 3286 | extern int buffer_migrate_page(struct address_space *, |
---|
3351 | 3287 | struct page *, struct page *, |
---|
3352 | 3288 | enum migrate_mode); |
---|
| 3289 | +extern int buffer_migrate_page_norefs(struct address_space *, |
---|
| 3290 | + struct page *, struct page *, |
---|
| 3291 | + enum migrate_mode); |
---|
3353 | 3292 | #else |
---|
3354 | 3293 | #define buffer_migrate_page NULL |
---|
| 3294 | +#define buffer_migrate_page_norefs NULL |
---|
3355 | 3295 | #endif |
---|
3356 | 3296 | |
---|
3357 | 3297 | extern int setattr_prepare(struct dentry *, struct iattr *); |
---|
.. | .. |
---|
3360 | 3300 | |
---|
3361 | 3301 | extern int file_update_time(struct file *file); |
---|
3362 | 3302 | |
---|
3363 | | -static inline bool io_is_direct(struct file *filp) |
---|
3364 | | -{ |
---|
3365 | | - return (filp->f_flags & O_DIRECT) || IS_DAX(filp->f_mapping->host); |
---|
3366 | | -} |
---|
3367 | | - |
---|
3368 | | -static inline bool vma_is_dax(struct vm_area_struct *vma) |
---|
| 3303 | +static inline bool vma_is_dax(const struct vm_area_struct *vma) |
---|
3369 | 3304 | { |
---|
3370 | 3305 | return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host); |
---|
3371 | 3306 | } |
---|
.. | .. |
---|
3374 | 3309 | { |
---|
3375 | 3310 | struct inode *inode; |
---|
3376 | 3311 | |
---|
3377 | | - if (!vma->vm_file) |
---|
| 3312 | + if (!IS_ENABLED(CONFIG_FS_DAX) || !vma->vm_file) |
---|
3378 | 3313 | return false; |
---|
3379 | 3314 | if (!vma_is_dax(vma)) |
---|
3380 | 3315 | return false; |
---|
.. | .. |
---|
3389 | 3324 | int res = 0; |
---|
3390 | 3325 | if (file->f_flags & O_APPEND) |
---|
3391 | 3326 | res |= IOCB_APPEND; |
---|
3392 | | - if (io_is_direct(file)) |
---|
| 3327 | + if (file->f_flags & O_DIRECT) |
---|
3393 | 3328 | res |= IOCB_DIRECT; |
---|
3394 | 3329 | if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host)) |
---|
3395 | 3330 | res |= IOCB_DSYNC; |
---|
.. | .. |
---|
3400 | 3335 | |
---|
3401 | 3336 | static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags) |
---|
3402 | 3337 | { |
---|
| 3338 | + int kiocb_flags = 0; |
---|
| 3339 | + |
---|
| 3340 | + /* make sure there's no overlap between RWF and private IOCB flags */ |
---|
| 3341 | + BUILD_BUG_ON((__force int) RWF_SUPPORTED & IOCB_EVENTFD); |
---|
| 3342 | + |
---|
| 3343 | + if (!flags) |
---|
| 3344 | + return 0; |
---|
3403 | 3345 | if (unlikely(flags & ~RWF_SUPPORTED)) |
---|
3404 | 3346 | return -EOPNOTSUPP; |
---|
3405 | 3347 | |
---|
3406 | 3348 | if (flags & RWF_NOWAIT) { |
---|
3407 | 3349 | if (!(ki->ki_filp->f_mode & FMODE_NOWAIT)) |
---|
3408 | 3350 | return -EOPNOTSUPP; |
---|
3409 | | - ki->ki_flags |= IOCB_NOWAIT; |
---|
| 3351 | + kiocb_flags |= IOCB_NOIO; |
---|
3410 | 3352 | } |
---|
3411 | | - if (flags & RWF_HIPRI) |
---|
3412 | | - ki->ki_flags |= IOCB_HIPRI; |
---|
3413 | | - if (flags & RWF_DSYNC) |
---|
3414 | | - ki->ki_flags |= IOCB_DSYNC; |
---|
| 3353 | + kiocb_flags |= (__force int) (flags & RWF_SUPPORTED); |
---|
3415 | 3354 | if (flags & RWF_SYNC) |
---|
3416 | | - ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC); |
---|
3417 | | - if (flags & RWF_APPEND) |
---|
3418 | | - ki->ki_flags |= IOCB_APPEND; |
---|
| 3355 | + kiocb_flags |= IOCB_DSYNC; |
---|
| 3356 | + |
---|
| 3357 | + ki->ki_flags |= kiocb_flags; |
---|
3419 | 3358 | return 0; |
---|
| 3359 | +} |
---|
| 3360 | + |
---|
| 3361 | +static inline rwf_t iocb_to_rw_flags(int ifl, int iocb_mask) |
---|
| 3362 | +{ |
---|
| 3363 | + return ifl & iocb_mask; |
---|
3420 | 3364 | } |
---|
3421 | 3365 | |
---|
3422 | 3366 | static inline ino_t parent_ino(struct dentry *dentry) |
---|
.. | .. |
---|
3441 | 3385 | */ |
---|
3442 | 3386 | struct simple_transaction_argresp { |
---|
3443 | 3387 | ssize_t size; |
---|
3444 | | - char data[0]; |
---|
| 3388 | + char data[]; |
---|
3445 | 3389 | }; |
---|
3446 | 3390 | |
---|
3447 | 3391 | #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp)) |
---|
.. | .. |
---|
3502 | 3446 | |
---|
3503 | 3447 | struct ctl_table; |
---|
3504 | 3448 | int proc_nr_files(struct ctl_table *table, int write, |
---|
3505 | | - void __user *buffer, size_t *lenp, loff_t *ppos); |
---|
| 3449 | + void *buffer, size_t *lenp, loff_t *ppos); |
---|
3506 | 3450 | int proc_nr_dentry(struct ctl_table *table, int write, |
---|
3507 | | - void __user *buffer, size_t *lenp, loff_t *ppos); |
---|
| 3451 | + void *buffer, size_t *lenp, loff_t *ppos); |
---|
3508 | 3452 | int proc_nr_inodes(struct ctl_table *table, int write, |
---|
3509 | | - void __user *buffer, size_t *lenp, loff_t *ppos); |
---|
| 3453 | + void *buffer, size_t *lenp, loff_t *ppos); |
---|
3510 | 3454 | int __init get_filesystem_list(char *buf); |
---|
3511 | 3455 | |
---|
3512 | 3456 | #define __FMODE_EXEC ((__force int) FMODE_EXEC) |
---|
.. | .. |
---|
3590 | 3534 | /* mm/fadvise.c */ |
---|
3591 | 3535 | extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len, |
---|
3592 | 3536 | int advice); |
---|
| 3537 | +extern int generic_fadvise(struct file *file, loff_t offset, loff_t len, |
---|
| 3538 | + int advice); |
---|
3593 | 3539 | |
---|
3594 | 3540 | int vfs_ioc_setflags_prepare(struct inode *inode, unsigned int oldflags, |
---|
3595 | 3541 | unsigned int flags); |
---|