aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h121
1 files changed, 74 insertions, 47 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 334d68a17108..32b38cd829d3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -34,9 +34,9 @@
34#define SEEK_MAX SEEK_END 34#define SEEK_MAX SEEK_END
35 35
36struct fstrim_range { 36struct fstrim_range {
37 uint64_t start; 37 __u64 start;
38 uint64_t len; 38 __u64 len;
39 uint64_t minlen; 39 __u64 minlen;
40}; 40};
41 41
42/* And dynamically-tunable limits and defaults: */ 42/* And dynamically-tunable limits and defaults: */
@@ -242,6 +242,7 @@ struct inodes_stat_t {
242#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */ 242#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
243#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 */ 244#define S_IMA 1024 /* Inode has an associated IMA struct */
245#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
245 246
246/* 247/*
247 * Note that nosuid etc flags are inode-specific: setting some file-system 248 * Note that nosuid etc flags are inode-specific: setting some file-system
@@ -277,6 +278,7 @@ struct inodes_stat_t {
277#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE) 278#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
278#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE) 279#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
279#define IS_IMA(inode) ((inode)->i_flags & S_IMA) 280#define IS_IMA(inode) ((inode)->i_flags & S_IMA)
281#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
280 282
281/* the read-only stuff doesn't really belong here, but any other place is 283/* the read-only stuff doesn't really belong here, but any other place is
282 probably as bad and I don't want to create yet another include file. */ 284 probably as bad and I don't want to create yet another include file. */
@@ -382,7 +384,6 @@ struct inodes_stat_t {
382#include <linux/path.h> 384#include <linux/path.h>
383#include <linux/stat.h> 385#include <linux/stat.h>
384#include <linux/cache.h> 386#include <linux/cache.h>
385#include <linux/kobject.h>
386#include <linux/list.h> 387#include <linux/list.h>
387#include <linux/radix-tree.h> 388#include <linux/radix-tree.h>
388#include <linux/prio_tree.h> 389#include <linux/prio_tree.h>
@@ -392,6 +393,7 @@ struct inodes_stat_t {
392#include <linux/capability.h> 393#include <linux/capability.h>
393#include <linux/semaphore.h> 394#include <linux/semaphore.h>
394#include <linux/fiemap.h> 395#include <linux/fiemap.h>
396#include <linux/rculist_bl.h>
395 397
396#include <asm/atomic.h> 398#include <asm/atomic.h>
397#include <asm/byteorder.h> 399#include <asm/byteorder.h>
@@ -401,6 +403,7 @@ struct hd_geometry;
401struct iovec; 403struct iovec;
402struct nameidata; 404struct nameidata;
403struct kiocb; 405struct kiocb;
406struct kobject;
404struct pipe_inode_info; 407struct pipe_inode_info;
405struct poll_table_struct; 408struct poll_table_struct;
406struct kstatfs; 409struct kstatfs;
@@ -602,6 +605,7 @@ struct address_space_operations {
602 sector_t (*bmap)(struct address_space *, sector_t); 605 sector_t (*bmap)(struct address_space *, sector_t);
603 void (*invalidatepage) (struct page *, unsigned long); 606 void (*invalidatepage) (struct page *, unsigned long);
604 int (*releasepage) (struct page *, gfp_t); 607 int (*releasepage) (struct page *, gfp_t);
608 void (*freepage)(struct page *);
605 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov, 609 ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
606 loff_t offset, unsigned long nr_segs); 610 loff_t offset, unsigned long nr_segs);
607 int (*get_xip_mem)(struct address_space *, pgoff_t, int, 611 int (*get_xip_mem)(struct address_space *, pgoff_t, int,
@@ -662,8 +666,9 @@ struct block_device {
662 void * bd_claiming; 666 void * bd_claiming;
663 void * bd_holder; 667 void * bd_holder;
664 int bd_holders; 668 int bd_holders;
669 bool bd_write_holder;
665#ifdef CONFIG_SYSFS 670#ifdef CONFIG_SYSFS
666 struct list_head bd_holder_list; 671 struct list_head bd_holder_disks;
667#endif 672#endif
668 struct block_device * bd_contains; 673 struct block_device * bd_contains;
669 unsigned bd_block_size; 674 unsigned bd_block_size;
@@ -732,16 +737,31 @@ struct posix_acl;
732#define ACL_NOT_CACHED ((void *)(-1)) 737#define ACL_NOT_CACHED ((void *)(-1))
733 738
734struct inode { 739struct inode {
740 /* RCU path lookup touches following: */
741 umode_t i_mode;
742 uid_t i_uid;
743 gid_t i_gid;
744 const struct inode_operations *i_op;
745 struct super_block *i_sb;
746
747 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
748 unsigned int i_flags;
749 struct mutex i_mutex;
750
751 unsigned long i_state;
752 unsigned long dirtied_when; /* jiffies of first dirtying */
753
735 struct hlist_node i_hash; 754 struct hlist_node i_hash;
736 struct list_head i_wb_list; /* backing dev IO list */ 755 struct list_head i_wb_list; /* backing dev IO list */
737 struct list_head i_lru; /* inode LRU list */ 756 struct list_head i_lru; /* inode LRU list */
738 struct list_head i_sb_list; 757 struct list_head i_sb_list;
739 struct list_head i_dentry; 758 union {
759 struct list_head i_dentry;
760 struct rcu_head i_rcu;
761 };
740 unsigned long i_ino; 762 unsigned long i_ino;
741 atomic_t i_count; 763 atomic_t i_count;
742 unsigned int i_nlink; 764 unsigned int i_nlink;
743 uid_t i_uid;
744 gid_t i_gid;
745 dev_t i_rdev; 765 dev_t i_rdev;
746 unsigned int i_blkbits; 766 unsigned int i_blkbits;
747 u64 i_version; 767 u64 i_version;
@@ -754,13 +774,8 @@ struct inode {
754 struct timespec i_ctime; 774 struct timespec i_ctime;
755 blkcnt_t i_blocks; 775 blkcnt_t i_blocks;
756 unsigned short i_bytes; 776 unsigned short i_bytes;
757 umode_t i_mode;
758 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
759 struct mutex i_mutex;
760 struct rw_semaphore i_alloc_sem; 777 struct rw_semaphore i_alloc_sem;
761 const struct inode_operations *i_op;
762 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 778 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
763 struct super_block *i_sb;
764 struct file_lock *i_flock; 779 struct file_lock *i_flock;
765 struct address_space *i_mapping; 780 struct address_space *i_mapping;
766 struct address_space i_data; 781 struct address_space i_data;
@@ -781,11 +796,6 @@ struct inode {
781 struct hlist_head i_fsnotify_marks; 796 struct hlist_head i_fsnotify_marks;
782#endif 797#endif
783 798
784 unsigned long i_state;
785 unsigned long dirtied_when; /* jiffies of first dirtying */
786
787 unsigned int i_flags;
788
789#ifdef CONFIG_IMA 799#ifdef CONFIG_IMA
790 /* protected by i_lock */ 800 /* protected by i_lock */
791 unsigned int i_readcount; /* struct files open RO */ 801 unsigned int i_readcount; /* struct files open RO */
@@ -1058,7 +1068,6 @@ struct lock_manager_operations {
1058 int (*fl_grant)(struct file_lock *, struct file_lock *, int); 1068 int (*fl_grant)(struct file_lock *, struct file_lock *, int);
1059 void (*fl_release_private)(struct file_lock *); 1069 void (*fl_release_private)(struct file_lock *);
1060 void (*fl_break)(struct file_lock *); 1070 void (*fl_break)(struct file_lock *);
1061 int (*fl_mylease)(struct file_lock *, struct file_lock *);
1062 int (*fl_change)(struct file_lock **, int); 1071 int (*fl_change)(struct file_lock **, int);
1063}; 1072};
1064 1073
@@ -1371,13 +1380,13 @@ struct super_block {
1371 const struct xattr_handler **s_xattr; 1380 const struct xattr_handler **s_xattr;
1372 1381
1373 struct list_head s_inodes; /* all inodes */ 1382 struct list_head s_inodes; /* all inodes */
1374 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */ 1383 struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */
1375#ifdef CONFIG_SMP 1384#ifdef CONFIG_SMP
1376 struct list_head __percpu *s_files; 1385 struct list_head __percpu *s_files;
1377#else 1386#else
1378 struct list_head s_files; 1387 struct list_head s_files;
1379#endif 1388#endif
1380 /* s_dentry_lru and s_nr_dentry_unused are protected by dcache_lock */ 1389 /* s_dentry_lru, s_nr_dentry_unused protected by dcache.c lru locks */
1381 struct list_head s_dentry_lru; /* unused dentry lru */ 1390 struct list_head s_dentry_lru; /* unused dentry lru */
1382 int s_nr_dentry_unused; /* # of dentry on lru */ 1391 int s_nr_dentry_unused; /* # of dentry on lru */
1383 1392
@@ -1416,6 +1425,7 @@ struct super_block {
1416 * generic_show_options() 1425 * generic_show_options()
1417 */ 1426 */
1418 char __rcu *s_options; 1427 char __rcu *s_options;
1428 const struct dentry_operations *s_d_op; /* default d_op for dentries */
1419}; 1429};
1420 1430
1421extern struct timespec current_fs_time(struct super_block *sb); 1431extern struct timespec current_fs_time(struct super_block *sb);
@@ -1473,8 +1483,8 @@ struct fiemap_extent_info {
1473 unsigned int fi_flags; /* Flags as passed from user */ 1483 unsigned int fi_flags; /* Flags as passed from user */
1474 unsigned int fi_extents_mapped; /* Number of mapped extents */ 1484 unsigned int fi_extents_mapped; /* Number of mapped extents */
1475 unsigned int fi_extents_max; /* Size of fiemap_extent array */ 1485 unsigned int fi_extents_max; /* Size of fiemap_extent array */
1476 struct fiemap_extent *fi_extents_start; /* Start of fiemap_extent 1486 struct fiemap_extent __user *fi_extents_start; /* Start of
1477 * array */ 1487 fiemap_extent array */
1478}; 1488};
1479int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, 1489int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
1480 u64 phys, u64 len, u32 flags); 1490 u64 phys, u64 len, u32 flags);
@@ -1542,11 +1552,22 @@ struct file_operations {
1542 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1552 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
1543 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); 1553 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
1544 int (*setlease)(struct file *, long, struct file_lock **); 1554 int (*setlease)(struct file *, long, struct file_lock **);
1555 long (*fallocate)(struct file *file, int mode, loff_t offset,
1556 loff_t len);
1545}; 1557};
1546 1558
1559#define IPERM_FLAG_RCU 0x0001
1560
1547struct inode_operations { 1561struct inode_operations {
1548 int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
1549 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *); 1562 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
1563 void * (*follow_link) (struct dentry *, struct nameidata *);
1564 int (*permission) (struct inode *, int, unsigned int);
1565 int (*check_acl)(struct inode *, int, unsigned int);
1566
1567 int (*readlink) (struct dentry *, char __user *,int);
1568 void (*put_link) (struct dentry *, struct nameidata *, void *);
1569
1570 int (*create) (struct inode *,struct dentry *,int, struct nameidata *);
1550 int (*link) (struct dentry *,struct inode *,struct dentry *); 1571 int (*link) (struct dentry *,struct inode *,struct dentry *);
1551 int (*unlink) (struct inode *,struct dentry *); 1572 int (*unlink) (struct inode *,struct dentry *);
1552 int (*symlink) (struct inode *,struct dentry *,const char *); 1573 int (*symlink) (struct inode *,struct dentry *,const char *);
@@ -1555,12 +1576,7 @@ struct inode_operations {
1555 int (*mknod) (struct inode *,struct dentry *,int,dev_t); 1576 int (*mknod) (struct inode *,struct dentry *,int,dev_t);
1556 int (*rename) (struct inode *, struct dentry *, 1577 int (*rename) (struct inode *, struct dentry *,
1557 struct inode *, struct dentry *); 1578 struct inode *, struct dentry *);
1558 int (*readlink) (struct dentry *, char __user *,int);
1559 void * (*follow_link) (struct dentry *, struct nameidata *);
1560 void (*put_link) (struct dentry *, struct nameidata *, void *);
1561 void (*truncate) (struct inode *); 1579 void (*truncate) (struct inode *);
1562 int (*permission) (struct inode *, int);
1563 int (*check_acl)(struct inode *, int);
1564 int (*setattr) (struct dentry *, struct iattr *); 1580 int (*setattr) (struct dentry *, struct iattr *);
1565 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); 1581 int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
1566 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); 1582 int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
@@ -1568,11 +1584,9 @@ struct inode_operations {
1568 ssize_t (*listxattr) (struct dentry *, char *, size_t); 1584 ssize_t (*listxattr) (struct dentry *, char *, size_t);
1569 int (*removexattr) (struct dentry *, const char *); 1585 int (*removexattr) (struct dentry *, const char *);
1570 void (*truncate_range)(struct inode *, loff_t, loff_t); 1586 void (*truncate_range)(struct inode *, loff_t, loff_t);
1571 long (*fallocate)(struct inode *inode, int mode, loff_t offset,
1572 loff_t len);
1573 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, 1587 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
1574 u64 len); 1588 u64 len);
1575}; 1589} ____cacheline_aligned;
1576 1590
1577struct seq_file; 1591struct seq_file;
1578 1592
@@ -1612,7 +1626,6 @@ struct super_operations {
1612 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 1626 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
1613#endif 1627#endif
1614 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1628 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
1615 int (*trim_fs) (struct super_block *, struct fstrim_range *);
1616}; 1629};
1617 1630
1618/* 1631/*
@@ -1824,7 +1837,9 @@ struct super_block *sget(struct file_system_type *type,
1824 int (*set)(struct super_block *,void *), 1837 int (*set)(struct super_block *,void *),
1825 void *data); 1838 void *data);
1826extern struct dentry *mount_pseudo(struct file_system_type *, char *, 1839extern struct dentry *mount_pseudo(struct file_system_type *, char *,
1827 const struct super_operations *ops, unsigned long); 1840 const struct super_operations *ops,
1841 const struct dentry_operations *dops,
1842 unsigned long);
1828extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1843extern void simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
1829 1844
1830static inline void sb_mark_dirty(struct super_block *sb) 1845static inline void sb_mark_dirty(struct super_block *sb)
@@ -2006,7 +2021,6 @@ extern struct block_device *bdgrab(struct block_device *bdev);
2006extern void bd_set_size(struct block_device *, loff_t size); 2021extern void bd_set_size(struct block_device *, loff_t size);
2007extern void bd_forget(struct inode *inode); 2022extern void bd_forget(struct inode *inode);
2008extern void bdput(struct block_device *); 2023extern void bdput(struct block_device *);
2009extern struct block_device *open_by_devnum(dev_t, fmode_t);
2010extern void invalidate_bdev(struct block_device *); 2024extern void invalidate_bdev(struct block_device *);
2011extern int sync_blockdev(struct block_device *bdev); 2025extern int sync_blockdev(struct block_device *bdev);
2012extern struct super_block *freeze_bdev(struct block_device *); 2026extern struct super_block *freeze_bdev(struct block_device *);
@@ -2037,16 +2051,26 @@ extern const struct file_operations def_fifo_fops;
2037extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 2051extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
2038extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long); 2052extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
2039extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 2053extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
2040extern int blkdev_get(struct block_device *, fmode_t); 2054extern int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder);
2041extern int blkdev_put(struct block_device *, fmode_t); 2055extern struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
2042extern int bd_claim(struct block_device *, void *); 2056 void *holder);
2043extern void bd_release(struct block_device *); 2057extern struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode,
2058 void *holder);
2059extern int blkdev_put(struct block_device *bdev, fmode_t mode);
2044#ifdef CONFIG_SYSFS 2060#ifdef CONFIG_SYSFS
2045extern int bd_claim_by_disk(struct block_device *, void *, struct gendisk *); 2061extern int bd_link_disk_holder(struct block_device *bdev, struct gendisk *disk);
2046extern void bd_release_from_disk(struct block_device *, struct gendisk *); 2062extern void bd_unlink_disk_holder(struct block_device *bdev,
2063 struct gendisk *disk);
2047#else 2064#else
2048#define bd_claim_by_disk(bdev, holder, disk) bd_claim(bdev, holder) 2065static inline int bd_link_disk_holder(struct block_device *bdev,
2049#define bd_release_from_disk(bdev, disk) bd_release(bdev) 2066 struct gendisk *disk)
2067{
2068 return 0;
2069}
2070static inline void bd_unlink_disk_holder(struct block_device *bdev,
2071 struct gendisk *disk)
2072{
2073}
2050#endif 2074#endif
2051#endif 2075#endif
2052 2076
@@ -2082,8 +2106,6 @@ static inline void unregister_chrdev(unsigned int major, const char *name)
2082extern const char *__bdevname(dev_t, char *buffer); 2106extern const char *__bdevname(dev_t, char *buffer);
2083extern const char *bdevname(struct block_device *bdev, char *buffer); 2107extern const char *bdevname(struct block_device *bdev, char *buffer);
2084extern struct block_device *lookup_bdev(const char *); 2108extern struct block_device *lookup_bdev(const char *);
2085extern struct block_device *open_bdev_exclusive(const char *, fmode_t, void *);
2086extern void close_bdev_exclusive(struct block_device *, fmode_t);
2087extern void blkdev_show(struct seq_file *,off_t); 2109extern void blkdev_show(struct seq_file *,off_t);
2088 2110
2089#else 2111#else
@@ -2158,8 +2180,8 @@ extern sector_t bmap(struct inode *, sector_t);
2158#endif 2180#endif
2159extern int notify_change(struct dentry *, struct iattr *); 2181extern int notify_change(struct dentry *, struct iattr *);
2160extern int inode_permission(struct inode *, int); 2182extern int inode_permission(struct inode *, int);
2161extern int generic_permission(struct inode *, int, 2183extern int generic_permission(struct inode *, int, unsigned int,
2162 int (*check_acl)(struct inode *, int)); 2184 int (*check_acl)(struct inode *, int, unsigned int));
2163 2185
2164static inline bool execute_ok(struct inode *inode) 2186static inline bool execute_ok(struct inode *inode)
2165{ 2187{
@@ -2230,6 +2252,7 @@ extern void iget_failed(struct inode *);
2230extern void end_writeback(struct inode *); 2252extern void end_writeback(struct inode *);
2231extern void __destroy_inode(struct inode *); 2253extern void __destroy_inode(struct inode *);
2232extern struct inode *new_inode(struct super_block *); 2254extern struct inode *new_inode(struct super_block *);
2255extern void free_inode_nonrcu(struct inode *inode);
2233extern int should_remove_suid(struct dentry *); 2256extern int should_remove_suid(struct dentry *);
2234extern int file_remove_suid(struct file *); 2257extern int file_remove_suid(struct file *);
2235 2258
@@ -2446,6 +2469,10 @@ static inline ino_t parent_ino(struct dentry *dentry)
2446{ 2469{
2447 ino_t res; 2470 ino_t res;
2448 2471
2472 /*
2473 * Don't strictly need d_lock here? If the parent ino could change
2474 * then surely we'd have a deeper race in the caller?
2475 */
2449 spin_lock(&dentry->d_lock); 2476 spin_lock(&dentry->d_lock);
2450 res = dentry->d_parent->d_inode->i_ino; 2477 res = dentry->d_parent->d_inode->i_ino;
2451 spin_unlock(&dentry->d_lock); 2478 spin_unlock(&dentry->d_lock);