vfs: fix bad hashing of dentries
[firefly-linux-kernel-4.4.55.git] / fs / open.c
index 68354466879f619b0bf6d626e8130c1675e115b7..86092bde31f4827eec31eec454ec60e2c1dcb1e8 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -197,10 +197,7 @@ out:
 
 SYSCALL_DEFINE2(ftruncate, unsigned int, fd, unsigned long, length)
 {
-       long ret = do_sys_ftruncate(fd, length, 1);
-       /* avoid REGPARM breakage on x86: */
-       asmlinkage_protect(2, ret, fd, length);
-       return ret;
+       return do_sys_ftruncate(fd, length, 1);
 }
 
 #ifdef CONFIG_COMPAT
@@ -212,32 +209,15 @@ COMPAT_SYSCALL_DEFINE2(ftruncate, unsigned int, fd, compat_ulong_t, length)
 
 /* LFS versions of truncate are only needed on 32 bit machines */
 #if BITS_PER_LONG == 32
-SYSCALL_DEFINE(truncate64)(const char __user * path, loff_t length)
+SYSCALL_DEFINE2(truncate64, const char __user *, path, loff_t, length)
 {
        return do_sys_truncate(path, length);
 }
-#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
-asmlinkage long SyS_truncate64(long path, loff_t length)
-{
-       return SYSC_truncate64((const char __user *) path, length);
-}
-SYSCALL_ALIAS(sys_truncate64, SyS_truncate64);
-#endif
 
-SYSCALL_DEFINE(ftruncate64)(unsigned int fd, loff_t length)
+SYSCALL_DEFINE2(ftruncate64, unsigned int, fd, loff_t, length)
 {
-       long ret = do_sys_ftruncate(fd, length, 0);
-       /* avoid REGPARM breakage on x86: */
-       asmlinkage_protect(2, ret, fd, length);
-       return ret;
-}
-#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
-asmlinkage long SyS_ftruncate64(long fd, loff_t length)
-{
-       return SYSC_ftruncate64((unsigned int) fd, length);
+       return do_sys_ftruncate(fd, length, 0);
 }
-SYSCALL_ALIAS(sys_ftruncate64, SyS_ftruncate64);
-#endif
 #endif /* BITS_PER_LONG == 32 */
 
 
@@ -299,7 +279,7 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
        return ret;
 }
 
-SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
+SYSCALL_DEFINE4(fallocate, int, fd, int, mode, loff_t, offset, loff_t, len)
 {
        struct fd f = fdget(fd);
        int error = -EBADF;
@@ -311,14 +291,6 @@ SYSCALL_DEFINE(fallocate)(int fd, int mode, loff_t offset, loff_t len)
        return error;
 }
 
-#ifdef CONFIG_HAVE_SYSCALL_WRAPPERS
-asmlinkage long SyS_fallocate(long fd, long mode, loff_t offset, loff_t len)
-{
-       return SYSC_fallocate((int)fd, (int)mode, offset, len);
-}
-SYSCALL_ALIAS(sys_fallocate, SyS_fallocate);
-#endif
-
 /*
  * access() needs to use the real uid/gid, not the effective uid/gid.
  * We do this by temporarily clearing all FS-related capabilities and
@@ -656,23 +628,12 @@ out:
 static inline int __get_file_write_access(struct inode *inode,
                                          struct vfsmount *mnt)
 {
-       int error;
-       error = get_write_access(inode);
+       int error = get_write_access(inode);
        if (error)
                return error;
-       /*
-        * Do not take mount writer counts on
-        * special files since no writes to
-        * the mount itself will occur.
-        */
-       if (!special_file(inode->i_mode)) {
-               /*
-                * Balanced in __fput()
-                */
-               error = __mnt_want_write(mnt);
-               if (error)
-                       put_write_access(inode);
-       }
+       error = __mnt_want_write(mnt);
+       if (error)
+               put_write_access(inode);
        return error;
 }
 
@@ -705,12 +666,11 @@ static int do_dentry_open(struct file *f,
 
        path_get(&f->f_path);
        inode = f->f_inode = f->f_path.dentry->d_inode;
-       if (f->f_mode & FMODE_WRITE) {
+       if (f->f_mode & FMODE_WRITE && !special_file(inode->i_mode)) {
                error = __get_file_write_access(inode, f->f_path.mnt);
                if (error)
                        goto cleanup_file;
-               if (!special_file(inode->i_mode))
-                       file_take_write(f);
+               file_take_write(f);
        }
 
        f->f_mapping = inode->i_mapping;
@@ -751,7 +711,6 @@ cleanup_all:
        fops_put(f->f_op);
        file_sb_list_del(f);
        if (f->f_mode & FMODE_WRITE) {
-               put_write_access(inode);
                if (!special_file(inode->i_mode)) {
                        /*
                         * We don't consider this a real
@@ -759,6 +718,7 @@ cleanup_all:
                         * because it all happenend right
                         * here, so just reset the state.
                         */
+                       put_write_access(inode);
                        file_reset_write(f);
                        __mnt_drop_write(f->f_path.mnt);
                }
@@ -983,29 +943,19 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
 
 SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)
 {
-       long ret;
-
        if (force_o_largefile())
                flags |= O_LARGEFILE;
 
-       ret = do_sys_open(AT_FDCWD, filename, flags, mode);
-       /* avoid REGPARM breakage on x86: */
-       asmlinkage_protect(3, ret, filename, flags, mode);
-       return ret;
+       return do_sys_open(AT_FDCWD, filename, flags, mode);
 }
 
 SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags,
                umode_t, mode)
 {
-       long ret;
-
        if (force_o_largefile())
                flags |= O_LARGEFILE;
 
-       ret = do_sys_open(dfd, filename, flags, mode);
-       /* avoid REGPARM breakage on x86: */
-       asmlinkage_protect(4, ret, dfd, filename, flags, mode);
-       return ret;
+       return do_sys_open(dfd, filename, flags, mode);
 }
 
 #ifndef __alpha__