diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 161 |
1 files changed, 112 insertions, 49 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 42efe13077b6..b4d71b5e1ff2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <asm/byteorder.h> | 34 | #include <asm/byteorder.h> |
35 | #include <uapi/linux/fs.h> | 35 | #include <uapi/linux/fs.h> |
36 | 36 | ||
37 | struct backing_dev_info; | ||
37 | struct export_operations; | 38 | struct export_operations; |
38 | struct hd_geometry; | 39 | struct hd_geometry; |
39 | struct iovec; | 40 | struct iovec; |
@@ -50,6 +51,7 @@ struct swap_info_struct; | |||
50 | struct seq_file; | 51 | struct seq_file; |
51 | struct workqueue_struct; | 52 | struct workqueue_struct; |
52 | struct iov_iter; | 53 | struct iov_iter; |
54 | struct vm_fault; | ||
53 | 55 | ||
54 | extern void __init inode_init(void); | 56 | extern void __init inode_init(void); |
55 | extern void __init inode_init_early(void); | 57 | extern void __init inode_init_early(void); |
@@ -360,8 +362,6 @@ struct address_space_operations { | |||
360 | int (*releasepage) (struct page *, gfp_t); | 362 | int (*releasepage) (struct page *, gfp_t); |
361 | void (*freepage)(struct page *); | 363 | void (*freepage)(struct page *); |
362 | ssize_t (*direct_IO)(int, struct kiocb *, struct iov_iter *iter, loff_t offset); | 364 | ssize_t (*direct_IO)(int, struct kiocb *, struct iov_iter *iter, loff_t offset); |
363 | int (*get_xip_mem)(struct address_space *, pgoff_t, int, | ||
364 | void **, unsigned long *); | ||
365 | /* | 365 | /* |
366 | * migrate the contents of a page to the specified target. If | 366 | * migrate the contents of a page to the specified target. If |
367 | * migrate_mode is MIGRATE_ASYNC, it must not block. | 367 | * migrate_mode is MIGRATE_ASYNC, it must not block. |
@@ -394,14 +394,12 @@ int pagecache_write_end(struct file *, struct address_space *mapping, | |||
394 | loff_t pos, unsigned len, unsigned copied, | 394 | loff_t pos, unsigned len, unsigned copied, |
395 | struct page *page, void *fsdata); | 395 | struct page *page, void *fsdata); |
396 | 396 | ||
397 | struct backing_dev_info; | ||
398 | struct address_space { | 397 | struct address_space { |
399 | struct inode *host; /* owner: inode, block_device */ | 398 | struct inode *host; /* owner: inode, block_device */ |
400 | struct radix_tree_root page_tree; /* radix tree of all pages */ | 399 | struct radix_tree_root page_tree; /* radix tree of all pages */ |
401 | spinlock_t tree_lock; /* and lock protecting it */ | 400 | spinlock_t tree_lock; /* and lock protecting it */ |
402 | atomic_t i_mmap_writable;/* count VM_SHARED mappings */ | 401 | atomic_t i_mmap_writable;/* count VM_SHARED mappings */ |
403 | struct rb_root i_mmap; /* tree of private and shared mappings */ | 402 | struct rb_root i_mmap; /* tree of private and shared mappings */ |
404 | struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ | ||
405 | struct rw_semaphore i_mmap_rwsem; /* protect tree, count, list */ | 403 | struct rw_semaphore i_mmap_rwsem; /* protect tree, count, list */ |
406 | /* Protected by tree_lock together with the radix tree */ | 404 | /* Protected by tree_lock together with the radix tree */ |
407 | unsigned long nrpages; /* number of total pages */ | 405 | unsigned long nrpages; /* number of total pages */ |
@@ -409,7 +407,6 @@ struct address_space { | |||
409 | pgoff_t writeback_index;/* writeback starts here */ | 407 | pgoff_t writeback_index;/* writeback starts here */ |
410 | const struct address_space_operations *a_ops; /* methods */ | 408 | const struct address_space_operations *a_ops; /* methods */ |
411 | unsigned long flags; /* error bits/gfp mask */ | 409 | unsigned long flags; /* error bits/gfp mask */ |
412 | struct backing_dev_info *backing_dev_info; /* device readahead, etc */ | ||
413 | spinlock_t private_lock; /* for use by the address_space */ | 410 | spinlock_t private_lock; /* for use by the address_space */ |
414 | struct list_head private_list; /* ditto */ | 411 | struct list_head private_list; /* ditto */ |
415 | void *private_data; /* ditto */ | 412 | void *private_data; /* ditto */ |
@@ -493,8 +490,7 @@ static inline void i_mmap_unlock_read(struct address_space *mapping) | |||
493 | */ | 490 | */ |
494 | static inline int mapping_mapped(struct address_space *mapping) | 491 | static inline int mapping_mapped(struct address_space *mapping) |
495 | { | 492 | { |
496 | return !RB_EMPTY_ROOT(&mapping->i_mmap) || | 493 | return !RB_EMPTY_ROOT(&mapping->i_mmap); |
497 | !list_empty(&mapping->i_mmap_nonlinear); | ||
498 | } | 494 | } |
499 | 495 | ||
500 | /* | 496 | /* |
@@ -625,7 +621,7 @@ struct inode { | |||
625 | atomic_t i_readcount; /* struct files open RO */ | 621 | atomic_t i_readcount; /* struct files open RO */ |
626 | #endif | 622 | #endif |
627 | const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ | 623 | const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ |
628 | struct file_lock *i_flock; | 624 | struct file_lock_context *i_flctx; |
629 | struct address_space i_data; | 625 | struct address_space i_data; |
630 | struct list_head i_devices; | 626 | struct list_head i_devices; |
631 | union { | 627 | union { |
@@ -875,6 +871,7 @@ static inline struct file *get_file(struct file *f) | |||
875 | #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ | 871 | #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */ |
876 | #define FL_UNLOCK_PENDING 512 /* Lease is being broken */ | 872 | #define FL_UNLOCK_PENDING 512 /* Lease is being broken */ |
877 | #define FL_OFDLCK 1024 /* lock is "owned" by struct file */ | 873 | #define FL_OFDLCK 1024 /* lock is "owned" by struct file */ |
874 | #define FL_LAYOUT 2048 /* outstanding pNFS layout */ | ||
878 | 875 | ||
879 | /* | 876 | /* |
880 | * Special return value from posix_lock_file() and vfs_lock_file() for | 877 | * Special return value from posix_lock_file() and vfs_lock_file() for |
@@ -885,6 +882,8 @@ static inline struct file *get_file(struct file *f) | |||
885 | /* legacy typedef, should eventually be removed */ | 882 | /* legacy typedef, should eventually be removed */ |
886 | typedef void *fl_owner_t; | 883 | typedef void *fl_owner_t; |
887 | 884 | ||
885 | struct file_lock; | ||
886 | |||
888 | struct file_lock_operations { | 887 | struct file_lock_operations { |
889 | void (*fl_copy_lock)(struct file_lock *, struct file_lock *); | 888 | void (*fl_copy_lock)(struct file_lock *, struct file_lock *); |
890 | void (*fl_release_private)(struct file_lock *); | 889 | void (*fl_release_private)(struct file_lock *); |
@@ -898,7 +897,7 @@ struct lock_manager_operations { | |||
898 | void (*lm_notify)(struct file_lock *); /* unblock callback */ | 897 | void (*lm_notify)(struct file_lock *); /* unblock callback */ |
899 | int (*lm_grant)(struct file_lock *, int); | 898 | int (*lm_grant)(struct file_lock *, int); |
900 | bool (*lm_break)(struct file_lock *); | 899 | bool (*lm_break)(struct file_lock *); |
901 | int (*lm_change)(struct file_lock **, int, struct list_head *); | 900 | int (*lm_change)(struct file_lock *, int, struct list_head *); |
902 | void (*lm_setup)(struct file_lock *, void **); | 901 | void (*lm_setup)(struct file_lock *, void **); |
903 | }; | 902 | }; |
904 | 903 | ||
@@ -923,17 +922,17 @@ int locks_in_grace(struct net *); | |||
923 | * FIXME: should we create a separate "struct lock_request" to help distinguish | 922 | * FIXME: should we create a separate "struct lock_request" to help distinguish |
924 | * these two uses? | 923 | * these two uses? |
925 | * | 924 | * |
926 | * The i_flock list is ordered by: | 925 | * The varous i_flctx lists are ordered by: |
927 | * | 926 | * |
928 | * 1) lock type -- FL_LEASEs first, then FL_FLOCK, and finally FL_POSIX | 927 | * 1) lock owner |
929 | * 2) lock owner | 928 | * 2) lock range start |
930 | * 3) lock range start | 929 | * 3) lock range end |
931 | * 4) lock range end | ||
932 | * | 930 | * |
933 | * Obviously, the last two criteria only matter for POSIX locks. | 931 | * Obviously, the last two criteria only matter for POSIX locks. |
934 | */ | 932 | */ |
935 | struct file_lock { | 933 | struct file_lock { |
936 | struct file_lock *fl_next; /* singly linked list for this inode */ | 934 | struct file_lock *fl_next; /* singly linked list for this inode */ |
935 | struct list_head fl_list; /* link into file_lock_context */ | ||
937 | struct hlist_node fl_link; /* node in global lists */ | 936 | struct hlist_node fl_link; /* node in global lists */ |
938 | struct list_head fl_block; /* circular list of blocked processes */ | 937 | struct list_head fl_block; /* circular list of blocked processes */ |
939 | fl_owner_t fl_owner; | 938 | fl_owner_t fl_owner; |
@@ -964,6 +963,13 @@ struct file_lock { | |||
964 | } fl_u; | 963 | } fl_u; |
965 | }; | 964 | }; |
966 | 965 | ||
966 | struct file_lock_context { | ||
967 | spinlock_t flc_lock; | ||
968 | struct list_head flc_flock; | ||
969 | struct list_head flc_posix; | ||
970 | struct list_head flc_lease; | ||
971 | }; | ||
972 | |||
967 | /* The following constant reflects the upper bound of the file/locking space */ | 973 | /* The following constant reflects the upper bound of the file/locking space */ |
968 | #ifndef OFFSET_MAX | 974 | #ifndef OFFSET_MAX |
969 | #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) | 975 | #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) |
@@ -990,6 +996,7 @@ extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); | |||
990 | extern int fcntl_getlease(struct file *filp); | 996 | extern int fcntl_getlease(struct file *filp); |
991 | 997 | ||
992 | /* fs/locks.c */ | 998 | /* fs/locks.c */ |
999 | void locks_free_lock_context(struct file_lock_context *ctx); | ||
993 | void locks_free_lock(struct file_lock *fl); | 1000 | void locks_free_lock(struct file_lock *fl); |
994 | extern void locks_init_lock(struct file_lock *); | 1001 | extern void locks_init_lock(struct file_lock *); |
995 | extern struct file_lock * locks_alloc_lock(void); | 1002 | extern struct file_lock * locks_alloc_lock(void); |
@@ -1010,7 +1017,7 @@ extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int t | |||
1010 | extern void lease_get_mtime(struct inode *, struct timespec *time); | 1017 | extern void lease_get_mtime(struct inode *, struct timespec *time); |
1011 | extern int generic_setlease(struct file *, long, struct file_lock **, void **priv); | 1018 | extern int generic_setlease(struct file *, long, struct file_lock **, void **priv); |
1012 | extern int vfs_setlease(struct file *, long, struct file_lock **, void **); | 1019 | extern int vfs_setlease(struct file *, long, struct file_lock **, void **); |
1013 | extern int lease_modify(struct file_lock **, int, struct list_head *); | 1020 | extern int lease_modify(struct file_lock *, int, struct list_head *); |
1014 | #else /* !CONFIG_FILE_LOCKING */ | 1021 | #else /* !CONFIG_FILE_LOCKING */ |
1015 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, | 1022 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, |
1016 | struct flock __user *user) | 1023 | struct flock __user *user) |
@@ -1047,6 +1054,11 @@ static inline int fcntl_getlease(struct file *filp) | |||
1047 | return F_UNLCK; | 1054 | return F_UNLCK; |
1048 | } | 1055 | } |
1049 | 1056 | ||
1057 | static inline void | ||
1058 | locks_free_lock_context(struct file_lock_context *ctx) | ||
1059 | { | ||
1060 | } | ||
1061 | |||
1050 | static inline void locks_init_lock(struct file_lock *fl) | 1062 | static inline void locks_init_lock(struct file_lock *fl) |
1051 | { | 1063 | { |
1052 | return; | 1064 | return; |
@@ -1137,7 +1149,7 @@ static inline int vfs_setlease(struct file *filp, long arg, | |||
1137 | return -EINVAL; | 1149 | return -EINVAL; |
1138 | } | 1150 | } |
1139 | 1151 | ||
1140 | static inline int lease_modify(struct file_lock **before, int arg, | 1152 | static inline int lease_modify(struct file_lock *fl, int arg, |
1141 | struct list_head *dispose) | 1153 | struct list_head *dispose) |
1142 | { | 1154 | { |
1143 | return -EINVAL; | 1155 | return -EINVAL; |
@@ -1184,8 +1196,6 @@ struct mm_struct; | |||
1184 | #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ | 1196 | #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ |
1185 | #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ | 1197 | #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ |
1186 | 1198 | ||
1187 | extern struct list_head super_blocks; | ||
1188 | extern spinlock_t sb_lock; | ||
1189 | 1199 | ||
1190 | /* Possible states of 'frozen' field */ | 1200 | /* Possible states of 'frozen' field */ |
1191 | enum { | 1201 | enum { |
@@ -1502,6 +1512,26 @@ struct block_device_operations; | |||
1502 | #define HAVE_COMPAT_IOCTL 1 | 1512 | #define HAVE_COMPAT_IOCTL 1 |
1503 | #define HAVE_UNLOCKED_IOCTL 1 | 1513 | #define HAVE_UNLOCKED_IOCTL 1 |
1504 | 1514 | ||
1515 | /* | ||
1516 | * These flags let !MMU mmap() govern direct device mapping vs immediate | ||
1517 | * copying more easily for MAP_PRIVATE, especially for ROM filesystems. | ||
1518 | * | ||
1519 | * NOMMU_MAP_COPY: Copy can be mapped (MAP_PRIVATE) | ||
1520 | * NOMMU_MAP_DIRECT: Can be mapped directly (MAP_SHARED) | ||
1521 | * NOMMU_MAP_READ: Can be mapped for reading | ||
1522 | * NOMMU_MAP_WRITE: Can be mapped for writing | ||
1523 | * NOMMU_MAP_EXEC: Can be mapped for execution | ||
1524 | */ | ||
1525 | #define NOMMU_MAP_COPY 0x00000001 | ||
1526 | #define NOMMU_MAP_DIRECT 0x00000008 | ||
1527 | #define NOMMU_MAP_READ VM_MAYREAD | ||
1528 | #define NOMMU_MAP_WRITE VM_MAYWRITE | ||
1529 | #define NOMMU_MAP_EXEC VM_MAYEXEC | ||
1530 | |||
1531 | #define NOMMU_VMFLAGS \ | ||
1532 | (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC) | ||
1533 | |||
1534 | |||
1505 | struct iov_iter; | 1535 | struct iov_iter; |
1506 | 1536 | ||
1507 | struct file_operations { | 1537 | struct file_operations { |
@@ -1536,6 +1566,9 @@ struct file_operations { | |||
1536 | long (*fallocate)(struct file *file, int mode, loff_t offset, | 1566 | long (*fallocate)(struct file *file, int mode, loff_t offset, |
1537 | loff_t len); | 1567 | loff_t len); |
1538 | void (*show_fdinfo)(struct seq_file *m, struct file *f); | 1568 | void (*show_fdinfo)(struct seq_file *m, struct file *f); |
1569 | #ifndef CONFIG_MMU | ||
1570 | unsigned (*mmap_capabilities)(struct file *); | ||
1571 | #endif | ||
1539 | }; | 1572 | }; |
1540 | 1573 | ||
1541 | struct inode_operations { | 1574 | struct inode_operations { |
@@ -1618,8 +1651,10 @@ struct super_operations { | |||
1618 | struct dquot **(*get_dquots)(struct inode *); | 1651 | struct dquot **(*get_dquots)(struct inode *); |
1619 | #endif | 1652 | #endif |
1620 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); | 1653 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); |
1621 | long (*nr_cached_objects)(struct super_block *, int); | 1654 | long (*nr_cached_objects)(struct super_block *, |
1622 | long (*free_cached_objects)(struct super_block *, long, int); | 1655 | struct shrink_control *); |
1656 | long (*free_cached_objects)(struct super_block *, | ||
1657 | struct shrink_control *); | ||
1623 | }; | 1658 | }; |
1624 | 1659 | ||
1625 | /* | 1660 | /* |
@@ -1638,6 +1673,11 @@ struct super_operations { | |||
1638 | #define S_IMA 1024 /* Inode has an associated IMA struct */ | 1673 | #define S_IMA 1024 /* Inode has an associated IMA struct */ |
1639 | #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ | 1674 | #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ |
1640 | #define S_NOSEC 4096 /* no suid or xattr security attributes */ | 1675 | #define S_NOSEC 4096 /* no suid or xattr security attributes */ |
1676 | #ifdef CONFIG_FS_DAX | ||
1677 | #define S_DAX 8192 /* Direct Access, avoiding the page cache */ | ||
1678 | #else | ||
1679 | #define S_DAX 0 /* Make all the DAX code disappear */ | ||
1680 | #endif | ||
1641 | 1681 | ||
1642 | /* | 1682 | /* |
1643 | * Note that nosuid etc flags are inode-specific: setting some file-system | 1683 | * Note that nosuid etc flags are inode-specific: setting some file-system |
@@ -1675,6 +1715,7 @@ struct super_operations { | |||
1675 | #define IS_IMA(inode) ((inode)->i_flags & S_IMA) | 1715 | #define IS_IMA(inode) ((inode)->i_flags & S_IMA) |
1676 | #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) | 1716 | #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) |
1677 | #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) | 1717 | #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) |
1718 | #define IS_DAX(inode) ((inode)->i_flags & S_DAX) | ||
1678 | 1719 | ||
1679 | #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ | 1720 | #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ |
1680 | (inode)->i_rdev == WHITEOUT_DEV) | 1721 | (inode)->i_rdev == WHITEOUT_DEV) |
@@ -1746,8 +1787,12 @@ struct super_operations { | |||
1746 | #define __I_DIO_WAKEUP 9 | 1787 | #define __I_DIO_WAKEUP 9 |
1747 | #define I_DIO_WAKEUP (1 << I_DIO_WAKEUP) | 1788 | #define I_DIO_WAKEUP (1 << I_DIO_WAKEUP) |
1748 | #define I_LINKABLE (1 << 10) | 1789 | #define I_LINKABLE (1 << 10) |
1790 | #define I_DIRTY_TIME (1 << 11) | ||
1791 | #define __I_DIRTY_TIME_EXPIRED 12 | ||
1792 | #define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) | ||
1749 | 1793 | ||
1750 | #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) | 1794 | #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) |
1795 | #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME) | ||
1751 | 1796 | ||
1752 | extern void __mark_inode_dirty(struct inode *, int); | 1797 | extern void __mark_inode_dirty(struct inode *, int); |
1753 | static inline void mark_inode_dirty(struct inode *inode) | 1798 | static inline void mark_inode_dirty(struct inode *inode) |
@@ -1910,6 +1955,7 @@ extern int current_umask(void); | |||
1910 | 1955 | ||
1911 | extern void ihold(struct inode * inode); | 1956 | extern void ihold(struct inode * inode); |
1912 | extern void iput(struct inode *); | 1957 | extern void iput(struct inode *); |
1958 | extern int generic_update_time(struct inode *, struct timespec *, int); | ||
1913 | 1959 | ||
1914 | static inline struct inode *file_inode(const struct file *f) | 1960 | static inline struct inode *file_inode(const struct file *f) |
1915 | { | 1961 | { |
@@ -1959,7 +2005,7 @@ static inline int locks_verify_truncate(struct inode *inode, | |||
1959 | struct file *filp, | 2005 | struct file *filp, |
1960 | loff_t size) | 2006 | loff_t size) |
1961 | { | 2007 | { |
1962 | if (inode->i_flock && mandatory_lock(inode)) | 2008 | if (inode->i_flctx && mandatory_lock(inode)) |
1963 | return locks_mandatory_area( | 2009 | return locks_mandatory_area( |
1964 | FLOCK_VERIFY_WRITE, inode, filp, | 2010 | FLOCK_VERIFY_WRITE, inode, filp, |
1965 | size < inode->i_size ? size : inode->i_size, | 2011 | size < inode->i_size ? size : inode->i_size, |
@@ -1973,11 +2019,12 @@ static inline int break_lease(struct inode *inode, unsigned int mode) | |||
1973 | { | 2019 | { |
1974 | /* | 2020 | /* |
1975 | * Since this check is lockless, we must ensure that any refcounts | 2021 | * Since this check is lockless, we must ensure that any refcounts |
1976 | * taken are done before checking inode->i_flock. Otherwise, we could | 2022 | * taken are done before checking i_flctx->flc_lease. Otherwise, we |
1977 | * end up racing with tasks trying to set a new lease on this file. | 2023 | * could end up racing with tasks trying to set a new lease on this |
2024 | * file. | ||
1978 | */ | 2025 | */ |
1979 | smp_mb(); | 2026 | smp_mb(); |
1980 | if (inode->i_flock) | 2027 | if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) |
1981 | return __break_lease(inode, mode, FL_LEASE); | 2028 | return __break_lease(inode, mode, FL_LEASE); |
1982 | return 0; | 2029 | return 0; |
1983 | } | 2030 | } |
@@ -1986,11 +2033,12 @@ static inline int break_deleg(struct inode *inode, unsigned int mode) | |||
1986 | { | 2033 | { |
1987 | /* | 2034 | /* |
1988 | * Since this check is lockless, we must ensure that any refcounts | 2035 | * Since this check is lockless, we must ensure that any refcounts |
1989 | * taken are done before checking inode->i_flock. Otherwise, we could | 2036 | * taken are done before checking i_flctx->flc_lease. Otherwise, we |
1990 | * end up racing with tasks trying to set a new lease on this file. | 2037 | * could end up racing with tasks trying to set a new lease on this |
2038 | * file. | ||
1991 | */ | 2039 | */ |
1992 | smp_mb(); | 2040 | smp_mb(); |
1993 | if (inode->i_flock) | 2041 | if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) |
1994 | return __break_lease(inode, mode, FL_DELEG); | 2042 | return __break_lease(inode, mode, FL_DELEG); |
1995 | return 0; | 2043 | return 0; |
1996 | } | 2044 | } |
@@ -2017,6 +2065,16 @@ static inline int break_deleg_wait(struct inode **delegated_inode) | |||
2017 | return ret; | 2065 | return ret; |
2018 | } | 2066 | } |
2019 | 2067 | ||
2068 | static inline int break_layout(struct inode *inode, bool wait) | ||
2069 | { | ||
2070 | smp_mb(); | ||
2071 | if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) | ||
2072 | return __break_lease(inode, | ||
2073 | wait ? O_WRONLY : O_WRONLY | O_NONBLOCK, | ||
2074 | FL_LAYOUT); | ||
2075 | return 0; | ||
2076 | } | ||
2077 | |||
2020 | #else /* !CONFIG_FILE_LOCKING */ | 2078 | #else /* !CONFIG_FILE_LOCKING */ |
2021 | static inline int locks_mandatory_locked(struct file *file) | 2079 | static inline int locks_mandatory_locked(struct file *file) |
2022 | { | 2080 | { |
@@ -2072,6 +2130,11 @@ static inline int break_deleg_wait(struct inode **delegated_inode) | |||
2072 | return 0; | 2130 | return 0; |
2073 | } | 2131 | } |
2074 | 2132 | ||
2133 | static inline int break_layout(struct inode *inode, bool wait) | ||
2134 | { | ||
2135 | return 0; | ||
2136 | } | ||
2137 | |||
2075 | #endif /* CONFIG_FILE_LOCKING */ | 2138 | #endif /* CONFIG_FILE_LOCKING */ |
2076 | 2139 | ||
2077 | /* fs/open.c */ | 2140 | /* fs/open.c */ |
@@ -2080,6 +2143,7 @@ struct filename { | |||
2080 | const char *name; /* pointer to actual string */ | 2143 | const char *name; /* pointer to actual string */ |
2081 | const __user char *uptr; /* original userland pointer */ | 2144 | const __user char *uptr; /* original userland pointer */ |
2082 | struct audit_names *aname; | 2145 | struct audit_names *aname; |
2146 | int refcnt; | ||
2083 | bool separate; /* should "name" be freed? */ | 2147 | bool separate; /* should "name" be freed? */ |
2084 | }; | 2148 | }; |
2085 | 2149 | ||
@@ -2101,6 +2165,7 @@ extern int filp_close(struct file *, fl_owner_t id); | |||
2101 | extern struct filename *getname_flags(const char __user *, int, int *); | 2165 | extern struct filename *getname_flags(const char __user *, int, int *); |
2102 | extern struct filename *getname(const char __user *); | 2166 | extern struct filename *getname(const char __user *); |
2103 | extern struct filename *getname_kernel(const char *); | 2167 | extern struct filename *getname_kernel(const char *); |
2168 | extern void putname(struct filename *name); | ||
2104 | 2169 | ||
2105 | enum { | 2170 | enum { |
2106 | FILE_CREATED = 1, | 2171 | FILE_CREATED = 1, |
@@ -2121,15 +2186,8 @@ extern void __init vfs_caches_init(unsigned long); | |||
2121 | 2186 | ||
2122 | extern struct kmem_cache *names_cachep; | 2187 | extern struct kmem_cache *names_cachep; |
2123 | 2188 | ||
2124 | extern void final_putname(struct filename *name); | ||
2125 | |||
2126 | #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) | 2189 | #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) |
2127 | #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) | 2190 | #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) |
2128 | #ifndef CONFIG_AUDITSYSCALL | ||
2129 | #define putname(name) final_putname(name) | ||
2130 | #else | ||
2131 | extern void putname(struct filename *name); | ||
2132 | #endif | ||
2133 | 2191 | ||
2134 | #ifdef CONFIG_BLOCK | 2192 | #ifdef CONFIG_BLOCK |
2135 | extern int register_blkdev(unsigned int, const char *); | 2193 | extern int register_blkdev(unsigned int, const char *); |
@@ -2436,6 +2494,11 @@ extern struct inode *ilookup(struct super_block *sb, unsigned long ino); | |||
2436 | 2494 | ||
2437 | extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *); | 2495 | extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *); |
2438 | extern struct inode * iget_locked(struct super_block *, unsigned long); | 2496 | extern struct inode * iget_locked(struct super_block *, unsigned long); |
2497 | extern struct inode *find_inode_nowait(struct super_block *, | ||
2498 | unsigned long, | ||
2499 | int (*match)(struct inode *, | ||
2500 | unsigned long, void *), | ||
2501 | void *data); | ||
2439 | extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); | 2502 | extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); |
2440 | extern int insert_inode_locked(struct inode *); | 2503 | extern int insert_inode_locked(struct inode *); |
2441 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 2504 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
@@ -2481,8 +2544,6 @@ extern int sb_min_blocksize(struct super_block *, int); | |||
2481 | 2544 | ||
2482 | extern int generic_file_mmap(struct file *, struct vm_area_struct *); | 2545 | extern int generic_file_mmap(struct file *, struct vm_area_struct *); |
2483 | extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); | 2546 | extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); |
2484 | extern int generic_file_remap_pages(struct vm_area_struct *, unsigned long addr, | ||
2485 | unsigned long size, pgoff_t pgoff); | ||
2486 | int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk); | 2547 | int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk); |
2487 | extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); | 2548 | extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); |
2488 | extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); | 2549 | extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); |
@@ -2494,6 +2555,9 @@ extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t l | |||
2494 | extern ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos); | 2555 | extern ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos); |
2495 | extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); | 2556 | extern ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); |
2496 | 2557 | ||
2558 | ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos); | ||
2559 | ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos); | ||
2560 | |||
2497 | /* fs/block_dev.c */ | 2561 | /* fs/block_dev.c */ |
2498 | extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to); | 2562 | extern ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to); |
2499 | extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); | 2563 | extern ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from); |
@@ -2527,19 +2591,13 @@ extern loff_t fixed_size_llseek(struct file *file, loff_t offset, | |||
2527 | extern int generic_file_open(struct inode * inode, struct file * filp); | 2591 | extern int generic_file_open(struct inode * inode, struct file * filp); |
2528 | extern int nonseekable_open(struct inode * inode, struct file * filp); | 2592 | extern int nonseekable_open(struct inode * inode, struct file * filp); |
2529 | 2593 | ||
2530 | #ifdef CONFIG_FS_XIP | 2594 | ssize_t dax_do_io(int rw, struct kiocb *, struct inode *, struct iov_iter *, |
2531 | extern ssize_t xip_file_read(struct file *filp, char __user *buf, size_t len, | 2595 | loff_t, get_block_t, dio_iodone_t, int flags); |
2532 | loff_t *ppos); | 2596 | int dax_clear_blocks(struct inode *, sector_t block, long size); |
2533 | extern int xip_file_mmap(struct file * file, struct vm_area_struct * vma); | 2597 | int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t); |
2534 | extern ssize_t xip_file_write(struct file *filp, const char __user *buf, | 2598 | int dax_truncate_page(struct inode *, loff_t from, get_block_t); |
2535 | size_t len, loff_t *ppos); | 2599 | int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t); |
2536 | extern int xip_truncate_page(struct address_space *mapping, loff_t from); | 2600 | #define dax_mkwrite(vma, vmf, gb) dax_fault(vma, vmf, gb) |
2537 | #else | ||
2538 | static inline int xip_truncate_page(struct address_space *mapping, loff_t from) | ||
2539 | { | ||
2540 | return 0; | ||
2541 | } | ||
2542 | #endif | ||
2543 | 2601 | ||
2544 | #ifdef CONFIG_BLOCK | 2602 | #ifdef CONFIG_BLOCK |
2545 | typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode, | 2603 | typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode, |
@@ -2696,6 +2754,11 @@ extern int generic_show_options(struct seq_file *m, struct dentry *root); | |||
2696 | extern void save_mount_options(struct super_block *sb, char *options); | 2754 | extern void save_mount_options(struct super_block *sb, char *options); |
2697 | extern void replace_mount_options(struct super_block *sb, char *options); | 2755 | extern void replace_mount_options(struct super_block *sb, char *options); |
2698 | 2756 | ||
2757 | static inline bool io_is_direct(struct file *filp) | ||
2758 | { | ||
2759 | return (filp->f_flags & O_DIRECT) || IS_DAX(file_inode(filp)); | ||
2760 | } | ||
2761 | |||
2699 | static inline ino_t parent_ino(struct dentry *dentry) | 2762 | static inline ino_t parent_ino(struct dentry *dentry) |
2700 | { | 2763 | { |
2701 | ino_t res; | 2764 | ino_t res; |