hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/linux/fs.h
....@@ -24,7 +24,6 @@
2424 #include <linux/capability.h>
2525 #include <linux/semaphore.h>
2626 #include <linux/fcntl.h>
27
-#include <linux/fiemap.h>
2827 #include <linux/rculist_bl.h>
2928 #include <linux/atomic.h>
3029 #include <linux/shrinker.h>
....@@ -37,15 +36,20 @@
3736 #include <linux/uuid.h>
3837 #include <linux/errseq.h>
3938 #include <linux/ioprio.h>
39
+#include <linux/fs_types.h>
40
+#include <linux/build_bug.h>
41
+#include <linux/stddef.h>
4042 #include <linux/android_kabi.h>
4143
4244 #include <asm/byteorder.h>
4345 #include <uapi/linux/fs.h>
46
+#include <linux/android_vendor.h>
4447
4548 struct backing_dev_info;
4649 struct bdi_writeback;
4750 struct bio;
4851 struct export_operations;
52
+struct fiemap_extent_info;
4953 struct hd_geometry;
5054 struct iovec;
5155 struct kiocb;
....@@ -64,6 +68,8 @@
6468 struct fscrypt_operations;
6569 struct fsverity_info;
6670 struct fsverity_operations;
71
+struct fs_context;
72
+struct fs_parameter_spec;
6773
6874 extern void __init inode_init(void);
6975 extern void __init inode_init_early(void);
....@@ -163,18 +169,16 @@
163169 #define FMODE_NONOTIFY ((__force fmode_t)0x4000000)
164170
165171 /* 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)
167176
168177 /* File does not contribute to nr_files count */
169
-#define FMODE_NOACCOUNT ((__force fmode_t)0x20000000)
178
+#define FMODE_NOACCOUNT ((__force fmode_t)0x20000000)
170179
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)
178182
179183 /*
180184 * Attribute flags. These should be or-ed together to figure out what
....@@ -285,6 +289,7 @@
285289 struct page;
286290 struct address_space;
287291 struct writeback_control;
292
+struct readahead_control;
288293
289294 /*
290295 * Write life time hint values.
....@@ -299,14 +304,20 @@
299304 WRITE_LIFE_EXTREME = RWH_WRITE_LIFE_EXTREME,
300305 };
301306
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)
310321
311322 struct kiocb {
312323 struct file *ki_filp;
....@@ -320,6 +331,10 @@
320331 int ki_flags;
321332 u16 ki_hint;
322333 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
+ };
323338
324339 randomized_struct_fields_end
325340 };
....@@ -367,6 +382,7 @@
367382 */
368383 int (*readpages)(struct file *filp, struct address_space *mapping,
369384 struct list_head *pages, unsigned nr_pages);
385
+ void (*readahead)(struct readahead_control *);
370386
371387 int (*write_begin)(struct file *, struct address_space *mapping,
372388 loff_t pos, unsigned len, unsigned flags,
....@@ -420,24 +436,45 @@
420436 loff_t pos, unsigned len, unsigned copied,
421437 struct page *page, void *fsdata);
422438
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
+ */
423458 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;
432470 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;
440474 errseq_t wb_err;
475
+ spinlock_t private_lock;
476
+ struct list_head private_list;
477
+ void *private_data;
441478
442479 ANDROID_KABI_RESERVE(1);
443480 ANDROID_KABI_RESERVE(2);
....@@ -449,69 +486,38 @@
449486 * must be enforced here for CRIS, to let the least significant bit
450487 * of struct page's "mapping" pointer be used for PAGE_MAPPING_ANON.
451488 */
452
-struct request_queue;
453489
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
496494
497495 /*
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.
500497 */
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
+}
506502
507503 static inline void i_mmap_lock_write(struct address_space *mapping)
508504 {
509505 down_write(&mapping->i_mmap_rwsem);
510506 }
511507
508
+static inline int i_mmap_trylock_write(struct address_space *mapping)
509
+{
510
+ return down_write_trylock(&mapping->i_mmap_rwsem);
511
+}
512
+
512513 static inline void i_mmap_unlock_write(struct address_space *mapping)
513514 {
514515 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);
515521 }
516522
517523 static inline void i_mmap_lock_read(struct address_space *mapping)
....@@ -524,6 +530,16 @@
524530 up_read(&mapping->i_mmap_rwsem);
525531 }
526532
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
+
527543 /*
528544 * Might pages of this file be mapped into userspace?
529545 */
....@@ -534,7 +550,7 @@
534550
535551 /*
536552 * 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
538554 * marks vma as VM_SHARED if it is shared, and the file was opened for
539555 * writing i.e. vma may be mprotected writable even if now readonly.
540556 *
....@@ -685,10 +701,13 @@
685701 atomic_t i_count;
686702 atomic_t i_dio_count;
687703 atomic_t i_writecount;
688
-#ifdef CONFIG_IMA
704
+#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
689705 atomic_t i_readcount; /* struct files open RO */
690706 #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
+ };
692711 struct file_lock_context *i_flctx;
693712 struct address_space i_data;
694713 struct list_head i_devices;
....@@ -720,6 +739,8 @@
720739 ANDROID_KABI_RESERVE(1);
721740 ANDROID_KABI_RESERVE(2);
722741 } __randomize_layout;
742
+
743
+struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode);
723744
724745 static inline unsigned int i_blocksize(const struct inode *node)
725746 {
....@@ -837,7 +858,7 @@
837858 i_size = inode->i_size;
838859 } while (read_seqcount_retry(&inode->i_size_seqcount, seq));
839860 return i_size;
840
-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
861
+#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
841862 loff_t i_size;
842863
843864 preempt_disable();
....@@ -862,7 +883,7 @@
862883 inode->i_size = i_size;
863884 write_seqcount_end(&inode->i_size_seqcount);
864885 preempt_enable();
865
-#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPT)
886
+#elif BITS_PER_LONG==32 && defined(CONFIG_PREEMPTION)
866887 preempt_disable();
867888 inode->i_size = i_size;
868889 preempt_enable();
....@@ -880,8 +901,6 @@
880901 {
881902 return MAJOR(inode->i_rdev);
882903 }
883
-
884
-extern struct block_device *I_BDEV(struct inode *inode);
885904
886905 struct fown_struct {
887906 rwlock_t lock; /* protects pid, uid, euid fields */
....@@ -952,6 +971,11 @@
952971 #endif /* #ifdef CONFIG_EPOLL */
953972 struct address_space *f_mapping;
954973 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);
955979 } __randomize_layout
956980 __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */
957981
....@@ -970,7 +994,6 @@
970994 #define get_file_rcu_many(x, cnt) \
971995 atomic_long_add_unless(&(x)->f_count, (cnt), 0)
972996 #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)
974997 #define file_count(x) atomic_long_read(&(x)->f_count)
975998
976999 #define MAX_NON_LFS ((1UL<<31) - 1)
....@@ -1018,8 +1041,6 @@
10181041 };
10191042
10201043 struct lock_manager_operations {
1021
- int (*lm_compare_owner)(struct file_lock *, struct file_lock *);
1022
- unsigned long (*lm_owner_key)(struct file_lock *);
10231044 fl_owner_t (*lm_get_owner)(fl_owner_t);
10241045 void (*lm_put_owner)(fl_owner_t);
10251046 void (*lm_notify)(struct file_lock *); /* unblock callback */
....@@ -1027,6 +1048,7 @@
10271048 bool (*lm_break)(struct file_lock *);
10281049 int (*lm_change)(struct file_lock *, int, struct list_head *);
10291050 void (*lm_setup)(struct file_lock *, void **);
1051
+ bool (*lm_breaker_owns_lease)(struct file_lock *);
10301052
10311053 ANDROID_KABI_RESERVE(1);
10321054 ANDROID_KABI_RESERVE(2);
....@@ -1068,10 +1090,15 @@
10681090 * Obviously, the last two criteria only matter for POSIX locks.
10691091 */
10701092 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 */
10721094 struct list_head fl_list; /* link into file_lock_context */
10731095 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
+ */
10751102 fl_owner_t fl_owner;
10761103 unsigned int fl_flags;
10771104 unsigned char fl_type;
....@@ -1095,6 +1122,7 @@
10951122 struct {
10961123 struct list_head link; /* link in AFS vnode's pending_locks list */
10971124 int state; /* state of grant or error if -ve */
1125
+ unsigned int debug_id;
10981126 } afs;
10991127 } fl_u;
11001128
....@@ -1147,7 +1175,7 @@
11471175 extern void locks_release_private(struct file_lock *);
11481176 extern void posix_test_lock(struct file *, struct file_lock *);
11491177 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 *);
11511179 extern int vfs_test_lock(struct file *, struct file_lock *);
11521180 extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
11531181 extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
....@@ -1157,6 +1185,11 @@
11571185 extern int generic_setlease(struct file *, long, struct file_lock **, void **priv);
11581186 extern int vfs_setlease(struct file *, long, struct file_lock **, void **);
11591187 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
+
11601193 struct files_struct;
11611194 extern void show_fd_locks(struct seq_file *f,
11621195 struct file *filp, struct files_struct *files);
....@@ -1237,7 +1270,7 @@
12371270 return -ENOLCK;
12381271 }
12391272
1240
-static inline int posix_unblock_lock(struct file_lock *waiter)
1273
+static inline int locks_delete_block(struct file_lock *waiter)
12411274 {
12421275 return -ENOENT;
12431276 }
....@@ -1354,12 +1387,14 @@
13541387 #define SB_NODIRATIME 2048 /* Do not update directory access times */
13551388 #define SB_SILENT 32768
13561389 #define SB_POSIXACL (1<<16) /* VFS does not apply the umask */
1390
+#define SB_INLINECRYPT (1<<17) /* Use blk-crypto for encrypted files */
13571391 #define SB_KERNMOUNT (1<<22) /* this is a kern_mount call */
13581392 #define SB_I_VERSION (1<<23) /* Update inode I_version field */
13591393 #define SB_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
13601394
13611395 /* These sb flags are internal to the kernel */
13621396 #define SB_SUBMOUNT (1<<26)
1397
+#define SB_FORCE (1<<27)
13631398 #define SB_NOSEC (1<<28)
13641399 #define SB_BORN (1<<29)
13651400 #define SB_ACTIVE (1<<30)
....@@ -1368,7 +1403,7 @@
13681403 /* These flags relate to encoding and casefolding */
13691404 #define SB_ENC_STRICT_MODE_FL (1 << 0)
13701405
1371
-#define sb_has_enc_strict_mode(sb) \
1406
+#define sb_has_strict_encoding(sb) \
13721407 (sb->s_encoding_flags & SB_ENC_STRICT_MODE_FL)
13731408
13741409 /*
....@@ -1385,12 +1420,14 @@
13851420 #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */
13861421 #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */
13871422 #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 */
13891424
13901425 /* sb->s_iflags to limit user namespace mounts */
13911426 #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */
13921427 #define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020
13931428 #define SB_I_UNTRUSTED_MOUNTER 0x00000040
1429
+
1430
+#define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */
13941431
13951432 /* Possible states of 'frozen' field */
13961433 enum {
....@@ -1434,7 +1471,16 @@
14341471 const struct xattr_handler **s_xattr;
14351472 #ifdef CONFIG_FS_ENCRYPTION
14361473 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
+ */
14371480 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
14381484 #endif
14391485 #ifdef CONFIG_FS_VERITY
14401486 const struct fsverity_operations *s_vop;
....@@ -1454,16 +1500,28 @@
14541500
14551501 struct sb_writers s_writers;
14561502
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
+
14571520 char s_id[32]; /* Informational name */
14581521 uuid_t s_uuid; /* UUID */
14591522
1460
- void *s_fs_info; /* Filesystem private info */
14611523 unsigned int s_max_links;
14621524 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;
14671525
14681526 /*
14691527 * The next field is for VFS *only*. No filesystems have any business
....@@ -1475,7 +1533,7 @@
14751533 * Filesystem subtype. If non-empty the filesystem type field
14761534 * in /proc/mounts will be "type.subtype"
14771535 */
1478
- char *s_subtype;
1536
+ const char *s_subtype;
14791537
14801538 const struct dentry_operations *s_d_op; /* default d_op for dentries */
14811539
....@@ -1495,6 +1553,9 @@
14951553 /* Being remounted read-only */
14961554 int s_readonly_remount;
14971555
1556
+ /* per-sb errseq_t for reporting writeback errors via syncfs */
1557
+ errseq_t s_wb_err;
1558
+
14981559 /* AIO completions deferred from interrupt context */
14991560 struct workqueue_struct *s_dio_done_wq;
15001561 struct hlist_head s_pins;
....@@ -1507,11 +1568,12 @@
15071568 struct user_namespace *s_user_ns;
15081569
15091570 /*
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.
15121574 */
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;
15151577 struct rcu_head rcu;
15161578 struct work_struct destroy_work;
15171579
....@@ -1560,15 +1622,30 @@
15601622 inode->i_gid = make_kgid(inode->i_sb->s_user_ns, gid);
15611623 }
15621624
1563
-extern struct timespec64 timespec64_trunc(struct timespec64 t, unsigned gran);
15641625 extern struct timespec64 current_time(struct inode *inode);
15651626
15661627 /*
15671628 * Snapshotting support.
15681629 */
15691630
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
+}
15721649
15731650 #define __sb_writers_acquired(sb, lev) \
15741651 percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_)
....@@ -1632,12 +1709,12 @@
16321709 */
16331710 static inline void sb_start_write(struct super_block *sb)
16341711 {
1635
- __sb_start_write(sb, SB_FREEZE_WRITE, true);
1712
+ __sb_start_write(sb, SB_FREEZE_WRITE);
16361713 }
16371714
1638
-static inline int sb_start_write_trylock(struct super_block *sb)
1715
+static inline bool sb_start_write_trylock(struct super_block *sb)
16391716 {
1640
- return __sb_start_write(sb, SB_FREEZE_WRITE, false);
1717
+ return __sb_start_write_trylock(sb, SB_FREEZE_WRITE);
16411718 }
16421719
16431720 /**
....@@ -1653,15 +1730,15 @@
16531730 *
16541731 * Since page fault freeze protection behaves as a lock, users have to preserve
16551732 * 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
16571734 * handling code implies lock dependency:
16581735 *
1659
- * mmap_sem
1736
+ * mmap_lock
16601737 * -> sb_start_pagefault
16611738 */
16621739 static inline void sb_start_pagefault(struct super_block *sb)
16631740 {
1664
- __sb_start_write(sb, SB_FREEZE_PAGEFAULT, true);
1741
+ __sb_start_write(sb, SB_FREEZE_PAGEFAULT);
16651742 }
16661743
16671744 /*
....@@ -1679,12 +1756,12 @@
16791756 */
16801757 static inline void sb_start_intwrite(struct super_block *sb)
16811758 {
1682
- __sb_start_write(sb, SB_FREEZE_FS, true);
1759
+ __sb_start_write(sb, SB_FREEZE_FS);
16831760 }
16841761
1685
-static inline int sb_start_intwrite_trylock(struct super_block *sb)
1762
+static inline bool sb_start_intwrite_trylock(struct super_block *sb)
16861763 {
1687
- return __sb_start_write(sb, SB_FREEZE_FS, false);
1764
+ return __sb_start_write_trylock(sb, SB_FREEZE_FS);
16881765 }
16891766
16901767
....@@ -1694,22 +1771,18 @@
16941771 * VFS helper functions..
16951772 */
16961773 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);
16981774 extern int vfs_mkdir(struct inode *, struct dentry *, umode_t);
1699
-extern int vfs_mkdir2(struct vfsmount *, struct inode *, struct dentry *, umode_t);
17001775 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);
17021776 extern int vfs_symlink(struct inode *, struct dentry *, const char *);
1703
-extern int vfs_symlink2(struct vfsmount *, struct inode *, struct dentry *, const char *);
17041777 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 **);
17061778 extern int vfs_rmdir(struct inode *, struct dentry *);
1707
-extern int vfs_rmdir2(struct vfsmount *, struct inode *, struct dentry *);
17081779 extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
1709
-extern int vfs_unlink2(struct vfsmount *, struct inode *, struct dentry *, struct inode **);
17101780 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
+}
17131786
17141787 extern struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode,
17151788 int open_flag);
....@@ -1717,11 +1790,19 @@
17171790 int vfs_mkobj(struct dentry *, umode_t,
17181791 int (*f)(struct dentry *, umode_t, void *),
17191792 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);
17231797
17241798 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
17251806
17261807 /*
17271808 * VFS file helper functions.
....@@ -1729,35 +1810,6 @@
17291810 extern void inode_init_owner(struct inode *inode, const struct inode *dir,
17301811 umode_t mode);
17311812 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
17611813
17621814 /*
17631815 * This is the "filldir" function type, used by readdir() to let
....@@ -1773,14 +1825,6 @@
17731825 filldir_t actor;
17741826 loff_t pos;
17751827 };
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
17841828
17851829 /*
17861830 * These flags let !MMU mmap() govern direct device mapping vs immediate
....@@ -1801,6 +1845,33 @@
18011845 #define NOMMU_VMFLAGS \
18021846 (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC)
18031847
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)
18041875
18051876 struct iov_iter;
18061877
....@@ -1811,6 +1882,7 @@
18111882 ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
18121883 ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
18131884 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
1885
+ int (*iopoll)(struct kiocb *kiocb, bool spin);
18141886 int (*iterate) (struct file *, struct dir_context *);
18151887 int (*iterate_shared) (struct file *, struct dir_context *);
18161888 __poll_t (*poll) (struct file *, struct poll_table_struct *);
....@@ -1839,10 +1911,9 @@
18391911 #endif
18401912 ssize_t (*copy_file_range)(struct file *, loff_t, struct file *,
18411913 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);
18461917 int (*fadvise)(struct file *, loff_t, loff_t, int);
18471918
18481919 ANDROID_KABI_RESERVE(1);
....@@ -1855,7 +1926,6 @@
18551926 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
18561927 const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *);
18571928 int (*permission) (struct inode *, int);
1858
- int (*permission2) (struct vfsmount *, struct inode *, int);
18591929 struct posix_acl * (*get_acl)(struct inode *, int);
18601930
18611931 int (*readlink) (struct dentry *, char __user *,int);
....@@ -1870,8 +1940,7 @@
18701940 int (*rename) (struct inode *, struct dentry *,
18711941 struct inode *, struct dentry *, unsigned int);
18721942 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);
18751944 ssize_t (*listxattr) (struct dentry *, char *, size_t);
18761945 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
18771946 u64 len);
....@@ -1905,38 +1974,34 @@
19051974 return file->f_op->mmap(file, vma);
19061975 }
19071976
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 *);
19141977 extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
19151978 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);
19181979 extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *,
19191980 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);
19301994 extern int vfs_dedupe_file_range(struct file *file,
19311995 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);
19351999
19362000
19372001 struct super_operations {
19382002 struct inode *(*alloc_inode)(struct super_block *sb);
19392003 void (*destroy_inode)(struct inode *);
2004
+ void (*free_inode)(struct inode *);
19402005
19412006 void (*dirty_inode) (struct inode *, int flags);
19422007 int (*write_inode) (struct inode *, struct writeback_control *wbc);
....@@ -1950,14 +2015,9 @@
19502015 int (*unfreeze_fs) (struct super_block *);
19512016 int (*statfs) (struct dentry *, struct kstatfs *);
19522017 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 *);
19562018 void (*umount_begin) (struct super_block *);
1957
- void (*umount_end)(struct super_block *sb, int flags);
19582019
19592020 int (*show_options)(struct seq_file *, struct dentry *);
1960
- int (*show_options2)(struct vfsmount *,struct seq_file *, struct dentry *);
19612021 int (*show_devname)(struct seq_file *, struct dentry *);
19622022 int (*show_path)(struct seq_file *, struct dentry *);
19632023 int (*show_stats)(struct seq_file *, struct dentry *);
....@@ -1981,27 +2041,27 @@
19812041 /*
19822042 * Inode flags - they have no relation to superblock flags now
19832043 */
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 */
19972057 #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 */
19992059 #else
2000
-#define S_DAX 0 /* Make all the DAX code disappear */
2060
+#define S_DAX 0 /* Make all the DAX code disappear */
20012061 #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/) */
20052065
20062066 /*
20072067 * Note that nosuid etc flags are inode-specific: setting some file-system
....@@ -2078,7 +2138,19 @@
20782138 .ki_filp = filp,
20792139 .ki_flags = iocb_flags(filp),
20802140 .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,
20822154 };
20832155 }
20842156
....@@ -2136,12 +2208,14 @@
21362208 * I_WB_SWITCH Cgroup bdi_writeback switching in progress. Used to
21372209 * synchronize competing switching instances and to tell
21382210 * 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.
21402212 *
21412213 * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper
21422214 * and work dirs among overlayfs mounts.
21432215 *
21442216 * 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.
21452219 *
21462220 * I_SYNC_QUEUED Inode is queued in b_io or b_more_io writeback lists.
21472221 * Used to detect that mark_inode_dirty() should not move
....@@ -2167,6 +2241,7 @@
21672241 #define I_WB_SWITCH (1 << 13)
21682242 #define I_OVL_INUSE (1 << 14)
21692243 #define I_CREATING (1 << 15)
2244
+#define I_DONTCACHE (1 << 16)
21702245 #define I_SYNC_QUEUED (1 << 17)
21712246
21722247 #define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
....@@ -2210,11 +2285,15 @@
22102285
22112286 extern bool atime_needs_update(const struct path *, struct inode *);
22122287 extern void touch_atime(const struct path *);
2288
+int inode_update_time(struct inode *inode, struct timespec64 *time, int flags);
2289
+
22132290 static inline void file_accessed(struct file *file)
22142291 {
22152292 if (!(file->f_flags & O_NOATIME))
22162293 touch_atime(&file->f_path);
22172294 }
2295
+
2296
+extern int file_modified(struct file *file);
22182297
22192298 int sync_inode(struct inode *inode, struct writeback_control *wbc);
22202299 int sync_inode_metadata(struct inode *inode, int wait);
....@@ -2226,12 +2305,13 @@
22262305 #define FS_BINARY_MOUNTDATA 2
22272306 #define FS_HAS_SUBTYPE 4
22282307 #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 */
22292310 #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;
22302313 struct dentry *(*mount) (struct file_system_type *, int,
22312314 const char *, void *);
2232
- struct dentry *(*mount2) (struct vfsmount *, struct file_system_type *, int,
2233
- const char *, void *);
2234
- void *(*alloc_mnt_data) (void);
22352315 void (*kill_sb) (struct super_block *);
22362316 struct module *owner;
22372317 struct file_system_type * next;
....@@ -2254,21 +2334,9 @@
22542334
22552335 #define MODULE_ALIAS_FS(NAME) MODULE_ALIAS("fs-" NAME)
22562336
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
22612337 extern struct dentry *mount_bdev(struct file_system_type *fs_type,
22622338 int flags, const char *dev_name, void *data,
22632339 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
22722340 extern struct dentry *mount_single(struct file_system_type *fs_type,
22732341 int flags, void *data,
22742342 int (*fill_super)(struct super_block *, void *, int));
....@@ -2277,43 +2345,22 @@
22772345 int (*fill_super)(struct super_block *, void *, int));
22782346 extern struct dentry *mount_subtree(struct vfsmount *mnt, const char *path);
22792347 void generic_shutdown_super(struct super_block *sb);
2280
-#ifdef CONFIG_BLOCK
22812348 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
22882349 void kill_anon_super(struct super_block *sb);
22892350 void kill_litter_super(struct super_block *sb);
22902351 void deactivate_super(struct super_block *sb);
22912352 void deactivate_locked_super(struct super_block *sb);
22922353 int set_anon_super(struct super_block *s, void *data);
2354
+int set_anon_super_fc(struct super_block *s, struct fs_context *fc);
22932355 int get_anon_bdev(dev_t *);
22942356 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 *));
23002360 struct super_block *sget(struct file_system_type *type,
23012361 int (*test)(struct super_block *,void *),
23022362 int (*set)(struct super_block *,void *),
23032363 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
-}
23172364
23182365 /* Alas, no aliases. Too much hassle with bringing module.h everywhere */
23192366 #define fops_get(fops) \
....@@ -2334,8 +2381,7 @@
23342381
23352382 extern int register_filesystem(struct file_system_type *);
23362383 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 *);
23392385 extern void kern_unmount(struct vfsmount *mnt);
23402386 extern int may_umount_tree(struct vfsmount *);
23412387 extern int may_umount(struct vfsmount *);
....@@ -2549,18 +2595,18 @@
25492595 struct audit_names *aname;
25502596 const char iname[];
25512597 };
2598
+static_assert(offsetof(struct filename, iname) % sizeof(long) == 0);
25522599
25532600 extern long vfs_truncate(const struct path *, loff_t);
25542601 extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
25552602 struct file *filp);
2556
-extern int do_truncate2(struct vfsmount *, struct dentry *, loff_t start,
2557
- unsigned int time_attrs, struct file *filp);
25582603 extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
25592604 loff_t len);
25602605 extern long do_sys_open(int dfd, const char __user *filename, int flags,
25612606 umode_t mode);
25622607 extern struct file *file_open_name(struct filename *, int, umode_t);
25632608 extern struct file *filp_open(const char *, int, umode_t);
2609
+extern struct file *filp_open_block(const char *, int, umode_t);
25642610 extern struct file *file_open_root(struct dentry *, struct vfsmount *,
25652611 const char *, int, umode_t);
25662612 extern struct file * dentry_open(const struct path *, int, const struct cred *);
....@@ -2581,10 +2627,6 @@
25812627 int (*open)(struct inode *, struct file *));
25822628 extern int finish_no_open(struct file *file, struct dentry *dentry);
25832629
2584
-/* fs/ioctl.c */
2585
-
2586
-extern int ioctl_preallocate(struct file *filp, void __user *argp);
2587
-
25882630 /* fs/dcache.c */
25892631 extern void __init vfs_caches_init_early(void);
25902632 extern void __init vfs_caches_init(void);
....@@ -2594,93 +2636,16 @@
25942636 #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL)
25952637 #define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
25962638
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
-
26162639 extern struct super_block *blockdev_superblock;
2617
-
26182640 static inline bool sb_is_blkdev_sb(struct super_block *sb)
26192641 {
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;
26312643 }
26322644
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);
26522646 extern int sync_filesystem(struct super_block *);
26532647 extern const struct file_operations def_blk_fops;
26542648 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
26842649
26852650 /* fs/char_dev.c */
26862651 #define CHRDEV_MAJOR_MAX 512
....@@ -2711,37 +2676,18 @@
27112676 __unregister_chrdev(major, 0, 256, name);
27122677 }
27132678
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
-
27292679 extern void init_special_inode(struct inode *, umode_t, dev_t);
27302680
27312681 /* Invalid inode operations -- fs/bad_inode.c */
27322682 extern void make_bad_inode(struct inode *);
27332683 extern bool is_bad_inode(struct inode *);
27342684
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
27432685 unsigned long invalidate_mapping_pages(struct address_space *mapping,
27442686 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);
27452691
27462692 static inline void invalidate_remote_inode(struct inode *inode)
27472693 {
....@@ -2768,7 +2714,6 @@
27682714
27692715 extern bool filemap_range_has_page(struct address_space *, loff_t lstart,
27702716 loff_t lend);
2771
-extern int filemap_write_and_wait(struct address_space *mapping);
27722717 extern int filemap_write_and_wait_range(struct address_space *mapping,
27732718 loff_t lstart, loff_t lend);
27742719 extern int __filemap_fdatawrite_range(struct address_space *mapping,
....@@ -2777,6 +2722,11 @@
27772722 loff_t start, loff_t end);
27782723 extern int filemap_check_errors(struct address_space *mapping);
27792724 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
+}
27802730
27812731 extern int __must_check file_fdatawait_range(struct file *file, loff_t lstart,
27822732 loff_t lend);
....@@ -2811,7 +2761,7 @@
28112761 }
28122762
28132763 /**
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?
28152765 * @mapping: mapping to check for writeback errors
28162766 * @since: previously-sampled errseq_t
28172767 *
....@@ -2838,9 +2788,24 @@
28382788 return errseq_sample(&mapping->wb_err);
28392789 }
28402790
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
+
28412803 extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
28422804 int datasync);
28432805 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);
28442809
28452810 /*
28462811 * Sync the bytes written if this was a synchronous write. Expect ki_pos
....@@ -2862,13 +2827,18 @@
28622827
28632828 extern void emergency_sync(void);
28642829 extern void emergency_remount(void);
2830
+
28652831 #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
+}
28672838 #endif
2839
+
28682840 extern int notify_change(struct dentry *, struct iattr *, struct inode **);
2869
-extern int notify_change2(struct vfsmount *, struct dentry *, struct iattr *, struct inode **);
28702841 extern int inode_permission(struct inode *, int);
2871
-extern int inode_permission2(struct vfsmount *, struct inode *, int);
28722842 extern int generic_permission(struct inode *, int);
28732843 extern int __check_sticky(struct inode *dir, struct inode *inode);
28742844
....@@ -2877,18 +2847,23 @@
28772847 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
28782848 }
28792849
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
+
28802855 static inline void file_start_write(struct file *file)
28812856 {
28822857 if (!S_ISREG(file_inode(file)->i_mode))
28832858 return;
2884
- __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);
2859
+ sb_start_write(file_inode(file)->i_sb);
28852860 }
28862861
28872862 static inline bool file_start_write_trylock(struct file *file)
28882863 {
28892864 if (!S_ISREG(file_inode(file)->i_mode))
28902865 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);
28922867 }
28932868
28942869 static inline void file_end_write(struct file *file)
....@@ -2937,7 +2912,7 @@
29372912 return atomic_read(&inode->i_writecount) > 0;
29382913 }
29392914
2940
-#ifdef CONFIG_IMA
2915
+#if defined(CONFIG_IMA) || defined(CONFIG_FILE_LOCKING)
29412916 static inline void i_readcount_dec(struct inode *inode)
29422917 {
29432918 BUG_ON(!atomic_read(&inode->i_readcount));
....@@ -2959,43 +2934,8 @@
29592934 #endif
29602935 extern int do_pipe_flags(int *, int);
29612936
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);
29982937 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);
29992939 extern ssize_t kernel_write(struct file *, const void *, size_t, loff_t *);
30002940 extern ssize_t __kernel_write(struct file *, const void *, size_t, loff_t *);
30012941 extern struct file * open_exec(const char *);
....@@ -3024,6 +2964,7 @@
30242964 {
30252965 return !inode->i_nlink || inode_unhashed(inode);
30262966 }
2967
+extern void d_mark_dontcache(struct inode *inode);
30272968
30282969 extern struct inode *ilookup5_nowait(struct super_block *sb,
30292970 unsigned long hashval, int (*test)(struct inode *, void *),
....@@ -3043,6 +2984,9 @@
30432984 int (*match)(struct inode *,
30442985 unsigned long, void *),
30452986 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);
30462990 extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *);
30472991 extern int insert_inode_locked(struct inode *);
30482992 #ifdef CONFIG_DEBUG_LOCK_ALLOC
....@@ -3054,6 +2998,21 @@
30542998 extern void discard_new_inode(struct inode *);
30552999 extern unsigned int get_next_ino(void);
30563000 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
+}
30573016
30583017 extern void __iget(struct inode * inode);
30593018 extern void iget_failed(struct inode *);
....@@ -3080,16 +3039,17 @@
30803039
30813040 extern void inode_sb_list_add(struct inode *inode);
30823041
3083
-#ifdef CONFIG_BLOCK
3084
-extern int bdev_read_only(struct block_device *);
3085
-#endif
3086
-extern int set_blocksize(struct block_device *, int);
30873042 extern int sb_set_blocksize(struct super_block *, int);
30883043 extern int sb_min_blocksize(struct super_block *, int);
30893044
30903045 extern int generic_file_mmap(struct file *, struct vm_area_struct *);
30913046 extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
30923047 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);
30933053 extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
30943054 extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
30953055 extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
....@@ -3100,6 +3060,10 @@
31003060 rwf_t flags);
31013061 ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos,
31023062 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);
31033067
31043068 /* fs/block_dev.c */
31053069 extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to);
....@@ -3147,9 +3111,6 @@
31473111 DIO_SKIP_HOLES = 0x02,
31483112 };
31493113
3150
-void dio_end_io(struct bio *bio);
3151
-void dio_warn_stale_pagecache(struct file *filp);
3152
-
31533114 ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode,
31543115 struct block_device *bdev, struct iov_iter *iter,
31553116 get_block_t get_block,
....@@ -3193,6 +3154,11 @@
31933154 wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
31943155 }
31953156
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
+
31963162 extern void inode_set_flags(struct inode *inode, unsigned int flags,
31973163 unsigned int mask);
31983164
....@@ -3229,41 +3195,21 @@
32293195
32303196 extern int iterate_dir(struct file *, struct dir_context *);
32313197
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);
32343201
32353202 static inline int vfs_stat(const char __user *filename, struct kstat *stat)
32363203 {
3237
- return vfs_statx(AT_FDCWD, filename, AT_NO_AUTOMOUNT,
3238
- stat, STATX_BASIC_STATS);
3204
+ return vfs_fstatat(AT_FDCWD, filename, stat, 0);
32393205 }
32403206 static inline int vfs_lstat(const char __user *name, struct kstat *stat)
32413207 {
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);
32443209 }
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
-
32563210
32573211 extern const char *vfs_get_link(struct dentry *, struct delayed_call *);
32583212 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);
32673213
32683214 extern struct file_system_type *get_filesystem(struct file_system_type *fs);
32693215 extern void put_filesystem(struct file_system_type *fs);
....@@ -3291,6 +3237,8 @@
32913237 extern int simple_rmdir(struct inode *, struct dentry *);
32923238 extern int simple_rename(struct inode *, struct dentry *,
32933239 struct inode *, struct dentry *, unsigned int);
3240
+extern void simple_recursive_removal(struct dentry *,
3241
+ void (*callback)(struct dentry *));
32943242 extern int noop_fsync(struct file *, loff_t, loff_t, int);
32953243 extern int noop_set_page_dirty(struct page *page);
32963244 extern void noop_invalidatepage(struct page *page, unsigned int offset,
....@@ -3332,26 +3280,18 @@
33323280
33333281 extern int generic_check_addressable(unsigned, u64);
33343282
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);
33483284
33493285 #ifdef CONFIG_MIGRATION
33503286 extern int buffer_migrate_page(struct address_space *,
33513287 struct page *, struct page *,
33523288 enum migrate_mode);
3289
+extern int buffer_migrate_page_norefs(struct address_space *,
3290
+ struct page *, struct page *,
3291
+ enum migrate_mode);
33533292 #else
33543293 #define buffer_migrate_page NULL
3294
+#define buffer_migrate_page_norefs NULL
33553295 #endif
33563296
33573297 extern int setattr_prepare(struct dentry *, struct iattr *);
....@@ -3360,12 +3300,7 @@
33603300
33613301 extern int file_update_time(struct file *file);
33623302
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)
33693304 {
33703305 return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
33713306 }
....@@ -3374,7 +3309,7 @@
33743309 {
33753310 struct inode *inode;
33763311
3377
- if (!vma->vm_file)
3312
+ if (!IS_ENABLED(CONFIG_FS_DAX) || !vma->vm_file)
33783313 return false;
33793314 if (!vma_is_dax(vma))
33803315 return false;
....@@ -3389,7 +3324,7 @@
33893324 int res = 0;
33903325 if (file->f_flags & O_APPEND)
33913326 res |= IOCB_APPEND;
3392
- if (io_is_direct(file))
3327
+ if (file->f_flags & O_DIRECT)
33933328 res |= IOCB_DIRECT;
33943329 if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host))
33953330 res |= IOCB_DSYNC;
....@@ -3400,23 +3335,32 @@
34003335
34013336 static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags)
34023337 {
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;
34033345 if (unlikely(flags & ~RWF_SUPPORTED))
34043346 return -EOPNOTSUPP;
34053347
34063348 if (flags & RWF_NOWAIT) {
34073349 if (!(ki->ki_filp->f_mode & FMODE_NOWAIT))
34083350 return -EOPNOTSUPP;
3409
- ki->ki_flags |= IOCB_NOWAIT;
3351
+ kiocb_flags |= IOCB_NOIO;
34103352 }
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);
34153354 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;
34193358 return 0;
3359
+}
3360
+
3361
+static inline rwf_t iocb_to_rw_flags(int ifl, int iocb_mask)
3362
+{
3363
+ return ifl & iocb_mask;
34203364 }
34213365
34223366 static inline ino_t parent_ino(struct dentry *dentry)
....@@ -3441,7 +3385,7 @@
34413385 */
34423386 struct simple_transaction_argresp {
34433387 ssize_t size;
3444
- char data[0];
3388
+ char data[];
34453389 };
34463390
34473391 #define SIMPLE_TRANSACTION_LIMIT (PAGE_SIZE - sizeof(struct simple_transaction_argresp))
....@@ -3502,11 +3446,11 @@
35023446
35033447 struct ctl_table;
35043448 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);
35063450 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);
35083452 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);
35103454 int __init get_filesystem_list(char *buf);
35113455
35123456 #define __FMODE_EXEC ((__force int) FMODE_EXEC)
....@@ -3590,6 +3534,8 @@
35903534 /* mm/fadvise.c */
35913535 extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
35923536 int advice);
3537
+extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,
3538
+ int advice);
35933539
35943540 int vfs_ioc_setflags_prepare(struct inode *inode, unsigned int oldflags,
35953541 unsigned int flags);