diff options
Diffstat (limited to 'include/linux/fs.h')
| -rw-r--r-- | include/linux/fs.h | 144 |
1 files changed, 101 insertions, 43 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index f90c0282c114..ed5a0900b94d 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); |
| @@ -135,7 +137,7 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset, | |||
| 135 | #define FMODE_CAN_WRITE ((__force fmode_t)0x40000) | 137 | #define FMODE_CAN_WRITE ((__force fmode_t)0x40000) |
| 136 | 138 | ||
| 137 | /* File was opened by fanotify and shouldn't generate fanotify events */ | 139 | /* File was opened by fanotify and shouldn't generate fanotify events */ |
| 138 | #define FMODE_NONOTIFY ((__force fmode_t)0x1000000) | 140 | #define FMODE_NONOTIFY ((__force fmode_t)0x4000000) |
| 139 | 141 | ||
| 140 | /* | 142 | /* |
| 141 | * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector | 143 | * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector |
| @@ -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,16 @@ 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 | int flc_flock_cnt; | ||
| 972 | int flc_posix_cnt; | ||
| 973 | int flc_lease_cnt; | ||
| 974 | }; | ||
| 975 | |||
| 967 | /* The following constant reflects the upper bound of the file/locking space */ | 976 | /* The following constant reflects the upper bound of the file/locking space */ |
| 968 | #ifndef OFFSET_MAX | 977 | #ifndef OFFSET_MAX |
| 969 | #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) | 978 | #define INT_LIMIT(x) (~((x)1 << (sizeof(x)*8 - 1))) |
| @@ -990,6 +999,7 @@ extern int fcntl_setlease(unsigned int fd, struct file *filp, long arg); | |||
| 990 | extern int fcntl_getlease(struct file *filp); | 999 | extern int fcntl_getlease(struct file *filp); |
| 991 | 1000 | ||
| 992 | /* fs/locks.c */ | 1001 | /* fs/locks.c */ |
| 1002 | void locks_free_lock_context(struct file_lock_context *ctx); | ||
| 993 | void locks_free_lock(struct file_lock *fl); | 1003 | void locks_free_lock(struct file_lock *fl); |
| 994 | extern void locks_init_lock(struct file_lock *); | 1004 | extern void locks_init_lock(struct file_lock *); |
| 995 | extern struct file_lock * locks_alloc_lock(void); | 1005 | extern struct file_lock * locks_alloc_lock(void); |
| @@ -1010,7 +1020,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); | 1020 | extern void lease_get_mtime(struct inode *, struct timespec *time); |
| 1011 | extern int generic_setlease(struct file *, long, struct file_lock **, void **priv); | 1021 | extern int generic_setlease(struct file *, long, struct file_lock **, void **priv); |
| 1012 | extern int vfs_setlease(struct file *, long, struct file_lock **, void **); | 1022 | extern int vfs_setlease(struct file *, long, struct file_lock **, void **); |
| 1013 | extern int lease_modify(struct file_lock **, int, struct list_head *); | 1023 | extern int lease_modify(struct file_lock *, int, struct list_head *); |
| 1014 | #else /* !CONFIG_FILE_LOCKING */ | 1024 | #else /* !CONFIG_FILE_LOCKING */ |
| 1015 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, | 1025 | static inline int fcntl_getlk(struct file *file, unsigned int cmd, |
| 1016 | struct flock __user *user) | 1026 | struct flock __user *user) |
| @@ -1047,6 +1057,11 @@ static inline int fcntl_getlease(struct file *filp) | |||
| 1047 | return F_UNLCK; | 1057 | return F_UNLCK; |
| 1048 | } | 1058 | } |
| 1049 | 1059 | ||
| 1060 | static inline void | ||
| 1061 | locks_free_lock_context(struct file_lock_context *ctx) | ||
| 1062 | { | ||
| 1063 | } | ||
| 1064 | |||
| 1050 | static inline void locks_init_lock(struct file_lock *fl) | 1065 | static inline void locks_init_lock(struct file_lock *fl) |
| 1051 | { | 1066 | { |
| 1052 | return; | 1067 | return; |
| @@ -1137,7 +1152,7 @@ static inline int vfs_setlease(struct file *filp, long arg, | |||
| 1137 | return -EINVAL; | 1152 | return -EINVAL; |
| 1138 | } | 1153 | } |
| 1139 | 1154 | ||
| 1140 | static inline int lease_modify(struct file_lock **before, int arg, | 1155 | static inline int lease_modify(struct file_lock *fl, int arg, |
| 1141 | struct list_head *dispose) | 1156 | struct list_head *dispose) |
| 1142 | { | 1157 | { |
| 1143 | return -EINVAL; | 1158 | return -EINVAL; |
| @@ -1184,8 +1199,6 @@ struct mm_struct; | |||
| 1184 | #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ | 1199 | #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ |
| 1185 | #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ | 1200 | #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ |
| 1186 | 1201 | ||
| 1187 | extern struct list_head super_blocks; | ||
| 1188 | extern spinlock_t sb_lock; | ||
| 1189 | 1202 | ||
| 1190 | /* Possible states of 'frozen' field */ | 1203 | /* Possible states of 'frozen' field */ |
| 1191 | enum { | 1204 | enum { |
| @@ -1502,6 +1515,26 @@ struct block_device_operations; | |||
| 1502 | #define HAVE_COMPAT_IOCTL 1 | 1515 | #define HAVE_COMPAT_IOCTL 1 |
| 1503 | #define HAVE_UNLOCKED_IOCTL 1 | 1516 | #define HAVE_UNLOCKED_IOCTL 1 |
| 1504 | 1517 | ||
| 1518 | /* | ||
| 1519 | * These flags let !MMU mmap() govern direct device mapping vs immediate | ||
| 1520 | * copying more easily for MAP_PRIVATE, especially for ROM filesystems. | ||
| 1521 | * | ||
| 1522 | * NOMMU_MAP_COPY: Copy can be mapped (MAP_PRIVATE) | ||
| 1523 | * NOMMU_MAP_DIRECT: Can be mapped directly (MAP_SHARED) | ||
| 1524 | * NOMMU_MAP_READ: Can be mapped for reading | ||
| 1525 | * NOMMU_MAP_WRITE: Can be mapped for writing | ||
| 1526 | * NOMMU_MAP_EXEC: Can be mapped for execution | ||
| 1527 | */ | ||
| 1528 | #define NOMMU_MAP_COPY 0x00000001 | ||
| 1529 | #define NOMMU_MAP_DIRECT 0x00000008 | ||
| 1530 | #define NOMMU_MAP_READ VM_MAYREAD | ||
| 1531 | #define NOMMU_MAP_WRITE VM_MAYWRITE | ||
| 1532 | #define NOMMU_MAP_EXEC VM_MAYEXEC | ||
| 1533 | |||
| 1534 | #define NOMMU_VMFLAGS \ | ||
| 1535 | (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC) | ||
| 1536 | |||
| 1537 | |||
| 1505 | struct iov_iter; | 1538 | struct iov_iter; |
| 1506 | 1539 | ||
| 1507 | struct file_operations { | 1540 | struct file_operations { |
| @@ -1536,6 +1569,9 @@ struct file_operations { | |||
| 1536 | long (*fallocate)(struct file *file, int mode, loff_t offset, | 1569 | long (*fallocate)(struct file *file, int mode, loff_t offset, |
| 1537 | loff_t len); | 1570 | loff_t len); |
| 1538 | void (*show_fdinfo)(struct seq_file *m, struct file *f); | 1571 | void (*show_fdinfo)(struct seq_file *m, struct file *f); |
| 1572 | #ifndef CONFIG_MMU | ||
| 1573 | unsigned (*mmap_capabilities)(struct file *); | ||
| 1574 | #endif | ||
| 1539 | }; | 1575 | }; |
| 1540 | 1576 | ||
| 1541 | struct inode_operations { | 1577 | struct inode_operations { |
| @@ -1618,8 +1654,10 @@ struct super_operations { | |||
| 1618 | struct dquot **(*get_dquots)(struct inode *); | 1654 | struct dquot **(*get_dquots)(struct inode *); |
| 1619 | #endif | 1655 | #endif |
| 1620 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); | 1656 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); |
| 1621 | long (*nr_cached_objects)(struct super_block *, int); | 1657 | long (*nr_cached_objects)(struct super_block *, |
| 1622 | long (*free_cached_objects)(struct super_block *, long, int); | 1658 | struct shrink_control *); |
| 1659 | long (*free_cached_objects)(struct super_block *, | ||
| 1660 | struct shrink_control *); | ||
| 1623 | }; | 1661 | }; |
| 1624 | 1662 | ||
| 1625 | /* | 1663 | /* |
| @@ -1638,6 +1676,11 @@ struct super_operations { | |||
| 1638 | #define S_IMA 1024 /* Inode has an associated IMA struct */ | 1676 | #define S_IMA 1024 /* Inode has an associated IMA struct */ |
| 1639 | #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ | 1677 | #define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */ |
| 1640 | #define S_NOSEC 4096 /* no suid or xattr security attributes */ | 1678 | #define S_NOSEC 4096 /* no suid or xattr security attributes */ |
| 1679 | #ifdef CONFIG_FS_DAX | ||
| 1680 | #define S_DAX 8192 /* Direct Access, avoiding the page cache */ | ||
| 1681 | #else | ||
| 1682 | #define S_DAX 0 /* Make all the DAX code disappear */ | ||
| 1683 | #endif | ||
| 1641 | 1684 | ||
| 1642 | /* | 1685 | /* |
| 1643 | * Note that nosuid etc flags are inode-specific: setting some file-system | 1686 | * Note that nosuid etc flags are inode-specific: setting some file-system |
| @@ -1675,6 +1718,7 @@ struct super_operations { | |||
| 1675 | #define IS_IMA(inode) ((inode)->i_flags & S_IMA) | 1718 | #define IS_IMA(inode) ((inode)->i_flags & S_IMA) |
| 1676 | #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) | 1719 | #define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT) |
| 1677 | #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) | 1720 | #define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC) |
| 1721 | #define IS_DAX(inode) ((inode)->i_flags & S_DAX) | ||
| 1678 | 1722 | ||
| 1679 | #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ | 1723 | #define IS_WHITEOUT(inode) (S_ISCHR(inode->i_mode) && \ |
| 1680 | (inode)->i_rdev == WHITEOUT_DEV) | 1724 | (inode)->i_rdev == WHITEOUT_DEV) |
| @@ -1959,7 +2003,7 @@ static inline int locks_verify_truncate(struct inode *inode, | |||
| 1959 | struct file *filp, | 2003 | struct file *filp, |
| 1960 | loff_t size) | 2004 | loff_t size) |
| 1961 | { | 2005 | { |
| 1962 | if (inode->i_flock && mandatory_lock(inode)) | 2006 | if (inode->i_flctx && mandatory_lock(inode)) |
| 1963 | return locks_mandatory_area( | 2007 | return locks_mandatory_area( |
| 1964 | FLOCK_VERIFY_WRITE, inode, filp, | 2008 | FLOCK_VERIFY_WRITE, inode, filp, |
| 1965 | size < inode->i_size ? size : inode->i_size, | 2009 | size < inode->i_size ? size : inode->i_size, |
| @@ -1973,11 +2017,12 @@ static inline int break_lease(struct inode *inode, unsigned int mode) | |||
| 1973 | { | 2017 | { |
| 1974 | /* | 2018 | /* |
| 1975 | * Since this check is lockless, we must ensure that any refcounts | 2019 | * Since this check is lockless, we must ensure that any refcounts |
| 1976 | * taken are done before checking inode->i_flock. Otherwise, we could | 2020 | * 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. | 2021 | * could end up racing with tasks trying to set a new lease on this |
| 2022 | * file. | ||
| 1978 | */ | 2023 | */ |
| 1979 | smp_mb(); | 2024 | smp_mb(); |
| 1980 | if (inode->i_flock) | 2025 | if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) |
| 1981 | return __break_lease(inode, mode, FL_LEASE); | 2026 | return __break_lease(inode, mode, FL_LEASE); |
| 1982 | return 0; | 2027 | return 0; |
| 1983 | } | 2028 | } |
| @@ -1986,11 +2031,12 @@ static inline int break_deleg(struct inode *inode, unsigned int mode) | |||
| 1986 | { | 2031 | { |
| 1987 | /* | 2032 | /* |
| 1988 | * Since this check is lockless, we must ensure that any refcounts | 2033 | * Since this check is lockless, we must ensure that any refcounts |
| 1989 | * taken are done before checking inode->i_flock. Otherwise, we could | 2034 | * 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. | 2035 | * could end up racing with tasks trying to set a new lease on this |
| 2036 | * file. | ||
| 1991 | */ | 2037 | */ |
| 1992 | smp_mb(); | 2038 | smp_mb(); |
| 1993 | if (inode->i_flock) | 2039 | if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) |
| 1994 | return __break_lease(inode, mode, FL_DELEG); | 2040 | return __break_lease(inode, mode, FL_DELEG); |
| 1995 | return 0; | 2041 | return 0; |
| 1996 | } | 2042 | } |
| @@ -2017,6 +2063,16 @@ static inline int break_deleg_wait(struct inode **delegated_inode) | |||
| 2017 | return ret; | 2063 | return ret; |
| 2018 | } | 2064 | } |
| 2019 | 2065 | ||
| 2066 | static inline int break_layout(struct inode *inode, bool wait) | ||
| 2067 | { | ||
| 2068 | smp_mb(); | ||
| 2069 | if (inode->i_flctx && !list_empty_careful(&inode->i_flctx->flc_lease)) | ||
| 2070 | return __break_lease(inode, | ||
| 2071 | wait ? O_WRONLY : O_WRONLY | O_NONBLOCK, | ||
| 2072 | FL_LAYOUT); | ||
| 2073 | return 0; | ||
| 2074 | } | ||
| 2075 | |||
| 2020 | #else /* !CONFIG_FILE_LOCKING */ | 2076 | #else /* !CONFIG_FILE_LOCKING */ |
| 2021 | static inline int locks_mandatory_locked(struct file *file) | 2077 | static inline int locks_mandatory_locked(struct file *file) |
| 2022 | { | 2078 | { |
| @@ -2072,6 +2128,11 @@ static inline int break_deleg_wait(struct inode **delegated_inode) | |||
| 2072 | return 0; | 2128 | return 0; |
| 2073 | } | 2129 | } |
| 2074 | 2130 | ||
| 2131 | static inline int break_layout(struct inode *inode, bool wait) | ||
| 2132 | { | ||
| 2133 | return 0; | ||
| 2134 | } | ||
| 2135 | |||
| 2075 | #endif /* CONFIG_FILE_LOCKING */ | 2136 | #endif /* CONFIG_FILE_LOCKING */ |
| 2076 | 2137 | ||
| 2077 | /* fs/open.c */ | 2138 | /* fs/open.c */ |
| @@ -2481,8 +2542,6 @@ extern int sb_min_blocksize(struct super_block *, int); | |||
| 2481 | 2542 | ||
| 2482 | extern int generic_file_mmap(struct file *, struct vm_area_struct *); | 2543 | extern int generic_file_mmap(struct file *, struct vm_area_struct *); |
| 2483 | extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); | 2544 | 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); | 2545 | 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 *); | 2546 | 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 *); | 2547 | extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); |
| @@ -2527,19 +2586,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); | 2586 | extern int generic_file_open(struct inode * inode, struct file * filp); |
| 2528 | extern int nonseekable_open(struct inode * inode, struct file * filp); | 2587 | extern int nonseekable_open(struct inode * inode, struct file * filp); |
| 2529 | 2588 | ||
| 2530 | #ifdef CONFIG_FS_XIP | 2589 | 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, | 2590 | loff_t, get_block_t, dio_iodone_t, int flags); |
| 2532 | loff_t *ppos); | 2591 | 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); | 2592 | 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, | 2593 | int dax_truncate_page(struct inode *, loff_t from, get_block_t); |
| 2535 | size_t len, loff_t *ppos); | 2594 | 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); | 2595 | #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 | 2596 | ||
| 2544 | #ifdef CONFIG_BLOCK | 2597 | #ifdef CONFIG_BLOCK |
| 2545 | typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode, | 2598 | typedef void (dio_submit_t)(int rw, struct bio *bio, struct inode *inode, |
| @@ -2696,6 +2749,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); | 2749 | extern void save_mount_options(struct super_block *sb, char *options); |
| 2697 | extern void replace_mount_options(struct super_block *sb, char *options); | 2750 | extern void replace_mount_options(struct super_block *sb, char *options); |
| 2698 | 2751 | ||
| 2752 | static inline bool io_is_direct(struct file *filp) | ||
| 2753 | { | ||
| 2754 | return (filp->f_flags & O_DIRECT) || IS_DAX(file_inode(filp)); | ||
| 2755 | } | ||
| 2756 | |||
| 2699 | static inline ino_t parent_ino(struct dentry *dentry) | 2757 | static inline ino_t parent_ino(struct dentry *dentry) |
| 2700 | { | 2758 | { |
| 2701 | ino_t res; | 2759 | ino_t res; |
