Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull misc vfs updates from Al Viro:
"Misc bits and pieces not fitting into anything more specific"

* 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
vfs: delete unnecessary assignment in vfs_listxattr
Documentation: filesystems: update filesystem locking documentation
vfs: namei: use path_equal() in follow_dotdot()
fs.h: fix outdated comment about file flags
__inode_security_revalidate() never gets NULL opt_dentry
make xattr_getsecurity() static
vfat: simplify checks in vfat_lookup()
get rid of dead code in d_find_alias()
it's SB_BORN, not MS_BORN...
msdos_rmdir(): kill BS comment
remove rpc_rmdir()
fs: avoid fdput() after failed fdget() in vfs_dedupe_file_range()

+69 -118
+24 -19
Documentation/filesystems/Locking
··· 69 69 70 70 locking rules: 71 71 all may block 72 - i_mutex(inode) 73 - lookup: yes 74 - create: yes 75 - link: yes (both) 76 - mknod: yes 77 - symlink: yes 78 - mkdir: yes 79 - unlink: yes (both) 80 - rmdir: yes (both) (see below) 81 - rename: yes (all) (see below) 72 + i_rwsem(inode) 73 + lookup: shared 74 + create: exclusive 75 + link: exclusive (both) 76 + mknod: exclusive 77 + symlink: exclusive 78 + mkdir: exclusive 79 + unlink: exclusive (both) 80 + rmdir: exclusive (both)(see below) 81 + rename: exclusive (all) (see below) 82 82 readlink: no 83 83 get_link: no 84 - setattr: yes 84 + setattr: exclusive 85 85 permission: no (may not block if called in rcu-walk mode) 86 86 get_acl: no 87 87 getattr: no 88 88 listxattr: no 89 89 fiemap: no 90 90 update_time: no 91 - atomic_open: yes 91 + atomic_open: exclusive 92 92 tmpfile: no 93 93 94 94 95 - Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on 96 - victim. 95 + Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_rwsem 96 + exclusive on victim. 97 97 cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem. 98 98 99 99 See Documentation/filesystems/directory-locking for more detailed discussion ··· 111 111 112 112 locking rules: 113 113 all may block 114 - i_mutex(inode) 114 + i_rwsem(inode) 115 115 list: no 116 116 get: no 117 - set: yes 117 + set: exclusive 118 118 119 119 --------------------------- super_operations --------------------------- 120 120 prototypes: ··· 217 217 locking rules: 218 218 All except set_page_dirty and freepage may block 219 219 220 - PageLocked(page) i_mutex 220 + PageLocked(page) i_rwsem 221 221 writepage: yes, unlocks (see below) 222 222 readpage: yes, unlocks 223 223 writepages: 224 224 set_page_dirty no 225 225 readpages: 226 - write_begin: locks the page yes 227 - write_end: yes, unlocks yes 226 + write_begin: locks the page exclusive 227 + write_end: yes, unlocks exclusive 228 228 bmap: 229 229 invalidatepage: yes 230 230 releasepage: yes ··· 439 439 ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); 440 440 ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); 441 441 int (*iterate) (struct file *, struct dir_context *); 442 + int (*iterate_shared) (struct file *, struct dir_context *); 442 443 unsigned int (*poll) (struct file *, struct poll_table_struct *); 443 444 long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); 444 445 long (*compat_ioctl) (struct file *, unsigned int, unsigned long); ··· 480 479 mutex or just to use i_size_read() instead. 481 480 Note: this does not protect the file->f_pos against concurrent modifications 482 481 since this is something the userspace has to take care about. 482 + 483 + ->iterate() is called with i_rwsem exclusive. 484 + 485 + ->iterate_shared() is called with i_rwsem at least shared. 483 486 484 487 ->fasync() is responsible for maintaining the FASYNC bit in filp->f_flags. 485 488 Most instances call fasync_helper(), which does that maintenance, so it's
+34 -49
fs/dcache.c
··· 902 902 } 903 903 EXPORT_SYMBOL(dget_parent); 904 904 905 + static struct dentry * __d_find_any_alias(struct inode *inode) 906 + { 907 + struct dentry *alias; 908 + 909 + if (hlist_empty(&inode->i_dentry)) 910 + return NULL; 911 + alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias); 912 + __dget(alias); 913 + return alias; 914 + } 915 + 916 + /** 917 + * d_find_any_alias - find any alias for a given inode 918 + * @inode: inode to find an alias for 919 + * 920 + * If any aliases exist for the given inode, take and return a 921 + * reference for one of them. If no aliases exist, return %NULL. 922 + */ 923 + struct dentry *d_find_any_alias(struct inode *inode) 924 + { 925 + struct dentry *de; 926 + 927 + spin_lock(&inode->i_lock); 928 + de = __d_find_any_alias(inode); 929 + spin_unlock(&inode->i_lock); 930 + return de; 931 + } 932 + EXPORT_SYMBOL(d_find_any_alias); 933 + 905 934 /** 906 935 * d_find_alias - grab a hashed alias of inode 907 936 * @inode: inode in question ··· 947 918 */ 948 919 static struct dentry *__d_find_alias(struct inode *inode) 949 920 { 950 - struct dentry *alias, *discon_alias; 921 + struct dentry *alias; 951 922 952 - again: 953 - discon_alias = NULL; 923 + if (S_ISDIR(inode->i_mode)) 924 + return __d_find_any_alias(inode); 925 + 954 926 hlist_for_each_entry(alias, &inode->i_dentry, d_u.d_alias) { 955 927 spin_lock(&alias->d_lock); 956 - if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) { 957 - if (IS_ROOT(alias) && 958 - (alias->d_flags & DCACHE_DISCONNECTED)) { 959 - discon_alias = alias; 960 - } else { 961 - __dget_dlock(alias); 962 - spin_unlock(&alias->d_lock); 963 - return alias; 964 - } 965 - } 966 - spin_unlock(&alias->d_lock); 967 - } 968 - if (discon_alias) { 969 - alias = discon_alias; 970 - spin_lock(&alias->d_lock); 971 - if (S_ISDIR(inode->i_mode) || !d_unhashed(alias)) { 928 + if (!d_unhashed(alias)) { 972 929 __dget_dlock(alias); 973 930 spin_unlock(&alias->d_lock); 974 931 return alias; 975 932 } 976 933 spin_unlock(&alias->d_lock); 977 - goto again; 978 934 } 979 935 return NULL; 980 936 } ··· 1940 1926 return res; 1941 1927 } 1942 1928 EXPORT_SYMBOL(d_make_root); 1943 - 1944 - static struct dentry * __d_find_any_alias(struct inode *inode) 1945 - { 1946 - struct dentry *alias; 1947 - 1948 - if (hlist_empty(&inode->i_dentry)) 1949 - return NULL; 1950 - alias = hlist_entry(inode->i_dentry.first, struct dentry, d_u.d_alias); 1951 - __dget(alias); 1952 - return alias; 1953 - } 1954 - 1955 - /** 1956 - * d_find_any_alias - find any alias for a given inode 1957 - * @inode: inode to find an alias for 1958 - * 1959 - * If any aliases exist for the given inode, take and return a 1960 - * reference for one of them. If no aliases exist, return %NULL. 1961 - */ 1962 - struct dentry *d_find_any_alias(struct inode *inode) 1963 - { 1964 - struct dentry *de; 1965 - 1966 - spin_lock(&inode->i_lock); 1967 - de = __d_find_any_alias(inode); 1968 - spin_unlock(&inode->i_lock); 1969 - return de; 1970 - } 1971 - EXPORT_SYMBOL(d_find_any_alias); 1972 1929 1973 1930 static struct dentry *__d_instantiate_anon(struct dentry *dentry, 1974 1931 struct inode *inode,
-4
fs/fat/namei_msdos.c
··· 314 314 int err; 315 315 316 316 mutex_lock(&MSDOS_SB(sb)->s_lock); 317 - /* 318 - * Check whether the directory is not in use, then check 319 - * whether it is empty. 320 - */ 321 317 err = fat_dir_empty(inode); 322 318 if (err) 323 319 goto out;
+1 -12
fs/fat/namei_vfat.c
··· 697 697 return fat_search_long(dir, qname->name, len, sinfo); 698 698 } 699 699 700 - /* 701 - * (nfsd's) anonymous disconnected dentry? 702 - * NOTE: !IS_ROOT() is not anonymous (I.e. d_splice_alias() did the job). 703 - */ 704 - static int vfat_d_anon_disconn(struct dentry *dentry) 705 - { 706 - return IS_ROOT(dentry) && (dentry->d_flags & DCACHE_DISCONNECTED); 707 - } 708 - 709 700 static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, 710 701 unsigned int flags) 711 702 { ··· 729 738 * Checking "alias->d_parent == dentry->d_parent" to make sure 730 739 * FS is not corrupted (especially double linked dir). 731 740 */ 732 - if (alias && alias->d_parent == dentry->d_parent && 733 - !vfat_d_anon_disconn(alias)) { 741 + if (alias && alias->d_parent == dentry->d_parent) { 734 742 /* 735 743 * This inode has non anonymous-DCACHE_DISCONNECTED 736 744 * dentry. This means, the user did ->lookup() by an ··· 737 747 * 738 748 * Switch to new one for reason of locality if possible. 739 749 */ 740 - BUG_ON(d_unhashed(alias)); 741 750 if (!S_ISDIR(inode->i_mode)) 742 751 d_move(alias, dentry); 743 752 iput(inode);
+1 -3
fs/namei.c
··· 1438 1438 static int follow_dotdot(struct nameidata *nd) 1439 1439 { 1440 1440 while(1) { 1441 - if (nd->path.dentry == nd->root.dentry && 1442 - nd->path.mnt == nd->root.mnt) { 1441 + if (path_equal(&nd->path, &nd->root)) 1443 1442 break; 1444 - } 1445 1443 if (nd->path.dentry != nd->path.mnt->mnt_root) { 1446 1444 int ret = path_parent_directory(&nd->path); 1447 1445 if (ret)
+3 -3
fs/read_write.c
··· 2023 2023 ret = mnt_want_write_file(dst_file); 2024 2024 if (ret) { 2025 2025 info->status = ret; 2026 - goto next_loop; 2026 + goto next_fdput; 2027 2027 } 2028 2028 2029 2029 dst_off = info->dest_offset; ··· 2058 2058 2059 2059 next_file: 2060 2060 mnt_drop_write_file(dst_file); 2061 - next_loop: 2061 + next_fdput: 2062 2062 fdput(dst_fd); 2063 - 2063 + next_loop: 2064 2064 if (fatal_signal_pending(current)) 2065 2065 goto out; 2066 2066 }
+1 -1
fs/super.c
··· 947 947 static void do_thaw_all_callback(struct super_block *sb) 948 948 { 949 949 down_write(&sb->s_umount); 950 - if (sb->s_root && sb->s_flags & MS_BORN) { 950 + if (sb->s_root && sb->s_flags & SB_BORN) { 951 951 emergency_thaw_bdev(sb); 952 952 thaw_super_locked(sb); 953 953 } else {
+1 -3
fs/xattr.c
··· 229 229 } 230 230 EXPORT_SYMBOL_GPL(vfs_setxattr); 231 231 232 - ssize_t 232 + static ssize_t 233 233 xattr_getsecurity(struct inode *inode, const char *name, void *value, 234 234 size_t size) 235 235 { ··· 254 254 out_noalloc: 255 255 return len; 256 256 } 257 - EXPORT_SYMBOL_GPL(xattr_getsecurity); 258 257 259 258 /* 260 259 * vfs_getxattr_alloc - allocate memory, if necessary, before calling getxattr ··· 353 354 if (error) 354 355 return error; 355 356 if (inode->i_op->listxattr && (inode->i_opflags & IOP_XATTR)) { 356 - error = -EOPNOTSUPP; 357 357 error = inode->i_op->listxattr(dentry, list, size); 358 358 } else { 359 359 error = security_inode_listsecurity(inode, list, size);
+1 -1
include/linux/fs.h
··· 94 94 95 95 /* 96 96 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond 97 - * to O_WRONLY and O_RDWR via the strange trick in __dentry_open() 97 + * to O_WRONLY and O_RDWR via the strange trick in do_dentry_open() 98 98 */ 99 99 100 100 /* file is open for reading */
-2
include/linux/sunrpc/rpc_pipe_fs.h
··· 122 122 struct cache_detail *); 123 123 extern void rpc_remove_cache_dir(struct dentry *); 124 124 125 - extern int rpc_rmdir(struct dentry *dentry); 126 - 127 125 struct rpc_pipe *rpc_mkpipe_data(const struct rpc_pipe_ops *ops, int flags); 128 126 void rpc_destroy_pipe_data(struct rpc_pipe *pipe); 129 127 extern struct dentry *rpc_mkpipe_dentry(struct dentry *, const char *, void *,
-1
include/linux/xattr.h
··· 46 46 size_t value_len; 47 47 }; 48 48 49 - ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t); 50 49 ssize_t __vfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t); 51 50 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t); 52 51 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
-16
net/sunrpc/rpc_pipe.c
··· 609 609 return ret; 610 610 } 611 611 612 - int rpc_rmdir(struct dentry *dentry) 613 - { 614 - struct dentry *parent; 615 - struct inode *dir; 616 - int error; 617 - 618 - parent = dget_parent(dentry); 619 - dir = d_inode(parent); 620 - inode_lock_nested(dir, I_MUTEX_PARENT); 621 - error = __rpc_rmdir(dir, dentry); 622 - inode_unlock(dir); 623 - dput(parent); 624 - return error; 625 - } 626 - EXPORT_SYMBOL_GPL(rpc_rmdir); 627 - 628 612 static int __rpc_unlink(struct inode *dir, struct dentry *dentry) 629 613 { 630 614 int ret;
+3 -4
security/selinux/hooks.c
··· 274 274 * Try reloading inode security labels that have been marked as invalid. The 275 275 * @may_sleep parameter indicates when sleeping and thus reloading labels is 276 276 * allowed; when set to false, returns -ECHILD when the label is 277 - * invalid. The @opt_dentry parameter should be set to a dentry of the inode; 278 - * when no dentry is available, set it to NULL instead. 277 + * invalid. The @dentry parameter should be set to a dentry of the inode. 279 278 */ 280 279 static int __inode_security_revalidate(struct inode *inode, 281 - struct dentry *opt_dentry, 280 + struct dentry *dentry, 282 281 bool may_sleep) 283 282 { 284 283 struct inode_security_struct *isec = inode->i_security; ··· 294 295 * @opt_dentry is NULL and no dentry for this inode can be 295 296 * found; in that case, continue using the old label. 296 297 */ 297 - inode_doinit_with_dentry(inode, opt_dentry); 298 + inode_doinit_with_dentry(inode, dentry); 298 299 } 299 300 return 0; 300 301 }