diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 90 |
1 files changed, 68 insertions, 22 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 4f34ff6e5558..7b7b507ffa1c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/limits.h> | 9 | #include <linux/limits.h> |
10 | #include <linux/ioctl.h> | 10 | #include <linux/ioctl.h> |
11 | #include <linux/blk_types.h> | 11 | #include <linux/blk_types.h> |
12 | #include <linux/types.h> | ||
12 | 13 | ||
13 | /* | 14 | /* |
14 | * It's silly to have NR_OPEN bigger than NR_FILE, but you can change | 15 | * It's silly to have NR_OPEN bigger than NR_FILE, but you can change |
@@ -32,11 +33,17 @@ | |||
32 | #define SEEK_END 2 /* seek relative to end of file */ | 33 | #define SEEK_END 2 /* seek relative to end of file */ |
33 | #define SEEK_MAX SEEK_END | 34 | #define SEEK_MAX SEEK_END |
34 | 35 | ||
36 | struct fstrim_range { | ||
37 | uint64_t start; | ||
38 | uint64_t len; | ||
39 | uint64_t minlen; | ||
40 | }; | ||
41 | |||
35 | /* And dynamically-tunable limits and defaults: */ | 42 | /* And dynamically-tunable limits and defaults: */ |
36 | struct files_stat_struct { | 43 | struct files_stat_struct { |
37 | int nr_files; /* read only */ | 44 | unsigned long nr_files; /* read only */ |
38 | int nr_free_files; /* read only */ | 45 | unsigned long nr_free_files; /* read only */ |
39 | int max_files; /* tunable */ | 46 | unsigned long max_files; /* tunable */ |
40 | }; | 47 | }; |
41 | 48 | ||
42 | struct inodes_stat_t { | 49 | struct inodes_stat_t { |
@@ -92,6 +99,9 @@ struct inodes_stat_t { | |||
92 | /* Expect random access pattern */ | 99 | /* Expect random access pattern */ |
93 | #define FMODE_RANDOM ((__force fmode_t)0x1000) | 100 | #define FMODE_RANDOM ((__force fmode_t)0x1000) |
94 | 101 | ||
102 | /* File is huge (eg. /dev/kmem): treat loff_t as unsigned */ | ||
103 | #define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000) | ||
104 | |||
95 | /* File was opened by fanotify and shouldn't generate fanotify events */ | 105 | /* File was opened by fanotify and shouldn't generate fanotify events */ |
96 | #define FMODE_NONOTIFY ((__force fmode_t)0x1000000) | 106 | #define FMODE_NONOTIFY ((__force fmode_t)0x1000000) |
97 | 107 | ||
@@ -231,6 +241,7 @@ struct inodes_stat_t { | |||
231 | #define S_NOCMTIME 128 /* Do not update file c/mtime */ | 241 | #define S_NOCMTIME 128 /* Do not update file c/mtime */ |
232 | #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ | 242 | #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ |
233 | #define S_PRIVATE 512 /* Inode is fs-internal */ | 243 | #define S_PRIVATE 512 /* Inode is fs-internal */ |
244 | #define S_IMA 1024 /* Inode has an associated IMA struct */ | ||
234 | 245 | ||
235 | /* | 246 | /* |
236 | * Note that nosuid etc flags are inode-specific: setting some file-system | 247 | * Note that nosuid etc flags are inode-specific: setting some file-system |
@@ -265,6 +276,7 @@ struct inodes_stat_t { | |||
265 | #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) | 276 | #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME) |
266 | #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE) | 277 | #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE) |
267 | #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE) | 278 | #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE) |
279 | #define IS_IMA(inode) ((inode)->i_flags & S_IMA) | ||
268 | 280 | ||
269 | /* the read-only stuff doesn't really belong here, but any other place is | 281 | /* the read-only stuff doesn't really belong here, but any other place is |
270 | probably as bad and I don't want to create yet another include file. */ | 282 | probably as bad and I don't want to create yet another include file. */ |
@@ -312,6 +324,7 @@ struct inodes_stat_t { | |||
312 | #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */ | 324 | #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */ |
313 | #define FIFREEZE _IOWR('X', 119, int) /* Freeze */ | 325 | #define FIFREEZE _IOWR('X', 119, int) /* Freeze */ |
314 | #define FITHAW _IOWR('X', 120, int) /* Thaw */ | 326 | #define FITHAW _IOWR('X', 120, int) /* Thaw */ |
327 | #define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */ | ||
315 | 328 | ||
316 | #define FS_IOC_GETFLAGS _IOR('f', 1, long) | 329 | #define FS_IOC_GETFLAGS _IOR('f', 1, long) |
317 | #define FS_IOC_SETFLAGS _IOW('f', 2, long) | 330 | #define FS_IOC_SETFLAGS _IOW('f', 2, long) |
@@ -400,7 +413,7 @@ extern void __init inode_init_early(void); | |||
400 | extern void __init files_init(unsigned long); | 413 | extern void __init files_init(unsigned long); |
401 | 414 | ||
402 | extern struct files_stat_struct files_stat; | 415 | extern struct files_stat_struct files_stat; |
403 | extern int get_max_files(void); | 416 | extern unsigned long get_max_files(void); |
404 | extern int sysctl_nr_open; | 417 | extern int sysctl_nr_open; |
405 | extern struct inodes_stat_t inodes_stat; | 418 | extern struct inodes_stat_t inodes_stat; |
406 | extern int leases_enable, lease_break_time; | 419 | extern int leases_enable, lease_break_time; |
@@ -720,7 +733,8 @@ struct posix_acl; | |||
720 | 733 | ||
721 | struct inode { | 734 | struct inode { |
722 | struct hlist_node i_hash; | 735 | struct hlist_node i_hash; |
723 | struct list_head i_list; /* backing dev IO list */ | 736 | struct list_head i_wb_list; /* backing dev IO list */ |
737 | struct list_head i_lru; /* inode LRU list */ | ||
724 | struct list_head i_sb_list; | 738 | struct list_head i_sb_list; |
725 | struct list_head i_dentry; | 739 | struct list_head i_dentry; |
726 | unsigned long i_ino; | 740 | unsigned long i_ino; |
@@ -772,6 +786,10 @@ struct inode { | |||
772 | 786 | ||
773 | unsigned int i_flags; | 787 | unsigned int i_flags; |
774 | 788 | ||
789 | #ifdef CONFIG_IMA | ||
790 | /* protected by i_lock */ | ||
791 | unsigned int i_readcount; /* struct files open RO */ | ||
792 | #endif | ||
775 | atomic_t i_writecount; | 793 | atomic_t i_writecount; |
776 | #ifdef CONFIG_SECURITY | 794 | #ifdef CONFIG_SECURITY |
777 | void *i_security; | 795 | void *i_security; |
@@ -783,6 +801,11 @@ struct inode { | |||
783 | void *i_private; /* fs or device private pointer */ | 801 | void *i_private; /* fs or device private pointer */ |
784 | }; | 802 | }; |
785 | 803 | ||
804 | static inline int inode_unhashed(struct inode *inode) | ||
805 | { | ||
806 | return hlist_unhashed(&inode->i_hash); | ||
807 | } | ||
808 | |||
786 | /* | 809 | /* |
787 | * inode->i_mutex nesting subclasses for the lock validator: | 810 | * inode->i_mutex nesting subclasses for the lock validator: |
788 | * | 811 | * |
@@ -1107,6 +1130,7 @@ extern int fcntl_getlease(struct file *filp); | |||
1107 | 1130 | ||
1108 | /* fs/locks.c */ | 1131 | /* fs/locks.c */ |
1109 | extern void locks_init_lock(struct file_lock *); | 1132 | extern void locks_init_lock(struct file_lock *); |
1133 | extern struct file_lock * locks_alloc_lock(void); | ||
1110 | extern void locks_copy_lock(struct file_lock *, struct file_lock *); | 1134 | extern void locks_copy_lock(struct file_lock *, struct file_lock *); |
1111 | extern void __locks_copy_lock(struct file_lock *, const struct file_lock *); | 1135 | extern void __locks_copy_lock(struct file_lock *, const struct file_lock *); |
1112 | extern void locks_remove_posix(struct file *, fl_owner_t); | 1136 | extern void locks_remove_posix(struct file *, fl_owner_t); |
@@ -1295,6 +1319,11 @@ struct fasync_struct { | |||
1295 | 1319 | ||
1296 | /* SMP safe fasync helpers: */ | 1320 | /* SMP safe fasync helpers: */ |
1297 | extern int fasync_helper(int, struct file *, int, struct fasync_struct **); | 1321 | extern int fasync_helper(int, struct file *, int, struct fasync_struct **); |
1322 | extern struct fasync_struct *fasync_insert_entry(int, struct file *, struct fasync_struct **, struct fasync_struct *); | ||
1323 | extern int fasync_remove_entry(struct file *, struct fasync_struct **); | ||
1324 | extern struct fasync_struct *fasync_alloc(void); | ||
1325 | extern void fasync_free(struct fasync_struct *); | ||
1326 | |||
1298 | /* can be called from interrupts */ | 1327 | /* can be called from interrupts */ |
1299 | extern void kill_fasync(struct fasync_struct **, int, int); | 1328 | extern void kill_fasync(struct fasync_struct **, int, int); |
1300 | 1329 | ||
@@ -1583,6 +1612,7 @@ struct super_operations { | |||
1583 | ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); | 1612 | ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); |
1584 | #endif | 1613 | #endif |
1585 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); | 1614 | int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); |
1615 | int (*trim_fs) (struct super_block *, struct fstrim_range *); | ||
1586 | }; | 1616 | }; |
1587 | 1617 | ||
1588 | /* | 1618 | /* |
@@ -1633,16 +1663,17 @@ struct super_operations { | |||
1633 | * | 1663 | * |
1634 | * Q: What is the difference between I_WILL_FREE and I_FREEING? | 1664 | * Q: What is the difference between I_WILL_FREE and I_FREEING? |
1635 | */ | 1665 | */ |
1636 | #define I_DIRTY_SYNC 1 | 1666 | #define I_DIRTY_SYNC (1 << 0) |
1637 | #define I_DIRTY_DATASYNC 2 | 1667 | #define I_DIRTY_DATASYNC (1 << 1) |
1638 | #define I_DIRTY_PAGES 4 | 1668 | #define I_DIRTY_PAGES (1 << 2) |
1639 | #define __I_NEW 3 | 1669 | #define __I_NEW 3 |
1640 | #define I_NEW (1 << __I_NEW) | 1670 | #define I_NEW (1 << __I_NEW) |
1641 | #define I_WILL_FREE 16 | 1671 | #define I_WILL_FREE (1 << 4) |
1642 | #define I_FREEING 32 | 1672 | #define I_FREEING (1 << 5) |
1643 | #define I_CLEAR 64 | 1673 | #define I_CLEAR (1 << 6) |
1644 | #define __I_SYNC 7 | 1674 | #define __I_SYNC 7 |
1645 | #define I_SYNC (1 << __I_SYNC) | 1675 | #define I_SYNC (1 << __I_SYNC) |
1676 | #define I_REFERENCED (1 << 8) | ||
1646 | 1677 | ||
1647 | #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) | 1678 | #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) |
1648 | 1679 | ||
@@ -1734,12 +1765,15 @@ static inline void file_accessed(struct file *file) | |||
1734 | } | 1765 | } |
1735 | 1766 | ||
1736 | int sync_inode(struct inode *inode, struct writeback_control *wbc); | 1767 | int sync_inode(struct inode *inode, struct writeback_control *wbc); |
1768 | int sync_inode_metadata(struct inode *inode, int wait); | ||
1737 | 1769 | ||
1738 | struct file_system_type { | 1770 | struct file_system_type { |
1739 | const char *name; | 1771 | const char *name; |
1740 | int fs_flags; | 1772 | int fs_flags; |
1741 | int (*get_sb) (struct file_system_type *, int, | 1773 | int (*get_sb) (struct file_system_type *, int, |
1742 | const char *, void *, struct vfsmount *); | 1774 | const char *, void *, struct vfsmount *); |
1775 | struct dentry *(*mount) (struct file_system_type *, int, | ||
1776 | const char *, void *); | ||
1743 | void (*kill_sb) (struct super_block *); | 1777 | void (*kill_sb) (struct super_block *); |
1744 | struct module *owner; | 1778 | struct module *owner; |
1745 | struct file_system_type * next; | 1779 | struct file_system_type * next; |
@@ -1755,17 +1789,25 @@ struct file_system_type { | |||
1755 | struct lock_class_key i_alloc_sem_key; | 1789 | struct lock_class_key i_alloc_sem_key; |
1756 | }; | 1790 | }; |
1757 | 1791 | ||
1758 | extern int get_sb_ns(struct file_system_type *fs_type, int flags, void *data, | 1792 | extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags, |
1759 | int (*fill_super)(struct super_block *, void *, int), | 1793 | void *data, int (*fill_super)(struct super_block *, void *, int)); |
1760 | struct vfsmount *mnt); | 1794 | extern struct dentry *mount_bdev(struct file_system_type *fs_type, |
1795 | int flags, const char *dev_name, void *data, | ||
1796 | int (*fill_super)(struct super_block *, void *, int)); | ||
1761 | extern int get_sb_bdev(struct file_system_type *fs_type, | 1797 | extern int get_sb_bdev(struct file_system_type *fs_type, |
1762 | int flags, const char *dev_name, void *data, | 1798 | int flags, const char *dev_name, void *data, |
1763 | int (*fill_super)(struct super_block *, void *, int), | 1799 | int (*fill_super)(struct super_block *, void *, int), |
1764 | struct vfsmount *mnt); | 1800 | struct vfsmount *mnt); |
1801 | extern struct dentry *mount_single(struct file_system_type *fs_type, | ||
1802 | int flags, void *data, | ||
1803 | int (*fill_super)(struct super_block *, void *, int)); | ||
1765 | extern int get_sb_single(struct file_system_type *fs_type, | 1804 | extern int get_sb_single(struct file_system_type *fs_type, |
1766 | int flags, void *data, | 1805 | int flags, void *data, |
1767 | int (*fill_super)(struct super_block *, void *, int), | 1806 | int (*fill_super)(struct super_block *, void *, int), |
1768 | struct vfsmount *mnt); | 1807 | struct vfsmount *mnt); |
1808 | extern struct dentry *mount_nodev(struct file_system_type *fs_type, | ||
1809 | int flags, void *data, | ||
1810 | int (*fill_super)(struct super_block *, void *, int)); | ||
1769 | extern int get_sb_nodev(struct file_system_type *fs_type, | 1811 | extern int get_sb_nodev(struct file_system_type *fs_type, |
1770 | int flags, void *data, | 1812 | int flags, void *data, |
1771 | int (*fill_super)(struct super_block *, void *, int), | 1813 | int (*fill_super)(struct super_block *, void *, int), |
@@ -1781,9 +1823,8 @@ struct super_block *sget(struct file_system_type *type, | |||
1781 | int (*test)(struct super_block *,void *), | 1823 | int (*test)(struct super_block *,void *), |
1782 | int (*set)(struct super_block *,void *), | 1824 | int (*set)(struct super_block *,void *), |
1783 | void *data); | 1825 | void *data); |
1784 | extern int get_sb_pseudo(struct file_system_type *, char *, | 1826 | extern struct dentry *mount_pseudo(struct file_system_type *, char *, |
1785 | const struct super_operations *ops, unsigned long, | 1827 | const struct super_operations *ops, unsigned long); |
1786 | struct vfsmount *mnt); | ||
1787 | extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); | 1828 | extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); |
1788 | 1829 | ||
1789 | static inline void sb_mark_dirty(struct super_block *sb) | 1830 | static inline void sb_mark_dirty(struct super_block *sb) |
@@ -1826,6 +1867,7 @@ extern int current_umask(void); | |||
1826 | /* /sys/fs */ | 1867 | /* /sys/fs */ |
1827 | extern struct kobject *fs_kobj; | 1868 | extern struct kobject *fs_kobj; |
1828 | 1869 | ||
1870 | #define MAX_RW_COUNT (INT_MAX & PAGE_CACHE_MASK) | ||
1829 | extern int rw_verify_area(int, struct file *, loff_t *, size_t); | 1871 | extern int rw_verify_area(int, struct file *, loff_t *, size_t); |
1830 | 1872 | ||
1831 | #define FLOCK_VERIFY_READ 1 | 1873 | #define FLOCK_VERIFY_READ 1 |
@@ -2078,7 +2120,6 @@ extern int check_disk_change(struct block_device *); | |||
2078 | extern int __invalidate_device(struct block_device *); | 2120 | extern int __invalidate_device(struct block_device *); |
2079 | extern int invalidate_partition(struct gendisk *, int); | 2121 | extern int invalidate_partition(struct gendisk *, int); |
2080 | #endif | 2122 | #endif |
2081 | extern int invalidate_inodes(struct super_block *); | ||
2082 | unsigned long invalidate_mapping_pages(struct address_space *mapping, | 2123 | unsigned long invalidate_mapping_pages(struct address_space *mapping, |
2083 | pgoff_t start, pgoff_t end); | 2124 | pgoff_t start, pgoff_t end); |
2084 | 2125 | ||
@@ -2162,7 +2203,7 @@ extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin); | |||
2162 | 2203 | ||
2163 | extern int inode_init_always(struct super_block *, struct inode *); | 2204 | extern int inode_init_always(struct super_block *, struct inode *); |
2164 | extern void inode_init_once(struct inode *); | 2205 | extern void inode_init_once(struct inode *); |
2165 | extern void inode_add_to_lists(struct super_block *, struct inode *); | 2206 | extern void ihold(struct inode * inode); |
2166 | extern void iput(struct inode *); | 2207 | extern void iput(struct inode *); |
2167 | extern struct inode * igrab(struct inode *); | 2208 | extern struct inode * igrab(struct inode *); |
2168 | extern ino_t iunique(struct super_block *, ino_t); | 2209 | extern ino_t iunique(struct super_block *, ino_t); |
@@ -2182,11 +2223,11 @@ extern struct inode * iget_locked(struct super_block *, unsigned long); | |||
2182 | extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); | 2223 | extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); |
2183 | extern int insert_inode_locked(struct inode *); | 2224 | extern int insert_inode_locked(struct inode *); |
2184 | extern void unlock_new_inode(struct inode *); | 2225 | extern void unlock_new_inode(struct inode *); |
2226 | extern unsigned int get_next_ino(void); | ||
2185 | 2227 | ||
2186 | extern void __iget(struct inode * inode); | 2228 | extern void __iget(struct inode * inode); |
2187 | extern void iget_failed(struct inode *); | 2229 | extern void iget_failed(struct inode *); |
2188 | extern void end_writeback(struct inode *); | 2230 | extern void end_writeback(struct inode *); |
2189 | extern void destroy_inode(struct inode *); | ||
2190 | extern void __destroy_inode(struct inode *); | 2231 | extern void __destroy_inode(struct inode *); |
2191 | extern struct inode *new_inode(struct super_block *); | 2232 | extern struct inode *new_inode(struct super_block *); |
2192 | extern int should_remove_suid(struct dentry *); | 2233 | extern int should_remove_suid(struct dentry *); |
@@ -2194,9 +2235,11 @@ extern int file_remove_suid(struct file *); | |||
2194 | 2235 | ||
2195 | extern void __insert_inode_hash(struct inode *, unsigned long hashval); | 2236 | extern void __insert_inode_hash(struct inode *, unsigned long hashval); |
2196 | extern void remove_inode_hash(struct inode *); | 2237 | extern void remove_inode_hash(struct inode *); |
2197 | static inline void insert_inode_hash(struct inode *inode) { | 2238 | static inline void insert_inode_hash(struct inode *inode) |
2239 | { | ||
2198 | __insert_inode_hash(inode, inode->i_ino); | 2240 | __insert_inode_hash(inode, inode->i_ino); |
2199 | } | 2241 | } |
2242 | extern void inode_sb_list_add(struct inode *inode); | ||
2200 | 2243 | ||
2201 | #ifdef CONFIG_BLOCK | 2244 | #ifdef CONFIG_BLOCK |
2202 | extern void submit_bio(int, struct bio *); | 2245 | extern void submit_bio(int, struct bio *); |
@@ -2479,7 +2522,10 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, | |||
2479 | struct ctl_table; | 2522 | struct ctl_table; |
2480 | int proc_nr_files(struct ctl_table *table, int write, | 2523 | int proc_nr_files(struct ctl_table *table, int write, |
2481 | void __user *buffer, size_t *lenp, loff_t *ppos); | 2524 | void __user *buffer, size_t *lenp, loff_t *ppos); |
2482 | 2525 | int proc_nr_dentry(struct ctl_table *table, int write, | |
2526 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
2527 | int proc_nr_inodes(struct ctl_table *table, int write, | ||
2528 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
2483 | int __init get_filesystem_list(char *buf); | 2529 | int __init get_filesystem_list(char *buf); |
2484 | 2530 | ||
2485 | #define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE]) | 2531 | #define ACC_MODE(x) ("\004\002\006\006"[(x)&O_ACCMODE]) |