diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 106 |
1 files changed, 81 insertions, 25 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 955dff5da56a..bf5d574ebdf4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -623,10 +623,13 @@ static inline int inode_unhashed(struct inode *inode) | |||
623 | * 0: the object of the current VFS operation | 623 | * 0: the object of the current VFS operation |
624 | * 1: parent | 624 | * 1: parent |
625 | * 2: child/target | 625 | * 2: child/target |
626 | * 3: quota file | 626 | * 3: xattr |
627 | * 4: second non-directory | ||
628 | * The last is for certain operations (such as rename) which lock two | ||
629 | * non-directories at once. | ||
627 | * | 630 | * |
628 | * The locking order between these classes is | 631 | * The locking order between these classes is |
629 | * parent -> child -> normal -> xattr -> quota | 632 | * parent -> child -> normal -> xattr -> second non-directory |
630 | */ | 633 | */ |
631 | enum inode_i_mutex_lock_class | 634 | enum inode_i_mutex_lock_class |
632 | { | 635 | { |
@@ -634,9 +637,12 @@ enum inode_i_mutex_lock_class | |||
634 | I_MUTEX_PARENT, | 637 | I_MUTEX_PARENT, |
635 | I_MUTEX_CHILD, | 638 | I_MUTEX_CHILD, |
636 | I_MUTEX_XATTR, | 639 | I_MUTEX_XATTR, |
637 | I_MUTEX_QUOTA | 640 | I_MUTEX_NONDIR2 |
638 | }; | 641 | }; |
639 | 642 | ||
643 | void lock_two_nondirectories(struct inode *, struct inode*); | ||
644 | void unlock_two_nondirectories(struct inode *, struct inode*); | ||
645 | |||
640 | /* | 646 | /* |
641 | * NOTE: in a 32bit arch with a preemptable kernel and | 647 | * NOTE: in a 32bit arch with a preemptable kernel and |
642 | * an UP compile the i_size_read/write must be atomic | 648 | * an UP compile the i_size_read/write must be atomic |
@@ -764,12 +770,7 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index) | |||
764 | #define FILE_MNT_WRITE_RELEASED 2 | 770 | #define FILE_MNT_WRITE_RELEASED 2 |
765 | 771 | ||
766 | struct file { | 772 | struct file { |
767 | /* | ||
768 | * fu_list becomes invalid after file_free is called and queued via | ||
769 | * fu_rcuhead for RCU freeing | ||
770 | */ | ||
771 | union { | 773 | union { |
772 | struct list_head fu_list; | ||
773 | struct llist_node fu_llist; | 774 | struct llist_node fu_llist; |
774 | struct rcu_head fu_rcuhead; | 775 | struct rcu_head fu_rcuhead; |
775 | } f_u; | 776 | } f_u; |
@@ -783,9 +784,6 @@ struct file { | |||
783 | * Must not be taken from IRQ context. | 784 | * Must not be taken from IRQ context. |
784 | */ | 785 | */ |
785 | spinlock_t f_lock; | 786 | spinlock_t f_lock; |
786 | #ifdef CONFIG_SMP | ||
787 | int f_sb_list_cpu; | ||
788 | #endif | ||
789 | atomic_long_t f_count; | 787 | atomic_long_t f_count; |
790 | unsigned int f_flags; | 788 | unsigned int f_flags; |
791 | fmode_t f_mode; | 789 | fmode_t f_mode; |
@@ -882,6 +880,7 @@ static inline int file_check_writeable(struct file *filp) | |||
882 | 880 | ||
883 | #define FL_POSIX 1 | 881 | #define FL_POSIX 1 |
884 | #define FL_FLOCK 2 | 882 | #define FL_FLOCK 2 |
883 | #define FL_DELEG 4 /* NFSv4 delegation */ | ||
885 | #define FL_ACCESS 8 /* not trying to lock, just looking */ | 884 | #define FL_ACCESS 8 /* not trying to lock, just looking */ |
886 | #define FL_EXISTS 16 /* when unlocking, test for existence */ | 885 | #define FL_EXISTS 16 /* when unlocking, test for existence */ |
887 | #define FL_LEASE 32 /* lease held on this file */ | 886 | #define FL_LEASE 32 /* lease held on this file */ |
@@ -1023,7 +1022,7 @@ extern int vfs_test_lock(struct file *, struct file_lock *); | |||
1023 | extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *); | 1022 | extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *); |
1024 | extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl); | 1023 | extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl); |
1025 | extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); | 1024 | extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); |
1026 | extern int __break_lease(struct inode *inode, unsigned int flags); | 1025 | extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type); |
1027 | extern void lease_get_mtime(struct inode *, struct timespec *time); | 1026 | extern void lease_get_mtime(struct inode *, struct timespec *time); |
1028 | extern int generic_setlease(struct file *, long, struct file_lock **); | 1027 | extern int generic_setlease(struct file *, long, struct file_lock **); |
1029 | extern int vfs_setlease(struct file *, long, struct file_lock **); | 1028 | extern int vfs_setlease(struct file *, long, struct file_lock **); |
@@ -1132,7 +1131,7 @@ static inline int flock_lock_file_wait(struct file *filp, | |||
1132 | return -ENOLCK; | 1131 | return -ENOLCK; |
1133 | } | 1132 | } |
1134 | 1133 | ||
1135 | static inline int __break_lease(struct inode *inode, unsigned int mode) | 1134 | static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) |
1136 | { | 1135 | { |
1137 | return 0; | 1136 | return 0; |
1138 | } | 1137 | } |
@@ -1264,11 +1263,6 @@ struct super_block { | |||
1264 | 1263 | ||
1265 | struct list_head s_inodes; /* all inodes */ | 1264 | struct list_head s_inodes; /* all inodes */ |
1266 | struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */ | 1265 | struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */ |
1267 | #ifdef CONFIG_SMP | ||
1268 | struct list_head __percpu *s_files; | ||
1269 | #else | ||
1270 | struct list_head s_files; | ||
1271 | #endif | ||
1272 | struct list_head s_mounts; /* list of mounts; _not_ for fs use */ | 1266 | struct list_head s_mounts; /* list of mounts; _not_ for fs use */ |
1273 | struct block_device *s_bdev; | 1267 | struct block_device *s_bdev; |
1274 | struct backing_dev_info *s_bdi; | 1268 | struct backing_dev_info *s_bdi; |
@@ -1330,6 +1324,7 @@ struct super_block { | |||
1330 | */ | 1324 | */ |
1331 | struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; | 1325 | struct list_lru s_dentry_lru ____cacheline_aligned_in_smp; |
1332 | struct list_lru s_inode_lru ____cacheline_aligned_in_smp; | 1326 | struct list_lru s_inode_lru ____cacheline_aligned_in_smp; |
1327 | struct rcu_head rcu; | ||
1333 | }; | 1328 | }; |
1334 | 1329 | ||
1335 | extern struct timespec current_fs_time(struct super_block *sb); | 1330 | extern struct timespec current_fs_time(struct super_block *sb); |
@@ -1458,10 +1453,10 @@ extern int vfs_create(struct inode *, struct dentry *, umode_t, bool); | |||
1458 | extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); | 1453 | extern int vfs_mkdir(struct inode *, struct dentry *, umode_t); |
1459 | extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); | 1454 | extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t); |
1460 | extern int vfs_symlink(struct inode *, struct dentry *, const char *); | 1455 | extern int vfs_symlink(struct inode *, struct dentry *, const char *); |
1461 | extern int vfs_link(struct dentry *, struct inode *, struct dentry *); | 1456 | extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **); |
1462 | extern int vfs_rmdir(struct inode *, struct dentry *); | 1457 | extern int vfs_rmdir(struct inode *, struct dentry *); |
1463 | extern int vfs_unlink(struct inode *, struct dentry *); | 1458 | extern int vfs_unlink(struct inode *, struct dentry *, struct inode **); |
1464 | extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); | 1459 | extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **); |
1465 | 1460 | ||
1466 | /* | 1461 | /* |
1467 | * VFS dentry helper functions. | 1462 | * VFS dentry helper functions. |
@@ -1875,6 +1870,17 @@ extern struct dentry *mount_pseudo(struct file_system_type *, char *, | |||
1875 | (((fops) && try_module_get((fops)->owner) ? (fops) : NULL)) | 1870 | (((fops) && try_module_get((fops)->owner) ? (fops) : NULL)) |
1876 | #define fops_put(fops) \ | 1871 | #define fops_put(fops) \ |
1877 | do { if (fops) module_put((fops)->owner); } while(0) | 1872 | do { if (fops) module_put((fops)->owner); } while(0) |
1873 | /* | ||
1874 | * This one is to be used *ONLY* from ->open() instances. | ||
1875 | * fops must be non-NULL, pinned down *and* module dependencies | ||
1876 | * should be sufficient to pin the caller down as well. | ||
1877 | */ | ||
1878 | #define replace_fops(f, fops) \ | ||
1879 | do { \ | ||
1880 | struct file *__file = (f); \ | ||
1881 | fops_put(__file->f_op); \ | ||
1882 | BUG_ON(!(__file->f_op = (fops))); \ | ||
1883 | } while(0) | ||
1878 | 1884 | ||
1879 | extern int register_filesystem(struct file_system_type *); | 1885 | extern int register_filesystem(struct file_system_type *); |
1880 | extern int unregister_filesystem(struct file_system_type *); | 1886 | extern int unregister_filesystem(struct file_system_type *); |
@@ -1899,6 +1905,9 @@ extern bool fs_fully_visible(struct file_system_type *); | |||
1899 | 1905 | ||
1900 | extern int current_umask(void); | 1906 | extern int current_umask(void); |
1901 | 1907 | ||
1908 | extern void ihold(struct inode * inode); | ||
1909 | extern void iput(struct inode *); | ||
1910 | |||
1902 | /* /sys/fs */ | 1911 | /* /sys/fs */ |
1903 | extern struct kobject *fs_kobj; | 1912 | extern struct kobject *fs_kobj; |
1904 | 1913 | ||
@@ -1955,9 +1964,39 @@ static inline int locks_verify_truncate(struct inode *inode, | |||
1955 | static inline int break_lease(struct inode *inode, unsigned int mode) | 1964 | static inline int break_lease(struct inode *inode, unsigned int mode) |
1956 | { | 1965 | { |
1957 | if (inode->i_flock) | 1966 | if (inode->i_flock) |
1958 | return __break_lease(inode, mode); | 1967 | return __break_lease(inode, mode, FL_LEASE); |
1968 | return 0; | ||
1969 | } | ||
1970 | |||
1971 | static inline int break_deleg(struct inode *inode, unsigned int mode) | ||
1972 | { | ||
1973 | if (inode->i_flock) | ||
1974 | return __break_lease(inode, mode, FL_DELEG); | ||
1959 | return 0; | 1975 | return 0; |
1960 | } | 1976 | } |
1977 | |||
1978 | static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) | ||
1979 | { | ||
1980 | int ret; | ||
1981 | |||
1982 | ret = break_deleg(inode, O_WRONLY|O_NONBLOCK); | ||
1983 | if (ret == -EWOULDBLOCK && delegated_inode) { | ||
1984 | *delegated_inode = inode; | ||
1985 | ihold(inode); | ||
1986 | } | ||
1987 | return ret; | ||
1988 | } | ||
1989 | |||
1990 | static inline int break_deleg_wait(struct inode **delegated_inode) | ||
1991 | { | ||
1992 | int ret; | ||
1993 | |||
1994 | ret = break_deleg(*delegated_inode, O_WRONLY); | ||
1995 | iput(*delegated_inode); | ||
1996 | *delegated_inode = NULL; | ||
1997 | return ret; | ||
1998 | } | ||
1999 | |||
1961 | #else /* !CONFIG_FILE_LOCKING */ | 2000 | #else /* !CONFIG_FILE_LOCKING */ |
1962 | static inline int locks_mandatory_locked(struct inode *inode) | 2001 | static inline int locks_mandatory_locked(struct inode *inode) |
1963 | { | 2002 | { |
@@ -1997,6 +2036,22 @@ static inline int break_lease(struct inode *inode, unsigned int mode) | |||
1997 | return 0; | 2036 | return 0; |
1998 | } | 2037 | } |
1999 | 2038 | ||
2039 | static inline int break_deleg(struct inode *inode, unsigned int mode) | ||
2040 | { | ||
2041 | return 0; | ||
2042 | } | ||
2043 | |||
2044 | static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode) | ||
2045 | { | ||
2046 | return 0; | ||
2047 | } | ||
2048 | |||
2049 | static inline int break_deleg_wait(struct inode **delegated_inode) | ||
2050 | { | ||
2051 | BUG(); | ||
2052 | return 0; | ||
2053 | } | ||
2054 | |||
2000 | #endif /* CONFIG_FILE_LOCKING */ | 2055 | #endif /* CONFIG_FILE_LOCKING */ |
2001 | 2056 | ||
2002 | /* fs/open.c */ | 2057 | /* fs/open.c */ |
@@ -2223,7 +2278,7 @@ extern void emergency_remount(void); | |||
2223 | #ifdef CONFIG_BLOCK | 2278 | #ifdef CONFIG_BLOCK |
2224 | extern sector_t bmap(struct inode *, sector_t); | 2279 | extern sector_t bmap(struct inode *, sector_t); |
2225 | #endif | 2280 | #endif |
2226 | extern int notify_change(struct dentry *, struct iattr *); | 2281 | extern int notify_change(struct dentry *, struct iattr *, struct inode **); |
2227 | extern int inode_permission(struct inode *, int); | 2282 | extern int inode_permission(struct inode *, int); |
2228 | extern int generic_permission(struct inode *, int); | 2283 | extern int generic_permission(struct inode *, int); |
2229 | 2284 | ||
@@ -2337,8 +2392,6 @@ extern loff_t vfs_llseek(struct file *file, loff_t offset, int whence); | |||
2337 | extern int inode_init_always(struct super_block *, struct inode *); | 2392 | extern int inode_init_always(struct super_block *, struct inode *); |
2338 | extern void inode_init_once(struct inode *); | 2393 | extern void inode_init_once(struct inode *); |
2339 | extern void address_space_init_once(struct address_space *mapping); | 2394 | extern void address_space_init_once(struct address_space *mapping); |
2340 | extern void ihold(struct inode * inode); | ||
2341 | extern void iput(struct inode *); | ||
2342 | extern struct inode * igrab(struct inode *); | 2395 | extern struct inode * igrab(struct inode *); |
2343 | extern ino_t iunique(struct super_block *, ino_t); | 2396 | extern ino_t iunique(struct super_block *, ino_t); |
2344 | extern int inode_needs_sync(struct inode *inode); | 2397 | extern int inode_needs_sync(struct inode *inode); |
@@ -2507,8 +2560,10 @@ extern int __page_symlink(struct inode *inode, const char *symname, int len, | |||
2507 | int nofs); | 2560 | int nofs); |
2508 | extern int page_symlink(struct inode *inode, const char *symname, int len); | 2561 | extern int page_symlink(struct inode *inode, const char *symname, int len); |
2509 | extern const struct inode_operations page_symlink_inode_operations; | 2562 | extern const struct inode_operations page_symlink_inode_operations; |
2563 | extern void kfree_put_link(struct dentry *, struct nameidata *, void *); | ||
2510 | extern int generic_readlink(struct dentry *, char __user *, int); | 2564 | extern int generic_readlink(struct dentry *, char __user *, int); |
2511 | extern void generic_fillattr(struct inode *, struct kstat *); | 2565 | extern void generic_fillattr(struct inode *, struct kstat *); |
2566 | int vfs_getattr_nosec(struct path *path, struct kstat *stat); | ||
2512 | extern int vfs_getattr(struct path *, struct kstat *); | 2567 | extern int vfs_getattr(struct path *, struct kstat *); |
2513 | void __inode_add_bytes(struct inode *inode, loff_t bytes); | 2568 | void __inode_add_bytes(struct inode *inode, loff_t bytes); |
2514 | void inode_add_bytes(struct inode *inode, loff_t bytes); | 2569 | void inode_add_bytes(struct inode *inode, loff_t bytes); |
@@ -2567,6 +2622,7 @@ extern int simple_write_begin(struct file *file, struct address_space *mapping, | |||
2567 | extern int simple_write_end(struct file *file, struct address_space *mapping, | 2622 | extern int simple_write_end(struct file *file, struct address_space *mapping, |
2568 | loff_t pos, unsigned len, unsigned copied, | 2623 | loff_t pos, unsigned len, unsigned copied, |
2569 | struct page *page, void *fsdata); | 2624 | struct page *page, void *fsdata); |
2625 | extern struct inode *alloc_anon_inode(struct super_block *); | ||
2570 | 2626 | ||
2571 | extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); | 2627 | extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); |
2572 | extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); | 2628 | extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); |