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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs changes from Al Viro.
"A lot of misc stuff. The obvious groups:
* Miklos' atomic_open series; kills the damn abuse of
->d_revalidate() by NFS, which was the major stumbling block for
all work in that area.
* ripping security_file_mmap() and dealing with deadlocks in the
area; sanitizing the neighborhood of vm_mmap()/vm_munmap() in
general.
* ->encode_fh() switched to saner API; insane fake dentry in
mm/cleancache.c gone.
* assorted annotations in fs (endianness, __user)
* parts of Artem's ->s_dirty work (jff2 and reiserfs parts)
* ->update_time() work from Josef.
* other bits and pieces all over the place.

Normally it would've been in two or three pull requests, but
signal.git stuff had eaten a lot of time during this cycle ;-/"

Fix up trivial conflicts in Documentation/filesystems/vfs.txt (the
'truncate_range' inode method was removed by the VM changes, the VFS
update adds an 'update_time()' method), and in fs/btrfs/ulist.[ch] (due
to sparse fix added twice, with other changes nearby).

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (95 commits)
nfs: don't open in ->d_revalidate
vfs: retry last component if opening stale dentry
vfs: nameidata_to_filp(): don't throw away file on error
vfs: nameidata_to_filp(): inline __dentry_open()
vfs: do_dentry_open(): don't put filp
vfs: split __dentry_open()
vfs: do_last() common post lookup
vfs: do_last(): add audit_inode before open
vfs: do_last(): only return EISDIR for O_CREAT
vfs: do_last(): check LOOKUP_DIRECTORY
vfs: do_last(): make ENOENT exit RCU safe
vfs: make follow_link check RCU safe
vfs: do_last(): use inode variable
vfs: do_last(): inline walk_component()
vfs: do_last(): make exit RCU safe
vfs: split do_lookup()
Btrfs: move over to use ->update_time
fs: introduce inode operation ->update_time
reiserfs: get rid of resierfs_sync_super
reiserfs: mark the superblock as dirty a bit later
...

+1497 -1620
+3
Documentation/filesystems/Locking
··· 61 61 ssize_t (*listxattr) (struct dentry *, char *, size_t); 62 62 int (*removexattr) (struct dentry *, const char *); 63 63 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len); 64 + void (*update_time)(struct inode *, struct timespec *, int); 64 65 65 66 locking rules: 66 67 all may block ··· 88 87 listxattr: no 89 88 removexattr: yes 90 89 fiemap: no 90 + update_time: no 91 + 91 92 Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on 92 93 victim. 93 94 cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
+4
Documentation/filesystems/vfs.txt
··· 363 363 ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); 364 364 ssize_t (*listxattr) (struct dentry *, char *, size_t); 365 365 int (*removexattr) (struct dentry *, const char *); 366 + void (*update_time)(struct inode *, struct timespec *, int); 366 367 }; 367 368 368 369 Again, all methods are called without any locks being held, unless ··· 472 471 removexattr: called by the VFS to remove an extended attribute from 473 472 a file. This method is called by removexattr(2) system call. 474 473 474 + update_time: called by the VFS to update a specific time or the i_version of 475 + an inode. If this is not defined the VFS will update the inode itself 476 + and call mark_inode_dirty_sync. 475 477 476 478 The Address Space Object 477 479 ========================
-3
arch/alpha/include/asm/posix_types.h
··· 10 10 typedef unsigned int __kernel_ino_t; 11 11 #define __kernel_ino_t __kernel_ino_t 12 12 13 - typedef unsigned int __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned long __kernel_sigset_t; /* at least 32 bits */ 17 14 18 15 #include <asm-generic/posix_types.h>
-3
arch/arm/include/asm/posix_types.h
··· 22 22 typedef unsigned short __kernel_mode_t; 23 23 #define __kernel_mode_t __kernel_mode_t 24 24 25 - typedef unsigned short __kernel_nlink_t; 26 - #define __kernel_nlink_t __kernel_nlink_t 27 - 28 25 typedef unsigned short __kernel_ipc_pid_t; 29 26 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 30 27
-3
arch/avr32/include/asm/posix_types.h
··· 17 17 typedef unsigned short __kernel_mode_t; 18 18 #define __kernel_mode_t __kernel_mode_t 19 19 20 - typedef unsigned short __kernel_nlink_t; 21 - #define __kernel_nlink_t __kernel_nlink_t 22 - 23 20 typedef unsigned short __kernel_ipc_pid_t; 24 21 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 25 22
-3
arch/blackfin/include/asm/posix_types.h
··· 10 10 typedef unsigned short __kernel_mode_t; 11 11 #define __kernel_mode_t __kernel_mode_t 12 12 13 - typedef unsigned short __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned int __kernel_ipc_pid_t; 17 14 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 18 15
-3
arch/cris/include/asm/posix_types.h
··· 15 15 typedef unsigned short __kernel_mode_t; 16 16 #define __kernel_mode_t __kernel_mode_t 17 17 18 - typedef unsigned short __kernel_nlink_t; 19 - #define __kernel_nlink_t __kernel_nlink_t 20 - 21 18 typedef unsigned short __kernel_ipc_pid_t; 22 19 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 23 20
-3
arch/frv/include/asm/posix_types.h
··· 10 10 typedef unsigned short __kernel_mode_t; 11 11 #define __kernel_mode_t __kernel_mode_t 12 12 13 - typedef unsigned short __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned short __kernel_ipc_pid_t; 17 14 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 18 15
-3
arch/h8300/include/asm/posix_types.h
··· 10 10 typedef unsigned short __kernel_mode_t; 11 11 #define __kernel_mode_t __kernel_mode_t 12 12 13 - typedef unsigned short __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned short __kernel_ipc_pid_t; 17 14 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 18 15
-3
arch/ia64/include/asm/posix_types.h
··· 1 1 #ifndef _ASM_IA64_POSIX_TYPES_H 2 2 #define _ASM_IA64_POSIX_TYPES_H 3 3 4 - typedef unsigned int __kernel_nlink_t; 5 - #define __kernel_nlink_t __kernel_nlink_t 6 - 7 4 typedef unsigned long __kernel_sigset_t; /* at least 32 bits */ 8 5 9 6 #include <asm-generic/posix_types.h>
+2 -8
arch/ia64/kernel/perfmon.c
··· 604 604 spin_unlock(&(x)->ctx_lock); 605 605 } 606 606 607 - static inline unsigned long 608 - pfm_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags, unsigned long exec) 609 - { 610 - return get_unmapped_area(file, addr, len, pgoff, flags); 611 - } 612 - 613 607 /* forward declaration */ 614 608 static const struct dentry_operations pfmfs_dentry_operations; 615 609 ··· 2327 2333 down_write(&task->mm->mmap_sem); 2328 2334 2329 2335 /* find some free area in address space, must have mmap sem held */ 2330 - vma->vm_start = pfm_get_unmapped_area(NULL, 0, size, 0, MAP_PRIVATE|MAP_ANONYMOUS, 0); 2331 - if (vma->vm_start == 0UL) { 2336 + vma->vm_start = get_unmapped_area(NULL, 0, size, 0, MAP_PRIVATE|MAP_ANONYMOUS); 2337 + if (IS_ERR_VALUE(vma->vm_start)) { 2332 2338 DPRINT(("Cannot find unmapped area for size %ld\n", size)); 2333 2339 up_write(&task->mm->mmap_sem); 2334 2340 goto error;
+3 -16
arch/ia64/kernel/sys_ia64.c
··· 171 171 ia64_mremap (unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, 172 172 unsigned long new_addr) 173 173 { 174 - extern unsigned long do_mremap (unsigned long addr, 175 - unsigned long old_len, 176 - unsigned long new_len, 177 - unsigned long flags, 178 - unsigned long new_addr); 179 - 180 - down_write(&current->mm->mmap_sem); 181 - { 182 - addr = do_mremap(addr, old_len, new_len, flags, new_addr); 183 - } 184 - up_write(&current->mm->mmap_sem); 185 - 186 - if (IS_ERR((void *) addr)) 187 - return addr; 188 - 189 - force_successful_syscall_return(); 174 + addr = sys_mremap(addr, old_len, new_len, flags, new_addr); 175 + if (!IS_ERR((void *) addr)) 176 + force_successful_syscall_return(); 190 177 return addr; 191 178 } 192 179
-3
arch/m32r/include/asm/posix_types.h
··· 10 10 typedef unsigned short __kernel_mode_t; 11 11 #define __kernel_mode_t __kernel_mode_t 12 12 13 - typedef unsigned short __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned short __kernel_ipc_pid_t; 17 14 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 18 15
-3
arch/m68k/include/asm/posix_types.h
··· 10 10 typedef unsigned short __kernel_mode_t; 11 11 #define __kernel_mode_t __kernel_mode_t 12 12 13 - typedef unsigned short __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned short __kernel_ipc_pid_t; 17 14 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 18 15
-5
arch/mips/include/asm/posix_types.h
··· 17 17 * assume GCC is being used. 18 18 */ 19 19 20 - #if (_MIPS_SZLONG == 64) 21 - typedef unsigned int __kernel_nlink_t; 22 - #define __kernel_nlink_t __kernel_nlink_t 23 - #endif 24 - 25 20 typedef long __kernel_daddr_t; 26 21 #define __kernel_daddr_t __kernel_daddr_t 27 22
+3 -3
arch/mips/include/asm/stat.h
··· 20 20 long st_pad1[3]; /* Reserved for network id */ 21 21 ino_t st_ino; 22 22 mode_t st_mode; 23 - nlink_t st_nlink; 23 + __u32 st_nlink; 24 24 uid_t st_uid; 25 25 gid_t st_gid; 26 26 unsigned st_rdev; ··· 55 55 unsigned long long st_ino; 56 56 57 57 mode_t st_mode; 58 - nlink_t st_nlink; 58 + __u32 st_nlink; 59 59 60 60 uid_t st_uid; 61 61 gid_t st_gid; ··· 96 96 unsigned long st_ino; 97 97 98 98 mode_t st_mode; 99 - nlink_t st_nlink; 99 + __u32 st_nlink; 100 100 101 101 uid_t st_uid; 102 102 gid_t st_gid;
-3
arch/mn10300/include/asm/posix_types.h
··· 20 20 typedef unsigned short __kernel_mode_t; 21 21 #define __kernel_mode_t __kernel_mode_t 22 22 23 - typedef unsigned short __kernel_nlink_t; 24 - #define __kernel_nlink_t __kernel_nlink_t 25 - 26 23 typedef unsigned short __kernel_ipc_pid_t; 27 24 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 28 25
-3
arch/parisc/include/asm/posix_types.h
··· 10 10 typedef unsigned short __kernel_mode_t; 11 11 #define __kernel_mode_t __kernel_mode_t 12 12 13 - typedef unsigned short __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned short __kernel_ipc_pid_t; 17 14 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 18 15
+2 -2
arch/parisc/include/asm/stat.h
··· 7 7 unsigned int st_dev; /* dev_t is 32 bits on parisc */ 8 8 ino_t st_ino; /* 32 bits */ 9 9 mode_t st_mode; /* 16 bits */ 10 - nlink_t st_nlink; /* 16 bits */ 10 + unsigned short st_nlink; /* 16 bits */ 11 11 unsigned short st_reserved1; /* old st_uid */ 12 12 unsigned short st_reserved2; /* old st_gid */ 13 13 unsigned int st_rdev; ··· 42 42 unsigned int st_dev; /* dev_t is 32 bits on parisc */ 43 43 ino_t st_ino; /* 32 bits */ 44 44 mode_t st_mode; /* 16 bits */ 45 - nlink_t st_nlink; /* 16 bits */ 45 + unsigned short st_nlink; /* 16 bits */ 46 46 unsigned short st_reserved1; /* old st_uid */ 47 47 unsigned short st_reserved2; /* old st_gid */ 48 48 unsigned int st_rdev;
-3
arch/powerpc/include/asm/posix_types.h
··· 16 16 typedef long __kernel_ptrdiff_t; 17 17 #define __kernel_size_t __kernel_size_t 18 18 19 - typedef unsigned short __kernel_nlink_t; 20 - #define __kernel_nlink_t __kernel_nlink_t 21 - 22 19 typedef short __kernel_ipc_pid_t; 23 20 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 24 21 #endif
+2 -2
arch/powerpc/include/asm/stat.h
··· 30 30 unsigned long st_dev; 31 31 ino_t st_ino; 32 32 #ifdef __powerpc64__ 33 - nlink_t st_nlink; 33 + unsigned short st_nlink; 34 34 mode_t st_mode; 35 35 #else 36 36 mode_t st_mode; 37 - nlink_t st_nlink; 37 + unsigned short st_nlink; 38 38 #endif 39 39 uid_t st_uid; 40 40 gid_t st_gid;
-3
arch/s390/include/asm/posix_types.h
··· 24 24 25 25 typedef unsigned long __kernel_ino_t; 26 26 typedef unsigned short __kernel_mode_t; 27 - typedef unsigned short __kernel_nlink_t; 28 27 typedef unsigned short __kernel_ipc_pid_t; 29 28 typedef unsigned short __kernel_uid_t; 30 29 typedef unsigned short __kernel_gid_t; ··· 34 35 35 36 typedef unsigned int __kernel_ino_t; 36 37 typedef unsigned int __kernel_mode_t; 37 - typedef unsigned int __kernel_nlink_t; 38 38 typedef int __kernel_ipc_pid_t; 39 39 typedef unsigned int __kernel_uid_t; 40 40 typedef unsigned int __kernel_gid_t; ··· 45 47 46 48 #define __kernel_ino_t __kernel_ino_t 47 49 #define __kernel_mode_t __kernel_mode_t 48 - #define __kernel_nlink_t __kernel_nlink_t 49 50 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 50 51 #define __kernel_uid_t __kernel_uid_t 51 52 #define __kernel_gid_t __kernel_gid_t
-2
arch/sh/include/asm/posix_types_32.h
··· 3 3 4 4 typedef unsigned short __kernel_mode_t; 5 5 #define __kernel_mode_t __kernel_mode_t 6 - typedef unsigned short __kernel_nlink_t; 7 - #define __kernel_nlink_t __kernel_nlink_t 8 6 typedef unsigned short __kernel_ipc_pid_t; 9 7 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 10 8 typedef unsigned short __kernel_uid_t;
-2
arch/sh/include/asm/posix_types_64.h
··· 3 3 4 4 typedef unsigned short __kernel_mode_t; 5 5 #define __kernel_mode_t __kernel_mode_t 6 - typedef unsigned short __kernel_nlink_t; 7 - #define __kernel_nlink_t __kernel_nlink_t 8 6 typedef unsigned short __kernel_ipc_pid_t; 9 7 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 10 8 typedef unsigned short __kernel_uid_t;
-5
arch/sparc/include/asm/posix_types.h
··· 9 9 10 10 #if defined(__sparc__) && defined(__arch64__) 11 11 /* sparc 64 bit */ 12 - typedef unsigned int __kernel_nlink_t; 13 - #define __kernel_nlink_t __kernel_nlink_t 14 12 15 13 typedef unsigned short __kernel_old_uid_t; 16 14 typedef unsigned short __kernel_old_gid_t; ··· 35 37 36 38 typedef unsigned short __kernel_mode_t; 37 39 #define __kernel_mode_t __kernel_mode_t 38 - 39 - typedef short __kernel_nlink_t; 40 - #define __kernel_nlink_t __kernel_nlink_t 41 40 42 41 typedef long __kernel_daddr_t; 43 42 #define __kernel_daddr_t __kernel_daddr_t
+2 -9
arch/sparc/kernel/sys_sparc_64.c
··· 580 580 unsigned long, new_len, unsigned long, flags, 581 581 unsigned long, new_addr) 582 582 { 583 - unsigned long ret = -EINVAL; 584 - 585 583 if (test_thread_flag(TIF_32BIT)) 586 - goto out; 587 - 588 - down_write(&current->mm->mmap_sem); 589 - ret = do_mremap(addr, old_len, new_len, flags, new_addr); 590 - up_write(&current->mm->mmap_sem); 591 - out: 592 - return ret; 584 + return -EINVAL; 585 + return sys_mremap(addr, old_len, new_len, flags, new_addr); 593 586 } 594 587 595 588 /* we come to here via sys_nis_syscall so it can setup the regs argument */
-1
arch/tile/include/asm/compat.h
··· 44 44 typedef __kernel_mode_t compat_mode_t; 45 45 typedef __kernel_dev_t compat_dev_t; 46 46 typedef __kernel_loff_t compat_loff_t; 47 - typedef __kernel_nlink_t compat_nlink_t; 48 47 typedef __kernel_ipc_pid_t compat_ipc_pid_t; 49 48 typedef __kernel_daddr_t compat_daddr_t; 50 49 typedef __kernel_fsid_t compat_fsid_t;
-3
arch/x86/include/asm/posix_types_32.h
··· 10 10 typedef unsigned short __kernel_mode_t; 11 11 #define __kernel_mode_t __kernel_mode_t 12 12 13 - typedef unsigned short __kernel_nlink_t; 14 - #define __kernel_nlink_t __kernel_nlink_t 15 - 16 13 typedef unsigned short __kernel_ipc_pid_t; 17 14 #define __kernel_ipc_pid_t __kernel_ipc_pid_t 18 15
+1 -1
drivers/base/soc.c
··· 42 42 return &soc_dev->dev; 43 43 } 44 44 45 - static mode_t soc_attribute_mode(struct kobject *kobj, 45 + static umode_t soc_attribute_mode(struct kobject *kobj, 46 46 struct attribute *attr, 47 47 int index) 48 48 {
+1 -3
drivers/gpu/drm/i810/i810_dma.c
··· 130 130 return -EINVAL; 131 131 132 132 /* This is all entirely broken */ 133 - down_write(&current->mm->mmap_sem); 134 133 old_fops = file_priv->filp->f_op; 135 134 file_priv->filp->f_op = &i810_buffer_fops; 136 135 dev_priv->mmap_buffer = buf; 137 - buf_priv->virtual = (void *)do_mmap(file_priv->filp, 0, buf->total, 136 + buf_priv->virtual = (void *)vm_mmap(file_priv->filp, 0, buf->total, 138 137 PROT_READ | PROT_WRITE, 139 138 MAP_SHARED, buf->bus_address); 140 139 dev_priv->mmap_buffer = NULL; ··· 144 145 retcode = PTR_ERR(buf_priv->virtual); 145 146 buf_priv->virtual = NULL; 146 147 } 147 - up_write(&current->mm->mmap_sem); 148 148 149 149 return retcode; 150 150 }
+3 -21
fs/9p/vfs_inode_dotl.c
··· 68 68 return current_fsgid(); 69 69 } 70 70 71 - /** 72 - * v9fs_dentry_from_dir_inode - helper function to get the dentry from 73 - * dir inode. 74 - * 75 - */ 76 - 77 - static struct dentry *v9fs_dentry_from_dir_inode(struct inode *inode) 78 - { 79 - struct dentry *dentry; 80 - 81 - spin_lock(&inode->i_lock); 82 - /* Directory should have only one entry. */ 83 - BUG_ON(S_ISDIR(inode->i_mode) && !list_is_singular(&inode->i_dentry)); 84 - dentry = list_entry(inode->i_dentry.next, struct dentry, d_alias); 85 - spin_unlock(&inode->i_lock); 86 - return dentry; 87 - } 88 - 89 71 static int v9fs_test_inode_dotl(struct inode *inode, void *data) 90 72 { 91 73 struct v9fs_inode *v9inode = V9FS_I(inode); ··· 397 415 if (dir->i_mode & S_ISGID) 398 416 omode |= S_ISGID; 399 417 400 - dir_dentry = v9fs_dentry_from_dir_inode(dir); 418 + dir_dentry = dentry->d_parent; 401 419 dfid = v9fs_fid_lookup(dir_dentry); 402 420 if (IS_ERR(dfid)) { 403 421 err = PTR_ERR(dfid); ··· 775 793 dir->i_ino, old_dentry->d_name.name, dentry->d_name.name); 776 794 777 795 v9ses = v9fs_inode2v9ses(dir); 778 - dir_dentry = v9fs_dentry_from_dir_inode(dir); 796 + dir_dentry = dentry->d_parent; 779 797 dfid = v9fs_fid_lookup(dir_dentry); 780 798 if (IS_ERR(dfid)) 781 799 return PTR_ERR(dfid); ··· 840 858 return -EINVAL; 841 859 842 860 v9ses = v9fs_inode2v9ses(dir); 843 - dir_dentry = v9fs_dentry_from_dir_inode(dir); 861 + dir_dentry = dentry->d_parent; 844 862 dfid = v9fs_fid_lookup(dir_dentry); 845 863 if (IS_ERR(dfid)) { 846 864 err = PTR_ERR(dfid);
-8
fs/affs/affs.h
··· 18 18 #define AFFS_GET_HASHENTRY(data,hashkey) be32_to_cpu(((struct dir_front *)data)->hashtable[hashkey]) 19 19 #define AFFS_BLOCK(sb, bh, blk) (AFFS_HEAD(bh)->table[AFFS_SB(sb)->s_hashsize-1-(blk)]) 20 20 21 - #ifdef __LITTLE_ENDIAN 22 - #define BO_EXBITS 0x18UL 23 - #elif defined(__BIG_ENDIAN) 24 - #define BO_EXBITS 0x00UL 25 - #else 26 - #error Endianness must be known for affs to work. 27 - #endif 28 - 29 21 #define AFFS_HEAD(bh) ((struct affs_head *)(bh)->b_data) 30 22 #define AFFS_TAIL(sb, bh) ((struct affs_tail *)((bh)->b_data+(sb)->s_blocksize-sizeof(struct affs_tail))) 31 23 #define AFFS_ROOT_HEAD(bh) ((struct affs_root_head *)(bh)->b_data)
+3 -3
fs/aio.c
··· 134 134 info->mmap_size = nr_pages * PAGE_SIZE; 135 135 dprintk("attempting mmap of %lu bytes\n", info->mmap_size); 136 136 down_write(&ctx->mm->mmap_sem); 137 - info->mmap_base = do_mmap(NULL, 0, info->mmap_size, 138 - PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, 139 - 0); 137 + info->mmap_base = do_mmap_pgoff(NULL, 0, info->mmap_size, 138 + PROT_READ|PROT_WRITE, 139 + MAP_ANONYMOUS|MAP_PRIVATE, 0); 140 140 if (IS_ERR((void *)info->mmap_base)) { 141 141 up_write(&ctx->mm->mmap_sem); 142 142 info->mmap_size = 0;
+5
fs/attr.c
··· 176 176 return -EPERM; 177 177 } 178 178 179 + if ((ia_valid & ATTR_SIZE) && IS_I_VERSION(inode)) { 180 + if (attr->ia_size != inode->i_size) 181 + inode_inc_iversion(inode); 182 + } 183 + 179 184 if ((ia_valid & ATTR_MODE)) { 180 185 umode_t amode = attr->ia_mode; 181 186 /* Flag setting protected by i_mutex */
+3 -5
fs/binfmt_elf.c
··· 329 329 if (!size) 330 330 return addr; 331 331 332 - down_write(&current->mm->mmap_sem); 333 332 /* 334 333 * total_size is the size of the ELF (interpreter) image. 335 334 * The _first_ mmap needs to know the full size, otherwise ··· 339 340 */ 340 341 if (total_size) { 341 342 total_size = ELF_PAGEALIGN(total_size); 342 - map_addr = do_mmap(filep, addr, total_size, prot, type, off); 343 + map_addr = vm_mmap(filep, addr, total_size, prot, type, off); 343 344 if (!BAD_ADDR(map_addr)) 344 - do_munmap(current->mm, map_addr+size, total_size-size); 345 + vm_munmap(map_addr+size, total_size-size); 345 346 } else 346 - map_addr = do_mmap(filep, addr, size, prot, type, off); 347 + map_addr = vm_mmap(filep, addr, size, prot, type, off); 347 348 348 - up_write(&current->mm->mmap_sem); 349 349 return(map_addr); 350 350 } 351 351
+4 -4
fs/binfmt_flat.c
··· 562 562 realdatastart = (unsigned long) -ENOMEM; 563 563 printk("Unable to allocate RAM for process data, errno %d\n", 564 564 (int)-realdatastart); 565 - do_munmap(current->mm, textpos, text_len); 565 + vm_munmap(textpos, text_len); 566 566 ret = realdatastart; 567 567 goto err; 568 568 } ··· 586 586 } 587 587 if (IS_ERR_VALUE(result)) { 588 588 printk("Unable to read data+bss, errno %d\n", (int)-result); 589 - do_munmap(current->mm, textpos, text_len); 590 - do_munmap(current->mm, realdatastart, len); 589 + vm_munmap(textpos, text_len); 590 + vm_munmap(realdatastart, len); 591 591 ret = result; 592 592 goto err; 593 593 } ··· 654 654 } 655 655 if (IS_ERR_VALUE(result)) { 656 656 printk("Unable to read code+data+bss, errno %d\n",(int)-result); 657 - do_munmap(current->mm, textpos, text_len + data_len + extra + 657 + vm_munmap(textpos, text_len + data_len + extra + 658 658 MAX_SHARED_LIBS * sizeof(unsigned long)); 659 659 ret = result; 660 660 goto err;
-1
fs/btrfs/ctree.h
··· 2974 2974 void btrfs_evict_inode(struct inode *inode); 2975 2975 int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc); 2976 2976 int btrfs_dirty_inode(struct inode *inode); 2977 - int btrfs_update_time(struct file *file); 2978 2977 struct inode *btrfs_alloc_inode(struct super_block *sb); 2979 2978 void btrfs_destroy_inode(struct inode *inode); 2980 2979 int btrfs_drop_inode(struct inode *inode);
+4 -11
fs/btrfs/export.c
··· 13 13 parent_root_objectid) / 4) 14 14 #define BTRFS_FID_SIZE_CONNECTABLE_ROOT (sizeof(struct btrfs_fid) / 4) 15 15 16 - static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, 17 - int connectable) 16 + static int btrfs_encode_fh(struct inode *inode, u32 *fh, int *max_len, 17 + struct inode *parent) 18 18 { 19 19 struct btrfs_fid *fid = (struct btrfs_fid *)fh; 20 - struct inode *inode = dentry->d_inode; 21 20 int len = *max_len; 22 21 int type; 23 22 24 - if (connectable && (len < BTRFS_FID_SIZE_CONNECTABLE)) { 23 + if (parent && (len < BTRFS_FID_SIZE_CONNECTABLE)) { 25 24 *max_len = BTRFS_FID_SIZE_CONNECTABLE; 26 25 return 255; 27 26 } else if (len < BTRFS_FID_SIZE_NON_CONNECTABLE) { ··· 35 36 fid->root_objectid = BTRFS_I(inode)->root->objectid; 36 37 fid->gen = inode->i_generation; 37 38 38 - if (connectable && !S_ISDIR(inode->i_mode)) { 39 - struct inode *parent; 39 + if (parent) { 40 40 u64 parent_root_id; 41 41 42 - spin_lock(&dentry->d_lock); 43 - 44 - parent = dentry->d_parent->d_inode; 45 42 fid->parent_objectid = BTRFS_I(parent)->location.objectid; 46 43 fid->parent_gen = parent->i_generation; 47 44 parent_root_id = BTRFS_I(parent)->root->objectid; 48 - 49 - spin_unlock(&dentry->d_lock); 50 45 51 46 if (parent_root_id != fid->root_objectid) { 52 47 fid->parent_root_objectid = parent_root_id;
+1 -1
fs/btrfs/file.c
··· 1433 1433 goto out; 1434 1434 } 1435 1435 1436 - err = btrfs_update_time(file); 1436 + err = file_update_time(file); 1437 1437 if (err) { 1438 1438 mutex_unlock(&inode->i_mutex); 1439 1439 goto out;
+4 -3
fs/btrfs/free-space-cache.c
··· 77 77 return ERR_PTR(-ENOENT); 78 78 } 79 79 80 - inode->i_mapping->flags &= ~__GFP_FS; 80 + mapping_set_gfp_mask(inode->i_mapping, 81 + mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 81 82 82 83 return inode; 83 84 } ··· 368 367 369 368 static void io_ctl_set_generation(struct io_ctl *io_ctl, u64 generation) 370 369 { 371 - u64 *val; 370 + __le64 *val; 372 371 373 372 io_ctl_map_page(io_ctl, 1); 374 373 ··· 391 390 392 391 static int io_ctl_check_generation(struct io_ctl *io_ctl, u64 generation) 393 392 { 394 - u64 *gen; 393 + __le64 *gen; 395 394 396 395 /* 397 396 * Skip the crc area. If we don't check crcs then we just have a 64bit
+14 -39
fs/btrfs/inode.c
··· 4475 4475 * This is a copy of file_update_time. We need this so we can return error on 4476 4476 * ENOSPC for updating the inode in the case of file write and mmap writes. 4477 4477 */ 4478 - int btrfs_update_time(struct file *file) 4478 + static int btrfs_update_time(struct inode *inode, struct timespec *now, 4479 + int flags) 4479 4480 { 4480 - struct inode *inode = file->f_path.dentry->d_inode; 4481 - struct timespec now; 4482 - int ret; 4483 - enum { S_MTIME = 1, S_CTIME = 2, S_VERSION = 4 } sync_it = 0; 4484 - 4485 - /* First try to exhaust all avenues to not sync */ 4486 - if (IS_NOCMTIME(inode)) 4487 - return 0; 4488 - 4489 - now = current_fs_time(inode->i_sb); 4490 - if (!timespec_equal(&inode->i_mtime, &now)) 4491 - sync_it = S_MTIME; 4492 - 4493 - if (!timespec_equal(&inode->i_ctime, &now)) 4494 - sync_it |= S_CTIME; 4495 - 4496 - if (IS_I_VERSION(inode)) 4497 - sync_it |= S_VERSION; 4498 - 4499 - if (!sync_it) 4500 - return 0; 4501 - 4502 - /* Finally allowed to write? Takes lock. */ 4503 - if (mnt_want_write_file(file)) 4504 - return 0; 4505 - 4506 - /* Only change inode inside the lock region */ 4507 - if (sync_it & S_VERSION) 4481 + if (flags & S_VERSION) 4508 4482 inode_inc_iversion(inode); 4509 - if (sync_it & S_CTIME) 4510 - inode->i_ctime = now; 4511 - if (sync_it & S_MTIME) 4512 - inode->i_mtime = now; 4513 - ret = btrfs_dirty_inode(inode); 4514 - if (!ret) 4515 - mark_inode_dirty_sync(inode); 4516 - mnt_drop_write(file->f_path.mnt); 4517 - return ret; 4483 + if (flags & S_CTIME) 4484 + inode->i_ctime = *now; 4485 + if (flags & S_MTIME) 4486 + inode->i_mtime = *now; 4487 + if (flags & S_ATIME) 4488 + inode->i_atime = *now; 4489 + return btrfs_dirty_inode(inode); 4518 4490 } 4519 4491 4520 4492 /* ··· 6537 6565 6538 6566 ret = btrfs_delalloc_reserve_space(inode, PAGE_CACHE_SIZE); 6539 6567 if (!ret) { 6540 - ret = btrfs_update_time(vma->vm_file); 6568 + ret = file_update_time(vma->vm_file); 6541 6569 reserved = 1; 6542 6570 } 6543 6571 if (ret) { ··· 7607 7635 .permission = btrfs_permission, 7608 7636 .fiemap = btrfs_fiemap, 7609 7637 .get_acl = btrfs_get_acl, 7638 + .update_time = btrfs_update_time, 7610 7639 }; 7611 7640 static const struct inode_operations btrfs_special_inode_operations = { 7612 7641 .getattr = btrfs_getattr, ··· 7618 7645 .listxattr = btrfs_listxattr, 7619 7646 .removexattr = btrfs_removexattr, 7620 7647 .get_acl = btrfs_get_acl, 7648 + .update_time = btrfs_update_time, 7621 7649 }; 7622 7650 static const struct inode_operations btrfs_symlink_inode_operations = { 7623 7651 .readlink = generic_readlink, ··· 7632 7658 .listxattr = btrfs_listxattr, 7633 7659 .removexattr = btrfs_removexattr, 7634 7660 .get_acl = btrfs_get_acl, 7661 + .update_time = btrfs_update_time, 7635 7662 }; 7636 7663 7637 7664 const struct dentry_operations btrfs_dentry_operations = {
+1 -1
fs/buffer.c
··· 3152 3152 /* 3153 3153 * Buffer-head allocation 3154 3154 */ 3155 - static struct kmem_cache *bh_cachep; 3155 + static struct kmem_cache *bh_cachep __read_mostly; 3156 3156 3157 3157 /* 3158 3158 * Once the number of bh's in the machine exceeds this level, we start
+21 -11
fs/ceph/export.c
··· 40 40 u32 parent_name_hash; 41 41 } __attribute__ ((packed)); 42 42 43 - static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len, 44 - int connectable) 43 + /* 44 + * The presence of @parent_inode here tells us whether NFS wants a 45 + * connectable file handle. However, we want to make a connectionable 46 + * file handle unconditionally so that the MDS gets as much of a hint 47 + * as possible. That means we only use @parent_dentry to indicate 48 + * whether nfsd wants a connectable fh, and whether we should indicate 49 + * failure from a too-small @max_len. 50 + */ 51 + static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len, 52 + struct inode *parent_inode) 45 53 { 46 54 int type; 47 55 struct ceph_nfs_fh *fh = (void *)rawfh; 48 56 struct ceph_nfs_confh *cfh = (void *)rawfh; 49 - struct dentry *parent; 50 - struct inode *inode = dentry->d_inode; 51 57 int connected_handle_length = sizeof(*cfh)/4; 52 58 int handle_length = sizeof(*fh)/4; 59 + struct dentry *dentry = d_find_alias(inode); 60 + struct dentry *parent; 53 61 54 62 /* don't re-export snaps */ 55 63 if (ceph_snap(inode) != CEPH_NOSNAP) 56 64 return -EINVAL; 57 65 58 - spin_lock(&dentry->d_lock); 59 - parent = dentry->d_parent; 60 - if (*max_len >= connected_handle_length) { 66 + /* if we found an alias, generate a connectable fh */ 67 + if (*max_len >= connected_handle_length && dentry) { 61 68 dout("encode_fh %p connectable\n", dentry); 62 - cfh->ino = ceph_ino(dentry->d_inode); 69 + spin_lock(&dentry->d_lock); 70 + parent = dentry->d_parent; 71 + cfh->ino = ceph_ino(inode); 63 72 cfh->parent_ino = ceph_ino(parent->d_inode); 64 73 cfh->parent_name_hash = ceph_dentry_hash(parent->d_inode, 65 74 dentry); 66 75 *max_len = connected_handle_length; 67 76 type = 2; 77 + spin_unlock(&dentry->d_lock); 68 78 } else if (*max_len >= handle_length) { 69 - if (connectable) { 79 + if (parent_inode) { 80 + /* nfsd wants connectable */ 70 81 *max_len = connected_handle_length; 71 82 type = 255; 72 83 } else { 73 84 dout("encode_fh %p\n", dentry); 74 - fh->ino = ceph_ino(dentry->d_inode); 85 + fh->ino = ceph_ino(inode); 75 86 *max_len = handle_length; 76 87 type = 1; 77 88 } ··· 90 79 *max_len = handle_length; 91 80 type = 255; 92 81 } 93 - spin_unlock(&dentry->d_lock); 94 82 return type; 95 83 } 96 84
+14 -19
fs/compat.c
··· 871 871 { 872 872 int error; 873 873 struct file *file; 874 + int fput_needed; 874 875 struct compat_readdir_callback buf; 875 876 876 - error = -EBADF; 877 - file = fget(fd); 877 + file = fget_light(fd, &fput_needed); 878 878 if (!file) 879 - goto out; 879 + return -EBADF; 880 880 881 881 buf.result = 0; 882 882 buf.dirent = dirent; ··· 885 885 if (buf.result) 886 886 error = buf.result; 887 887 888 - fput(file); 889 - out: 888 + fput_light(file, fput_needed); 890 889 return error; 891 890 } 892 891 ··· 952 953 struct file * file; 953 954 struct compat_linux_dirent __user * lastdirent; 954 955 struct compat_getdents_callback buf; 956 + int fput_needed; 955 957 int error; 956 958 957 - error = -EFAULT; 958 959 if (!access_ok(VERIFY_WRITE, dirent, count)) 959 - goto out; 960 + return -EFAULT; 960 961 961 - error = -EBADF; 962 - file = fget(fd); 962 + file = fget_light(fd, &fput_needed); 963 963 if (!file) 964 - goto out; 964 + return -EBADF; 965 965 966 966 buf.current_dir = dirent; 967 967 buf.previous = NULL; ··· 977 979 else 978 980 error = count - buf.count; 979 981 } 980 - fput(file); 981 - out: 982 + fput_light(file, fput_needed); 982 983 return error; 983 984 } 984 985 ··· 1038 1041 struct file * file; 1039 1042 struct linux_dirent64 __user * lastdirent; 1040 1043 struct compat_getdents_callback64 buf; 1044 + int fput_needed; 1041 1045 int error; 1042 1046 1043 - error = -EFAULT; 1044 1047 if (!access_ok(VERIFY_WRITE, dirent, count)) 1045 - goto out; 1048 + return -EFAULT; 1046 1049 1047 - error = -EBADF; 1048 - file = fget(fd); 1050 + file = fget_light(fd, &fput_needed); 1049 1051 if (!file) 1050 - goto out; 1052 + return -EBADF; 1051 1053 1052 1054 buf.current_dir = dirent; 1053 1055 buf.previous = NULL; ··· 1064 1068 else 1065 1069 error = count - buf.count; 1066 1070 } 1067 - fput(file); 1068 - out: 1071 + fput_light(file, fput_needed); 1069 1072 return error; 1070 1073 } 1071 1074 #endif /* ! __ARCH_OMIT_COMPAT_SYS_GETDENTS64 */
+8 -12
fs/dcache.c
··· 683 683 /** 684 684 * d_find_alias - grab a hashed alias of inode 685 685 * @inode: inode in question 686 - * @want_discon: flag, used by d_splice_alias, to request 687 - * that only a DISCONNECTED alias be returned. 688 686 * 689 687 * If inode has a hashed alias, or is a directory and has any alias, 690 688 * acquire the reference to alias and return it. Otherwise return NULL. ··· 691 693 * of a filesystem. 692 694 * 693 695 * If the inode has an IS_ROOT, DCACHE_DISCONNECTED alias, then prefer 694 - * any other hashed alias over that one unless @want_discon is set, 695 - * in which case only return an IS_ROOT, DCACHE_DISCONNECTED alias. 696 + * any other hashed alias over that. 696 697 */ 697 - static struct dentry *__d_find_alias(struct inode *inode, int want_discon) 698 + static struct dentry *__d_find_alias(struct inode *inode) 698 699 { 699 700 struct dentry *alias, *discon_alias; 700 701 ··· 705 708 if (IS_ROOT(alias) && 706 709 (alias->d_flags & DCACHE_DISCONNECTED)) { 707 710 discon_alias = alias; 708 - } else if (!want_discon) { 711 + } else { 709 712 __dget_dlock(alias); 710 713 spin_unlock(&alias->d_lock); 711 714 return alias; ··· 736 739 737 740 if (!list_empty(&inode->i_dentry)) { 738 741 spin_lock(&inode->i_lock); 739 - de = __d_find_alias(inode, 0); 742 + de = __d_find_alias(inode); 740 743 spin_unlock(&inode->i_lock); 741 744 } 742 745 return de; ··· 1647 1650 1648 1651 if (inode && S_ISDIR(inode->i_mode)) { 1649 1652 spin_lock(&inode->i_lock); 1650 - new = __d_find_alias(inode, 1); 1653 + new = __d_find_any_alias(inode); 1651 1654 if (new) { 1652 - BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED)); 1653 1655 spin_unlock(&inode->i_lock); 1654 1656 security_d_instantiate(new, inode); 1655 1657 d_move(new, dentry); ··· 2478 2482 struct dentry *alias; 2479 2483 2480 2484 /* Does an aliased dentry already exist? */ 2481 - alias = __d_find_alias(inode, 0); 2485 + alias = __d_find_alias(inode); 2482 2486 if (alias) { 2483 2487 actual = alias; 2484 2488 write_seqlock(&rename_lock); ··· 2571 2575 bool slash = false; 2572 2576 int error = 0; 2573 2577 2574 - br_read_lock(vfsmount_lock); 2578 + br_read_lock(&vfsmount_lock); 2575 2579 while (dentry != root->dentry || vfsmnt != root->mnt) { 2576 2580 struct dentry * parent; 2577 2581 ··· 2602 2606 error = prepend(buffer, buflen, "/", 1); 2603 2607 2604 2608 out: 2605 - br_read_unlock(vfsmount_lock); 2609 + br_read_unlock(&vfsmount_lock); 2606 2610 return error; 2607 2611 2608 2612 global_root:
+11 -41
fs/ecryptfs/inode.c
··· 660 660 { 661 661 struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry); 662 662 char *lower_buf; 663 - size_t lower_bufsiz = PATH_MAX; 664 663 mm_segment_t old_fs; 665 664 int rc; 666 665 667 - lower_buf = kmalloc(lower_bufsiz, GFP_KERNEL); 666 + lower_buf = kmalloc(PATH_MAX, GFP_KERNEL); 668 667 if (!lower_buf) { 669 668 rc = -ENOMEM; 670 669 goto out; ··· 672 673 set_fs(get_ds()); 673 674 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry, 674 675 (char __user *)lower_buf, 675 - lower_bufsiz); 676 + PATH_MAX); 676 677 set_fs(old_fs); 677 678 if (rc < 0) 678 679 goto out; 679 - lower_bufsiz = rc; 680 680 rc = ecryptfs_decode_and_decrypt_filename(buf, bufsiz, dentry, 681 - lower_buf, lower_bufsiz); 681 + lower_buf, rc); 682 682 out: 683 683 kfree(lower_buf); 684 - return rc; 685 - } 686 - 687 - static int 688 - ecryptfs_readlink(struct dentry *dentry, char __user *buf, int bufsiz) 689 - { 690 - char *kbuf; 691 - size_t kbufsiz, copied; 692 - int rc; 693 - 694 - rc = ecryptfs_readlink_lower(dentry, &kbuf, &kbufsiz); 695 - if (rc) 696 - goto out; 697 - copied = min_t(size_t, bufsiz, kbufsiz); 698 - rc = copy_to_user(buf, kbuf, copied) ? -EFAULT : copied; 699 - kfree(kbuf); 700 - fsstack_copy_attr_atime(dentry->d_inode, 701 - ecryptfs_dentry_to_lower(dentry)->d_inode); 702 - out: 703 684 return rc; 704 685 } 705 686 706 687 static void *ecryptfs_follow_link(struct dentry *dentry, struct nameidata *nd) 707 688 { 708 689 char *buf; 709 - int len = PAGE_SIZE, rc; 710 - mm_segment_t old_fs; 690 + size_t len = PATH_MAX; 691 + int rc; 711 692 712 - /* Released in ecryptfs_put_link(); only release here on error */ 713 - buf = kmalloc(len, GFP_KERNEL); 714 - if (!buf) { 715 - buf = ERR_PTR(-ENOMEM); 693 + rc = ecryptfs_readlink_lower(dentry, &buf, &len); 694 + if (rc) 716 695 goto out; 717 - } 718 - old_fs = get_fs(); 719 - set_fs(get_ds()); 720 - rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len); 721 - set_fs(old_fs); 722 - if (rc < 0) { 723 - kfree(buf); 724 - buf = ERR_PTR(rc); 725 - } else 726 - buf[rc] = '\0'; 696 + fsstack_copy_attr_atime(dentry->d_inode, 697 + ecryptfs_dentry_to_lower(dentry)->d_inode); 698 + buf[len] = '\0'; 727 699 out: 728 700 nd_set_link(nd, buf); 729 701 return NULL; ··· 1123 1153 } 1124 1154 1125 1155 const struct inode_operations ecryptfs_symlink_iops = { 1126 - .readlink = ecryptfs_readlink, 1156 + .readlink = generic_readlink, 1127 1157 .follow_link = ecryptfs_follow_link, 1128 1158 .put_link = ecryptfs_put_link, 1129 1159 .permission = ecryptfs_permission,
-4
fs/exec.c
··· 280 280 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags); 281 281 INIT_LIST_HEAD(&vma->anon_vma_chain); 282 282 283 - err = security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1); 284 - if (err) 285 - goto err; 286 - 287 283 err = insert_vm_struct(mm, vma); 288 284 if (err) 289 285 goto err;
+19 -14
fs/exportfs/expfs.c
··· 304 304 305 305 /** 306 306 * export_encode_fh - default export_operations->encode_fh function 307 - * @dentry: the dentry to encode 307 + * @inode: the object to encode 308 308 * @fh: where to store the file handle fragment 309 309 * @max_len: maximum length to store there 310 - * @connectable: whether to store parent information 310 + * @parent: parent directory inode, if wanted 311 311 * 312 312 * This default encode_fh function assumes that the 32 inode number 313 313 * is suitable for locating an inode, and that the generation number 314 314 * can be used to check that it is still valid. It places them in the 315 315 * filehandle fragment where export_decode_fh expects to find them. 316 316 */ 317 - static int export_encode_fh(struct dentry *dentry, struct fid *fid, 318 - int *max_len, int connectable) 317 + static int export_encode_fh(struct inode *inode, struct fid *fid, 318 + int *max_len, struct inode *parent) 319 319 { 320 - struct inode * inode = dentry->d_inode; 321 320 int len = *max_len; 322 321 int type = FILEID_INO32_GEN; 323 322 324 - if (connectable && (len < 4)) { 323 + if (parent && (len < 4)) { 325 324 *max_len = 4; 326 325 return 255; 327 326 } else if (len < 2) { ··· 331 332 len = 2; 332 333 fid->i32.ino = inode->i_ino; 333 334 fid->i32.gen = inode->i_generation; 334 - if (connectable && !S_ISDIR(inode->i_mode)) { 335 - struct inode *parent; 336 - 337 - spin_lock(&dentry->d_lock); 338 - parent = dentry->d_parent->d_inode; 335 + if (parent) { 339 336 fid->i32.parent_ino = parent->i_ino; 340 337 fid->i32.parent_gen = parent->i_generation; 341 - spin_unlock(&dentry->d_lock); 342 338 len = 4; 343 339 type = FILEID_INO32_GEN_PARENT; 344 340 } ··· 346 352 { 347 353 const struct export_operations *nop = dentry->d_sb->s_export_op; 348 354 int error; 355 + struct dentry *p = NULL; 356 + struct inode *inode = dentry->d_inode, *parent = NULL; 349 357 358 + if (connectable && !S_ISDIR(inode->i_mode)) { 359 + p = dget_parent(dentry); 360 + /* 361 + * note that while p might've ceased to be our parent already, 362 + * it's still pinned by and still positive. 363 + */ 364 + parent = p->d_inode; 365 + } 350 366 if (nop->encode_fh) 351 - error = nop->encode_fh(dentry, fid->raw, max_len, connectable); 367 + error = nop->encode_fh(inode, fid->raw, max_len, parent); 352 368 else 353 - error = export_encode_fh(dentry, fid, max_len, connectable); 369 + error = export_encode_fh(inode, fid, max_len, parent); 370 + dput(p); 354 371 355 372 return error; 356 373 }
+4 -5
fs/fat/inode.c
··· 735 735 } 736 736 737 737 static int 738 - fat_encode_fh(struct dentry *de, __u32 *fh, int *lenp, int connectable) 738 + fat_encode_fh(struct inode *inode, __u32 *fh, int *lenp, struct inode *parent) 739 739 { 740 740 int len = *lenp; 741 - struct inode *inode = de->d_inode; 742 741 u32 ipos_h, ipos_m, ipos_l; 743 742 744 743 if (len < 5) { ··· 753 754 fh[1] = inode->i_generation; 754 755 fh[2] = ipos_h; 755 756 fh[3] = ipos_m | MSDOS_I(inode)->i_logstart; 756 - spin_lock(&de->d_lock); 757 - fh[4] = ipos_l | MSDOS_I(de->d_parent->d_inode)->i_logstart; 758 - spin_unlock(&de->d_lock); 757 + fh[4] = ipos_l; 758 + if (parent) 759 + fh[4] |= MSDOS_I(parent)->i_logstart; 759 760 return 3; 760 761 } 761 762
+17 -25
fs/fcntl.c
··· 442 442 SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, unsigned long, arg) 443 443 { 444 444 struct file *filp; 445 + int fput_needed; 445 446 long err = -EBADF; 446 447 447 - filp = fget_raw(fd); 448 + filp = fget_raw_light(fd, &fput_needed); 448 449 if (!filp) 449 450 goto out; 450 451 451 452 if (unlikely(filp->f_mode & FMODE_PATH)) { 452 - if (!check_fcntl_cmd(cmd)) { 453 - fput(filp); 454 - goto out; 455 - } 453 + if (!check_fcntl_cmd(cmd)) 454 + goto out1; 456 455 } 457 456 458 457 err = security_file_fcntl(filp, cmd, arg); 459 - if (err) { 460 - fput(filp); 461 - return err; 462 - } 458 + if (!err) 459 + err = do_fcntl(fd, cmd, arg, filp); 463 460 464 - err = do_fcntl(fd, cmd, arg, filp); 465 - 466 - fput(filp); 461 + out1: 462 + fput_light(filp, fput_needed); 467 463 out: 468 464 return err; 469 465 } ··· 469 473 unsigned long, arg) 470 474 { 471 475 struct file * filp; 472 - long err; 476 + long err = -EBADF; 477 + int fput_needed; 473 478 474 - err = -EBADF; 475 - filp = fget_raw(fd); 479 + filp = fget_raw_light(fd, &fput_needed); 476 480 if (!filp) 477 481 goto out; 478 482 479 483 if (unlikely(filp->f_mode & FMODE_PATH)) { 480 - if (!check_fcntl_cmd(cmd)) { 481 - fput(filp); 482 - goto out; 483 - } 484 + if (!check_fcntl_cmd(cmd)) 485 + goto out1; 484 486 } 485 487 486 488 err = security_file_fcntl(filp, cmd, arg); 487 - if (err) { 488 - fput(filp); 489 - return err; 490 - } 491 - err = -EBADF; 489 + if (err) 490 + goto out1; 492 491 493 492 switch (cmd) { 494 493 case F_GETLK64: ··· 498 507 err = do_fcntl(fd, cmd, arg, filp); 499 508 break; 500 509 } 501 - fput(filp); 510 + out1: 511 + fput_light(filp, fput_needed); 502 512 out: 503 513 return err; 504 514 }
+8 -9
fs/file_table.c
··· 34 34 .max_files = NR_FILE 35 35 }; 36 36 37 - DECLARE_LGLOCK(files_lglock); 38 37 DEFINE_LGLOCK(files_lglock); 39 38 40 39 /* SLAB cache for file structures */ ··· 420 421 */ 421 422 void file_sb_list_add(struct file *file, struct super_block *sb) 422 423 { 423 - lg_local_lock(files_lglock); 424 + lg_local_lock(&files_lglock); 424 425 __file_sb_list_add(file, sb); 425 - lg_local_unlock(files_lglock); 426 + lg_local_unlock(&files_lglock); 426 427 } 427 428 428 429 /** ··· 435 436 void file_sb_list_del(struct file *file) 436 437 { 437 438 if (!list_empty(&file->f_u.fu_list)) { 438 - lg_local_lock_cpu(files_lglock, file_list_cpu(file)); 439 + lg_local_lock_cpu(&files_lglock, file_list_cpu(file)); 439 440 list_del_init(&file->f_u.fu_list); 440 - lg_local_unlock_cpu(files_lglock, file_list_cpu(file)); 441 + lg_local_unlock_cpu(&files_lglock, file_list_cpu(file)); 441 442 } 442 443 } 443 444 ··· 484 485 struct file *f; 485 486 486 487 retry: 487 - lg_global_lock(files_lglock); 488 + lg_global_lock(&files_lglock); 488 489 do_file_list_for_each_entry(sb, f) { 489 490 struct vfsmount *mnt; 490 491 if (!S_ISREG(f->f_path.dentry->d_inode->i_mode)) ··· 501 502 file_release_write(f); 502 503 mnt = mntget(f->f_path.mnt); 503 504 /* This can sleep, so we can't hold the spinlock. */ 504 - lg_global_unlock(files_lglock); 505 + lg_global_unlock(&files_lglock); 505 506 mnt_drop_write(mnt); 506 507 mntput(mnt); 507 508 goto retry; 508 509 } while_file_list_for_each_entry; 509 - lg_global_unlock(files_lglock); 510 + lg_global_unlock(&files_lglock); 510 511 } 511 512 512 513 void __init files_init(unsigned long mempages) ··· 524 525 n = (mempages * (PAGE_SIZE / 1024)) / 10; 525 526 files_stat.max_files = max_t(unsigned long, n, NR_FILE); 526 527 files_defer_init(); 527 - lg_lock_init(files_lglock); 528 + lg_lock_init(&files_lglock, "files_lglock"); 528 529 percpu_counter_init(&nr_files, 0); 529 530 }
+3 -1
fs/fuse/file.c
··· 962 962 if (err) 963 963 goto out; 964 964 965 - file_update_time(file); 965 + err = file_update_time(file); 966 + if (err) 967 + goto out; 966 968 967 969 if (file->f_flags & O_DIRECT) { 968 970 written = generic_file_direct_write(iocb, iov, &nr_segs,
+5 -12
fs/fuse/inode.c
··· 627 627 return ERR_PTR(err); 628 628 } 629 629 630 - static int fuse_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, 631 - int connectable) 630 + static int fuse_encode_fh(struct inode *inode, u32 *fh, int *max_len, 631 + struct inode *parent) 632 632 { 633 - struct inode *inode = dentry->d_inode; 634 - bool encode_parent = connectable && !S_ISDIR(inode->i_mode); 635 - int len = encode_parent ? 6 : 3; 633 + int len = parent ? 6 : 3; 636 634 u64 nodeid; 637 635 u32 generation; 638 636 ··· 646 648 fh[1] = (u32)(nodeid & 0xffffffff); 647 649 fh[2] = generation; 648 650 649 - if (encode_parent) { 650 - struct inode *parent; 651 - 652 - spin_lock(&dentry->d_lock); 653 - parent = dentry->d_parent->d_inode; 651 + if (parent) { 654 652 nodeid = get_fuse_inode(parent)->nodeid; 655 653 generation = parent->i_generation; 656 - spin_unlock(&dentry->d_lock); 657 654 658 655 fh[3] = (u32)(nodeid >> 32); 659 656 fh[4] = (u32)(nodeid & 0xffffffff); ··· 656 663 } 657 664 658 665 *max_len = len; 659 - return encode_parent ? 0x82 : 0x81; 666 + return parent ? 0x82 : 0x81; 660 667 } 661 668 662 669 static struct dentry *fuse_fh_to_dentry(struct super_block *sb,
+5 -12
fs/gfs2/export.c
··· 28 28 #define GFS2_LARGE_FH_SIZE 8 29 29 #define GFS2_OLD_FH_SIZE 10 30 30 31 - static int gfs2_encode_fh(struct dentry *dentry, __u32 *p, int *len, 32 - int connectable) 31 + static int gfs2_encode_fh(struct inode *inode, __u32 *p, int *len, 32 + struct inode *parent) 33 33 { 34 34 __be32 *fh = (__force __be32 *)p; 35 - struct inode *inode = dentry->d_inode; 36 35 struct super_block *sb = inode->i_sb; 37 36 struct gfs2_inode *ip = GFS2_I(inode); 38 37 39 - if (connectable && (*len < GFS2_LARGE_FH_SIZE)) { 38 + if (parent && (*len < GFS2_LARGE_FH_SIZE)) { 40 39 *len = GFS2_LARGE_FH_SIZE; 41 40 return 255; 42 41 } else if (*len < GFS2_SMALL_FH_SIZE) { ··· 49 50 fh[3] = cpu_to_be32(ip->i_no_addr & 0xFFFFFFFF); 50 51 *len = GFS2_SMALL_FH_SIZE; 51 52 52 - if (!connectable || inode == sb->s_root->d_inode) 53 + if (!parent || inode == sb->s_root->d_inode) 53 54 return *len; 54 55 55 - spin_lock(&dentry->d_lock); 56 - inode = dentry->d_parent->d_inode; 57 - ip = GFS2_I(inode); 58 - igrab(inode); 59 - spin_unlock(&dentry->d_lock); 56 + ip = GFS2_I(parent); 60 57 61 58 fh[4] = cpu_to_be32(ip->i_no_formal_ino >> 32); 62 59 fh[5] = cpu_to_be32(ip->i_no_formal_ino & 0xFFFFFFFF); 63 60 fh[6] = cpu_to_be32(ip->i_no_addr >> 32); 64 61 fh[7] = cpu_to_be32(ip->i_no_addr & 0xFFFFFFFF); 65 62 *len = GFS2_LARGE_FH_SIZE; 66 - 67 - iput(inode); 68 63 69 64 return *len; 70 65 }
+7 -7
fs/hpfs/alloc.c
··· 16 16 static int chk_if_allocated(struct super_block *s, secno sec, char *msg) 17 17 { 18 18 struct quad_buffer_head qbh; 19 - u32 *bmp; 19 + __le32 *bmp; 20 20 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "chk"))) goto fail; 21 - if ((cpu_to_le32(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) { 21 + if ((le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) >> (sec & 0x1f)) & 1) { 22 22 hpfs_error(s, "sector '%s' - %08x not allocated in bitmap", msg, sec); 23 23 goto fail1; 24 24 } ··· 62 62 static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigned forward) 63 63 { 64 64 struct quad_buffer_head qbh; 65 - unsigned *bmp; 65 + __le32 *bmp; 66 66 unsigned bs = near & ~0x3fff; 67 67 unsigned nr = (near & 0x3fff) & ~(n - 1); 68 68 /*unsigned mnr;*/ ··· 236 236 int hpfs_alloc_if_possible(struct super_block *s, secno sec) 237 237 { 238 238 struct quad_buffer_head qbh; 239 - u32 *bmp; 239 + __le32 *bmp; 240 240 if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; 241 241 if (le32_to_cpu(bmp[(sec & 0x3fff) >> 5]) & (1 << (sec & 0x1f))) { 242 242 bmp[(sec & 0x3fff) >> 5] &= cpu_to_le32(~(1 << (sec & 0x1f))); ··· 254 254 void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) 255 255 { 256 256 struct quad_buffer_head qbh; 257 - u32 *bmp; 257 + __le32 *bmp; 258 258 struct hpfs_sb_info *sbi = hpfs_sb(s); 259 259 /*printk("2 - ");*/ 260 260 if (!n) return; ··· 299 299 int n_bmps = (hpfs_sb(s)->sb_fs_size + 0x4000 - 1) >> 14; 300 300 int b = hpfs_sb(s)->sb_c_bitmap & 0x0fffffff; 301 301 int i, j; 302 - u32 *bmp; 302 + __le32 *bmp; 303 303 struct quad_buffer_head qbh; 304 304 if ((bmp = hpfs_map_dnode_bitmap(s, &qbh))) { 305 305 for (j = 0; j < 512; j++) { ··· 351 351 hpfs_free_sectors(s, dno, 4); 352 352 } else { 353 353 struct quad_buffer_head qbh; 354 - u32 *bmp; 354 + __le32 *bmp; 355 355 unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; 356 356 if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { 357 357 return;
+24 -19
fs/hpfs/anode.c
··· 20 20 int c1, c2 = 0; 21 21 go_down: 22 22 if (hpfs_sb(s)->sb_chk) if (hpfs_stop_cycles(s, a, &c1, &c2, "hpfs_bplus_lookup")) return -1; 23 - if (btree->internal) { 23 + if (bp_internal(btree)) { 24 24 for (i = 0; i < btree->n_used_nodes; i++) 25 25 if (le32_to_cpu(btree->u.internal[i].file_secno) > sec) { 26 26 a = le32_to_cpu(btree->u.internal[i].down); ··· 82 82 brelse(bh); 83 83 return -1; 84 84 } 85 - if (btree->internal) { 85 + if (bp_internal(btree)) { 86 86 a = le32_to_cpu(btree->u.internal[n].down); 87 87 btree->u.internal[n].file_secno = cpu_to_le32(-1); 88 88 mark_buffer_dirty(bh); ··· 129 129 } 130 130 if (a == node && fnod) { 131 131 anode->up = cpu_to_le32(node); 132 - anode->btree.fnode_parent = 1; 132 + anode->btree.flags |= BP_fnode_parent; 133 133 anode->btree.n_used_nodes = btree->n_used_nodes; 134 134 anode->btree.first_free = btree->first_free; 135 135 anode->btree.n_free_nodes = 40 - anode->btree.n_used_nodes; 136 136 memcpy(&anode->u, &btree->u, btree->n_used_nodes * 12); 137 - btree->internal = 1; 137 + btree->flags |= BP_internal; 138 138 btree->n_free_nodes = 11; 139 139 btree->n_used_nodes = 1; 140 140 btree->first_free = cpu_to_le16((char *)&(btree->u.internal[1]) - (char *)btree); ··· 184 184 hpfs_free_sectors(s, ra, 1); 185 185 if ((anode = hpfs_map_anode(s, na, &bh))) { 186 186 anode->up = cpu_to_le32(up); 187 - anode->btree.fnode_parent = up == node && fnod; 187 + if (up == node && fnod) 188 + anode->btree.flags |= BP_fnode_parent; 189 + else 190 + anode->btree.flags &= ~BP_fnode_parent; 188 191 mark_buffer_dirty(bh); 189 192 brelse(bh); 190 193 } ··· 201 198 if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) { 202 199 anode = new_anode; 203 200 /*anode->up = cpu_to_le32(up != -1 ? up : ra);*/ 204 - anode->btree.internal = 1; 201 + anode->btree.flags |= BP_internal; 205 202 anode->btree.n_used_nodes = 1; 206 203 anode->btree.n_free_nodes = 59; 207 204 anode->btree.first_free = cpu_to_le16(16); ··· 218 215 } 219 216 if ((anode = hpfs_map_anode(s, na, &bh))) { 220 217 anode->up = cpu_to_le32(node); 221 - if (fnod) anode->btree.fnode_parent = 1; 218 + if (fnod) 219 + anode->btree.flags |= BP_fnode_parent; 222 220 mark_buffer_dirty(bh); 223 221 brelse(bh); 224 222 } ··· 238 234 } 239 235 ranode->up = cpu_to_le32(node); 240 236 memcpy(&ranode->btree, btree, le16_to_cpu(btree->first_free)); 241 - if (fnod) ranode->btree.fnode_parent = 1; 242 - ranode->btree.n_free_nodes = (ranode->btree.internal ? 60 : 40) - ranode->btree.n_used_nodes; 243 - if (ranode->btree.internal) for (n = 0; n < ranode->btree.n_used_nodes; n++) { 237 + if (fnod) 238 + ranode->btree.flags |= BP_fnode_parent; 239 + ranode->btree.n_free_nodes = (bp_internal(&ranode->btree) ? 60 : 40) - ranode->btree.n_used_nodes; 240 + if (bp_internal(&ranode->btree)) for (n = 0; n < ranode->btree.n_used_nodes; n++) { 244 241 struct anode *unode; 245 242 if ((unode = hpfs_map_anode(s, le32_to_cpu(ranode->u.internal[n].down), &bh1))) { 246 243 unode->up = cpu_to_le32(ra); 247 - unode->btree.fnode_parent = 0; 244 + unode->btree.flags &= ~BP_fnode_parent; 248 245 mark_buffer_dirty(bh1); 249 246 brelse(bh1); 250 247 } 251 248 } 252 - btree->internal = 1; 249 + btree->flags |= BP_internal; 253 250 btree->n_free_nodes = fnod ? 10 : 58; 254 251 btree->n_used_nodes = 2; 255 252 btree->first_free = cpu_to_le16((char *)&btree->u.internal[2] - (char *)btree); ··· 283 278 int d1, d2; 284 279 go_down: 285 280 d2 = 0; 286 - while (btree1->internal) { 281 + while (bp_internal(btree1)) { 287 282 ano = le32_to_cpu(btree1->u.internal[pos].down); 288 283 if (level) brelse(bh); 289 284 if (hpfs_sb(s)->sb_chk) ··· 417 412 btree->n_free_nodes = 8; 418 413 btree->n_used_nodes = 0; 419 414 btree->first_free = cpu_to_le16(8); 420 - btree->internal = 0; 415 + btree->flags &= ~BP_internal; 421 416 mark_buffer_dirty(bh); 422 417 } else hpfs_free_sectors(s, f, 1); 423 418 brelse(bh); 424 419 return; 425 420 } 426 - while (btree->internal) { 421 + while (bp_internal(btree)) { 427 422 nodes = btree->n_used_nodes + btree->n_free_nodes; 428 423 for (i = 0; i < btree->n_used_nodes; i++) 429 424 if (le32_to_cpu(btree->u.internal[i].file_secno) >= secs) goto f; ··· 484 479 struct extended_attribute *ea; 485 480 struct extended_attribute *ea_end; 486 481 if (!(fnode = hpfs_map_fnode(s, fno, &bh))) return; 487 - if (!fnode->dirflag) hpfs_remove_btree(s, &fnode->btree); 482 + if (!fnode_is_dir(fnode)) hpfs_remove_btree(s, &fnode->btree); 488 483 else hpfs_remove_dtree(s, le32_to_cpu(fnode->u.external[0].disk_secno)); 489 484 ea_end = fnode_end_ea(fnode); 490 485 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) 491 - if (ea->indirect) 492 - hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); 493 - hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l)); 486 + if (ea_indirect(ea)) 487 + hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); 488 + hpfs_ea_ext_remove(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l)); 494 489 brelse(bh); 495 490 hpfs_free_sectors(s, fno, 1); 496 491 }
+1 -1
fs/hpfs/dir.c
··· 87 87 ret = -EIOERROR; 88 88 goto out; 89 89 } 90 - if (!fno->dirflag) { 90 + if (!fnode_is_dir(fno)) { 91 91 e = 1; 92 92 hpfs_error(inode->i_sb, "not a directory, fnode %08lx", 93 93 (unsigned long)inode->i_ino);
+5 -5
fs/hpfs/dnode.c
··· 153 153 } 154 154 de->length = cpu_to_le16(36); 155 155 de->down = 1; 156 - *(dnode_secno *)((char *)de + 32) = cpu_to_le32(ptr); 156 + *(__le32 *)((char *)de + 32) = cpu_to_le32(ptr); 157 157 } 158 158 } 159 159 ··· 177 177 memmove((char *)de + d_size, de, (char *)de_end - (char *)de); 178 178 memset(de, 0, d_size); 179 179 if (down_ptr) { 180 - *(dnode_secno *)((char *)de + d_size - 4) = cpu_to_le32(down_ptr); 180 + *(__le32 *)((char *)de + d_size - 4) = cpu_to_le32(down_ptr); 181 181 de->down = 1; 182 182 } 183 183 de->length = cpu_to_le16(d_size); ··· 656 656 del->down = 0; 657 657 d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); 658 658 } else if (down) 659 - *(dnode_secno *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); 659 + *(__le32 *) ((void *) del + le16_to_cpu(del->length) - 4) = cpu_to_le32(down); 660 660 } else goto endm; 661 661 if (!(de_cp = kmalloc(le16_to_cpu(de_prev->length), GFP_NOFS))) { 662 662 printk("HPFS: out of memory for dtree balancing\n"); ··· 672 672 de_prev->down = 1; 673 673 dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); 674 674 } 675 - *(dnode_secno *) ((void *) de_prev + le16_to_cpu(de_prev->length) - 4) = cpu_to_le32(ndown); 675 + *(__le32 *) ((void *) de_prev + le16_to_cpu(de_prev->length) - 4) = cpu_to_le32(ndown); 676 676 hpfs_mark_4buffers_dirty(&qbh); 677 677 hpfs_brelse4(&qbh); 678 678 for_all_poss(i, hpfs_pos_subst, ((loff_t)up << 4) | (p - 1), 4); ··· 1015 1015 kfree(name2); 1016 1016 return NULL; 1017 1017 } 1018 - if (!upf->dirflag) { 1018 + if (!fnode_is_dir(upf)) { 1019 1019 brelse(bh); 1020 1020 hpfs_error(s, "fnode %08x has non-directory parent %08x", fno, le32_to_cpu(f->up)); 1021 1021 kfree(name2);
+30 -30
fs/hpfs/ea.c
··· 23 23 return; 24 24 } 25 25 if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; 26 - if (ea->indirect) { 26 + if (ea_indirect(ea)) { 27 27 if (ea_valuelen(ea) != 8) { 28 - hpfs_error(s, "ea->indirect set while ea->valuelen!=8, %s %08x, pos %08x", 28 + hpfs_error(s, "ea_indirect(ea) set while ea->valuelen!=8, %s %08x, pos %08x", 29 29 ano ? "anode" : "sectors", a, pos); 30 30 return; 31 31 } 32 32 if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 9, ex+4)) 33 33 return; 34 - hpfs_ea_remove(s, ea_sec(ea), ea->anode, ea_len(ea)); 34 + hpfs_ea_remove(s, ea_sec(ea), ea_in_anode(ea), ea_len(ea)); 35 35 } 36 36 pos += ea->namelen + ea_valuelen(ea) + 5; 37 37 } ··· 81 81 struct extended_attribute *ea_end = fnode_end_ea(fnode); 82 82 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) 83 83 if (!strcmp(ea->name, key)) { 84 - if (ea->indirect) 84 + if (ea_indirect(ea)) 85 85 goto indirect; 86 86 if (ea_valuelen(ea) >= size) 87 87 return -EINVAL; ··· 91 91 } 92 92 a = le32_to_cpu(fnode->ea_secno); 93 93 len = le32_to_cpu(fnode->ea_size_l); 94 - ano = fnode->ea_anode; 94 + ano = fnode_in_anode(fnode); 95 95 pos = 0; 96 96 while (pos < len) { 97 97 ea = (struct extended_attribute *)ex; ··· 101 101 return -EIO; 102 102 } 103 103 if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return -EIO; 104 - if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) 104 + if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) 105 105 return -EIO; 106 106 if (!strcmp(ea->name, key)) { 107 - if (ea->indirect) 107 + if (ea_indirect(ea)) 108 108 goto indirect; 109 109 if (ea_valuelen(ea) >= size) 110 110 return -EINVAL; ··· 119 119 indirect: 120 120 if (ea_len(ea) >= size) 121 121 return -EINVAL; 122 - if (hpfs_ea_read(s, ea_sec(ea), ea->anode, 0, ea_len(ea), buf)) 122 + if (hpfs_ea_read(s, ea_sec(ea), ea_in_anode(ea), 0, ea_len(ea), buf)) 123 123 return -EIO; 124 124 buf[ea_len(ea)] = 0; 125 125 return 0; ··· 136 136 struct extended_attribute *ea_end = fnode_end_ea(fnode); 137 137 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) 138 138 if (!strcmp(ea->name, key)) { 139 - if (ea->indirect) 140 - return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); 139 + if (ea_indirect(ea)) 140 + return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); 141 141 if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { 142 142 printk("HPFS: out of memory for EA\n"); 143 143 return NULL; ··· 148 148 } 149 149 a = le32_to_cpu(fnode->ea_secno); 150 150 len = le32_to_cpu(fnode->ea_size_l); 151 - ano = fnode->ea_anode; 151 + ano = fnode_in_anode(fnode); 152 152 pos = 0; 153 153 while (pos < len) { 154 154 char ex[4 + 255 + 1 + 8]; ··· 159 159 return NULL; 160 160 } 161 161 if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return NULL; 162 - if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) 162 + if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) 163 163 return NULL; 164 164 if (!strcmp(ea->name, key)) { 165 - if (ea->indirect) 166 - return get_indirect_ea(s, ea->anode, ea_sec(ea), *size = ea_len(ea)); 165 + if (ea_indirect(ea)) 166 + return get_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), *size = ea_len(ea)); 167 167 if (!(ret = kmalloc((*size = ea_valuelen(ea)) + 1, GFP_NOFS))) { 168 168 printk("HPFS: out of memory for EA\n"); 169 169 return NULL; ··· 199 199 struct extended_attribute *ea_end = fnode_end_ea(fnode); 200 200 for (ea = fnode_ea(fnode); ea < ea_end; ea = next_ea(ea)) 201 201 if (!strcmp(ea->name, key)) { 202 - if (ea->indirect) { 202 + if (ea_indirect(ea)) { 203 203 if (ea_len(ea) == size) 204 - set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); 204 + set_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), data, size); 205 205 } else if (ea_valuelen(ea) == size) { 206 206 memcpy(ea_data(ea), data, size); 207 207 } ··· 209 209 } 210 210 a = le32_to_cpu(fnode->ea_secno); 211 211 len = le32_to_cpu(fnode->ea_size_l); 212 - ano = fnode->ea_anode; 212 + ano = fnode_in_anode(fnode); 213 213 pos = 0; 214 214 while (pos < len) { 215 215 char ex[4 + 255 + 1 + 8]; ··· 220 220 return; 221 221 } 222 222 if (hpfs_ea_read(s, a, ano, pos, 4, ex)) return; 223 - if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea->indirect ? 8 : 0), ex + 4)) 223 + if (hpfs_ea_read(s, a, ano, pos + 4, ea->namelen + 1 + (ea_indirect(ea) ? 8 : 0), ex + 4)) 224 224 return; 225 225 if (!strcmp(ea->name, key)) { 226 - if (ea->indirect) { 226 + if (ea_indirect(ea)) { 227 227 if (ea_len(ea) == size) 228 - set_indirect_ea(s, ea->anode, ea_sec(ea), data, size); 228 + set_indirect_ea(s, ea_in_anode(ea), ea_sec(ea), data, size); 229 229 } 230 230 else { 231 231 if (ea_valuelen(ea) == size) ··· 246 246 if (le16_to_cpu(fnode->ea_offs) < 0xc4 || le16_to_cpu(fnode->ea_offs) + le16_to_cpu(fnode->acl_size_s) + le16_to_cpu(fnode->ea_size_s) > 0x200) { 247 247 hpfs_error(s, "fnode %08lx: ea_offs == %03x, ea_size_s == %03x", 248 248 (unsigned long)inode->i_ino, 249 - le32_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s)); 249 + le16_to_cpu(fnode->ea_offs), le16_to_cpu(fnode->ea_size_s)); 250 250 return; 251 251 } 252 252 if ((le16_to_cpu(fnode->ea_size_s) || !le32_to_cpu(fnode->ea_size_l)) && ··· 276 276 fnode->ea_size_l = cpu_to_le32(le16_to_cpu(fnode->ea_size_s)); 277 277 fnode->ea_size_s = cpu_to_le16(0); 278 278 fnode->ea_secno = cpu_to_le32(n); 279 - fnode->ea_anode = cpu_to_le32(0); 279 + fnode->flags &= ~FNODE_anode; 280 280 mark_buffer_dirty(bh); 281 281 brelse(bh); 282 282 } ··· 288 288 secno q = hpfs_alloc_sector(s, fno, 1, 0); 289 289 if (!q) goto bail; 290 290 fnode->ea_secno = cpu_to_le32(q); 291 - fnode->ea_anode = 0; 291 + fnode->flags &= ~FNODE_anode; 292 292 len++; 293 - } else if (!fnode->ea_anode) { 293 + } else if (!fnode_in_anode(fnode)) { 294 294 if (hpfs_alloc_if_possible(s, le32_to_cpu(fnode->ea_secno) + len)) { 295 295 len++; 296 296 } else { ··· 310 310 anode->u.external[0].length = cpu_to_le32(len); 311 311 mark_buffer_dirty(bh); 312 312 brelse(bh); 313 - fnode->ea_anode = 1; 313 + fnode->flags |= FNODE_anode; 314 314 fnode->ea_secno = cpu_to_le32(a_s);*/ 315 315 secno new_sec; 316 316 int i; ··· 338 338 len = (pos + 511) >> 9; 339 339 } 340 340 } 341 - if (fnode->ea_anode) { 341 + if (fnode_in_anode(fnode)) { 342 342 if (hpfs_add_sector_to_btree(s, le32_to_cpu(fnode->ea_secno), 343 343 0, len) != -1) { 344 344 len++; ··· 351 351 h[1] = strlen(key); 352 352 h[2] = size & 0xff; 353 353 h[3] = size >> 8; 354 - if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail; 355 - if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail; 356 - if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode->ea_anode, le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail; 354 + if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l), 4, h)) goto bail; 355 + if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 4, h[1] + 1, key)) goto bail; 356 + if (hpfs_ea_write(s, le32_to_cpu(fnode->ea_secno), fnode_in_anode(fnode), le32_to_cpu(fnode->ea_size_l) + 5 + h[1], size, data)) goto bail; 357 357 fnode->ea_size_l = cpu_to_le32(pos); 358 358 ret: 359 359 hpfs_i(inode)->i_ea_size += 5 + strlen(key) + size; 360 360 return; 361 361 bail: 362 362 if (le32_to_cpu(fnode->ea_secno)) 363 - if (fnode->ea_anode) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9); 363 + if (fnode_in_anode(fnode)) hpfs_truncate_btree(s, le32_to_cpu(fnode->ea_secno), 1, (le32_to_cpu(fnode->ea_size_l) + 511) >> 9); 364 364 else hpfs_free_sectors(s, le32_to_cpu(fnode->ea_secno) + ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9), len - ((le32_to_cpu(fnode->ea_size_l) + 511) >> 9)); 365 365 else fnode->ea_secno = fnode->ea_size_l = cpu_to_le32(0); 366 366 }
+140 -149
fs/hpfs/hpfs.h
··· 51 51 u8 n_rootdir_entries[2]; 52 52 u8 n_sectors_s[2]; 53 53 u8 media_byte; 54 - u16 sectors_per_fat; 55 - u16 sectors_per_track; 56 - u16 heads_per_cyl; 57 - u32 n_hidden_sectors; 58 - u32 n_sectors_l; /* size of partition */ 54 + __le16 sectors_per_fat; 55 + __le16 sectors_per_track; 56 + __le16 heads_per_cyl; 57 + __le32 n_hidden_sectors; 58 + __le32 n_sectors_l; /* size of partition */ 59 59 u8 drive_number; 60 60 u8 mbz; 61 61 u8 sig_28h; /* 28h */ ··· 63 63 u8 vol_label[11]; 64 64 u8 sig_hpfs[8]; /* "HPFS " */ 65 65 u8 pad[448]; 66 - u16 magic; /* aa55 */ 66 + __le16 magic; /* aa55 */ 67 67 }; 68 68 69 69 ··· 75 75 76 76 struct hpfs_super_block 77 77 { 78 - u32 magic; /* f995 e849 */ 79 - u32 magic1; /* fa53 e9c5, more magic? */ 78 + __le32 magic; /* f995 e849 */ 79 + __le32 magic1; /* fa53 e9c5, more magic? */ 80 80 u8 version; /* version of a filesystem usually 2 */ 81 81 u8 funcversion; /* functional version - oldest version 82 82 of filesystem that can understand 83 83 this disk */ 84 - u16 zero; /* 0 */ 85 - fnode_secno root; /* fnode of root directory */ 86 - secno n_sectors; /* size of filesystem */ 87 - u32 n_badblocks; /* number of bad blocks */ 88 - secno bitmaps; /* pointers to free space bit maps */ 89 - u32 zero1; /* 0 */ 90 - secno badblocks; /* bad block list */ 91 - u32 zero3; /* 0 */ 92 - time32_t last_chkdsk; /* date last checked, 0 if never */ 93 - time32_t last_optimize; /* date last optimized, 0 if never */ 94 - secno n_dir_band; /* number of sectors in dir band */ 95 - secno dir_band_start; /* first sector in dir band */ 96 - secno dir_band_end; /* last sector in dir band */ 97 - secno dir_band_bitmap; /* free space map, 1 dnode per bit */ 84 + __le16 zero; /* 0 */ 85 + __le32 root; /* fnode of root directory */ 86 + __le32 n_sectors; /* size of filesystem */ 87 + __le32 n_badblocks; /* number of bad blocks */ 88 + __le32 bitmaps; /* pointers to free space bit maps */ 89 + __le32 zero1; /* 0 */ 90 + __le32 badblocks; /* bad block list */ 91 + __le32 zero3; /* 0 */ 92 + __le32 last_chkdsk; /* date last checked, 0 if never */ 93 + __le32 last_optimize; /* date last optimized, 0 if never */ 94 + __le32 n_dir_band; /* number of sectors in dir band */ 95 + __le32 dir_band_start; /* first sector in dir band */ 96 + __le32 dir_band_end; /* last sector in dir band */ 97 + __le32 dir_band_bitmap; /* free space map, 1 dnode per bit */ 98 98 u8 volume_name[32]; /* not used */ 99 - secno user_id_table; /* 8 preallocated sectors - user id */ 99 + __le32 user_id_table; /* 8 preallocated sectors - user id */ 100 100 u32 zero6[103]; /* 0 */ 101 101 }; 102 102 ··· 109 109 110 110 struct hpfs_spare_block 111 111 { 112 - u32 magic; /* f991 1849 */ 113 - u32 magic1; /* fa52 29c5, more magic? */ 112 + __le32 magic; /* f991 1849 */ 113 + __le32 magic1; /* fa52 29c5, more magic? */ 114 114 115 115 #ifdef __LITTLE_ENDIAN 116 116 u8 dirty: 1; /* 0 clean, 1 "improperly stopped" */ ··· 153 153 u8 mm_contlgulty; 154 154 u8 unused; 155 155 156 - secno hotfix_map; /* info about remapped bad sectors */ 157 - u32 n_spares_used; /* number of hotfixes */ 158 - u32 n_spares; /* number of spares in hotfix map */ 159 - u32 n_dnode_spares_free; /* spare dnodes unused */ 160 - u32 n_dnode_spares; /* length of spare_dnodes[] list, 156 + __le32 hotfix_map; /* info about remapped bad sectors */ 157 + __le32 n_spares_used; /* number of hotfixes */ 158 + __le32 n_spares; /* number of spares in hotfix map */ 159 + __le32 n_dnode_spares_free; /* spare dnodes unused */ 160 + __le32 n_dnode_spares; /* length of spare_dnodes[] list, 161 161 follows in this block*/ 162 - secno code_page_dir; /* code page directory block */ 163 - u32 n_code_pages; /* number of code pages */ 164 - u32 super_crc; /* on HPFS386 and LAN Server this is 162 + __le32 code_page_dir; /* code page directory block */ 163 + __le32 n_code_pages; /* number of code pages */ 164 + __le32 super_crc; /* on HPFS386 and LAN Server this is 165 165 checksum of superblock, on normal 166 166 OS/2 unused */ 167 - u32 spare_crc; /* on HPFS386 checksum of spareblock */ 168 - u32 zero1[15]; /* unused */ 169 - dnode_secno spare_dnodes[100]; /* emergency free dnode list */ 170 - u32 zero2[1]; /* room for more? */ 167 + __le32 spare_crc; /* on HPFS386 checksum of spareblock */ 168 + __le32 zero1[15]; /* unused */ 169 + __le32 spare_dnodes[100]; /* emergency free dnode list */ 170 + __le32 zero2[1]; /* room for more? */ 171 171 }; 172 172 173 173 /* The bad block list is 4 sectors long. The first word must be zero, ··· 202 202 203 203 struct code_page_directory 204 204 { 205 - u32 magic; /* 4945 21f7 */ 206 - u32 n_code_pages; /* number of pointers following */ 207 - u32 zero1[2]; 205 + __le32 magic; /* 4945 21f7 */ 206 + __le32 n_code_pages; /* number of pointers following */ 207 + __le32 zero1[2]; 208 208 struct { 209 - u16 ix; /* index */ 210 - u16 code_page_number; /* code page number */ 211 - u32 bounds; /* matches corresponding word 209 + __le16 ix; /* index */ 210 + __le16 code_page_number; /* code page number */ 211 + __le32 bounds; /* matches corresponding word 212 212 in data block */ 213 - secno code_page_data; /* sector number of a code_page_data 213 + __le32 code_page_data; /* sector number of a code_page_data 214 214 containing c.p. array */ 215 - u16 index; /* index in c.p. array in that sector*/ 216 - u16 unknown; /* some unknown value; usually 0; 215 + __le16 index; /* index in c.p. array in that sector*/ 216 + __le16 unknown; /* some unknown value; usually 0; 217 217 2 in Japanese version */ 218 218 } array[31]; /* unknown length */ 219 219 }; ··· 224 224 225 225 struct code_page_data 226 226 { 227 - u32 magic; /* 8945 21f7 */ 228 - u32 n_used; /* # elements used in c_p_data[] */ 229 - u32 bounds[3]; /* looks a bit like 227 + __le32 magic; /* 8945 21f7 */ 228 + __le32 n_used; /* # elements used in c_p_data[] */ 229 + __le32 bounds[3]; /* looks a bit like 230 230 (beg1,end1), (beg2,end2) 231 231 one byte each */ 232 - u16 offs[3]; /* offsets from start of sector 232 + __le16 offs[3]; /* offsets from start of sector 233 233 to start of c_p_data[ix] */ 234 234 struct { 235 - u16 ix; /* index */ 236 - u16 code_page_number; /* code page number */ 237 - u16 unknown; /* the same as in cp directory */ 235 + __le16 ix; /* index */ 236 + __le16 code_page_number; /* code page number */ 237 + __le16 unknown; /* the same as in cp directory */ 238 238 u8 map[128]; /* upcase table for chars 80..ff */ 239 - u16 zero2; 239 + __le16 zero2; 240 240 } code_page[3]; 241 241 u8 incognita[78]; 242 242 }; ··· 278 278 #define DNODE_MAGIC 0x77e40aae 279 279 280 280 struct dnode { 281 - u32 magic; /* 77e4 0aae */ 282 - u32 first_free; /* offset from start of dnode to 281 + __le32 magic; /* 77e4 0aae */ 282 + __le32 first_free; /* offset from start of dnode to 283 283 first free dir entry */ 284 284 #ifdef __LITTLE_ENDIAN 285 285 u8 root_dnode: 1; /* Is it root dnode? */ ··· 293 293 u8 root_dnode: 1; /* Is it root dnode? */ 294 294 #endif 295 295 u8 increment_me2[3]; 296 - secno up; /* (root dnode) directory's fnode 296 + __le32 up; /* (root dnode) directory's fnode 297 297 (nonroot) parent dnode */ 298 - dnode_secno self; /* pointer to this dnode */ 298 + __le32 self; /* pointer to this dnode */ 299 299 u8 dirent[2028]; /* one or more dirents */ 300 300 }; 301 301 302 302 struct hpfs_dirent { 303 - u16 length; /* offset to next dirent */ 303 + __le16 length; /* offset to next dirent */ 304 304 305 305 #ifdef __LITTLE_ENDIAN 306 306 u8 first: 1; /* set on phony ^A^A (".") entry */ ··· 346 346 u8 read_only: 1; /* dos attrib */ 347 347 #endif 348 348 349 - fnode_secno fnode; /* fnode giving allocation info */ 350 - time32_t write_date; /* mtime */ 351 - u32 file_size; /* file length, bytes */ 352 - time32_t read_date; /* atime */ 353 - time32_t creation_date; /* ctime */ 354 - u32 ea_size; /* total EA length, bytes */ 349 + __le32 fnode; /* fnode giving allocation info */ 350 + __le32 write_date; /* mtime */ 351 + __le32 file_size; /* file length, bytes */ 352 + __le32 read_date; /* atime */ 353 + __le32 creation_date; /* ctime */ 354 + __le32 ea_size; /* total EA length, bytes */ 355 355 u8 no_of_acls; /* number of ACL's (low 3 bits) */ 356 356 u8 ix; /* code page index (of filename), see 357 357 struct code_page_data */ ··· 375 375 376 376 struct bplus_leaf_node 377 377 { 378 - u32 file_secno; /* first file sector in extent */ 379 - u32 length; /* length, sectors */ 380 - secno disk_secno; /* first corresponding disk sector */ 378 + __le32 file_secno; /* first file sector in extent */ 379 + __le32 length; /* length, sectors */ 380 + __le32 disk_secno; /* first corresponding disk sector */ 381 381 }; 382 382 383 383 struct bplus_internal_node 384 384 { 385 - u32 file_secno; /* subtree maps sectors < this */ 386 - anode_secno down; /* pointer to subtree */ 385 + __le32 file_secno; /* subtree maps sectors < this */ 386 + __le32 down; /* pointer to subtree */ 387 387 }; 388 388 389 + enum { 390 + BP_hbff = 1, 391 + BP_fnode_parent = 0x20, 392 + BP_binary_search = 0x40, 393 + BP_internal = 0x80 394 + }; 389 395 struct bplus_header 390 396 { 391 - #ifdef __LITTLE_ENDIAN 392 - u8 hbff: 1; /* high bit of first free entry offset */ 393 - u8 flag1234: 4; 394 - u8 fnode_parent: 1; /* ? we're pointed to by an fnode, 397 + u8 flags; /* bit 0 - high bit of first free entry offset 398 + bit 5 - we're pointed to by an fnode, 395 399 the data btree or some ea or the 396 - main ea bootage pointer ea_secno */ 397 - /* also can get set in fnodes, which 398 - may be a chkdsk glitch or may mean 399 - this bit is irrelevant in fnodes, 400 - or this interpretation is all wet */ 401 - u8 binary_search: 1; /* suggest binary search (unused) */ 402 - u8 internal: 1; /* 1 -> (internal) tree of anodes 403 - 0 -> (leaf) list of extents */ 404 - #else 405 - u8 internal: 1; /* 1 -> (internal) tree of anodes 406 - 0 -> (leaf) list of extents */ 407 - u8 binary_search: 1; /* suggest binary search (unused) */ 408 - u8 fnode_parent: 1; /* ? we're pointed to by an fnode, 409 - the data btree or some ea or the 410 - main ea bootage pointer ea_secno */ 411 - /* also can get set in fnodes, which 412 - may be a chkdsk glitch or may mean 413 - this bit is irrelevant in fnodes, 414 - or this interpretation is all wet */ 415 - u8 flag1234: 4; 416 - u8 hbff: 1; /* high bit of first free entry offset */ 417 - #endif 400 + main ea bootage pointer ea_secno 401 + bit 6 - suggest binary search (unused) 402 + bit 7 - 1 -> (internal) tree of anodes 403 + 0 -> (leaf) list of extents */ 418 404 u8 fill[3]; 419 405 u8 n_free_nodes; /* free nodes in following array */ 420 406 u8 n_used_nodes; /* used nodes in following array */ 421 - u16 first_free; /* offset from start of header to 407 + __le16 first_free; /* offset from start of header to 422 408 first free node in array */ 423 409 union { 424 410 struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving ··· 414 428 } u; 415 429 }; 416 430 431 + static inline bool bp_internal(struct bplus_header *bp) 432 + { 433 + return bp->flags & BP_internal; 434 + } 435 + 436 + static inline bool bp_fnode_parent(struct bplus_header *bp) 437 + { 438 + return bp->flags & BP_fnode_parent; 439 + } 440 + 417 441 /* fnode: root of allocation b+ tree, and EA's */ 418 442 419 443 /* Every file and every directory has one fnode, pointed to by the directory ··· 432 436 433 437 #define FNODE_MAGIC 0xf7e40aae 434 438 439 + enum {FNODE_anode = cpu_to_le16(2), FNODE_dir = cpu_to_le16(256)}; 435 440 struct fnode 436 441 { 437 - u32 magic; /* f7e4 0aae */ 438 - u32 zero1[2]; /* read history */ 442 + __le32 magic; /* f7e4 0aae */ 443 + __le32 zero1[2]; /* read history */ 439 444 u8 len, name[15]; /* true length, truncated name */ 440 - fnode_secno up; /* pointer to file's directory fnode */ 441 - secno acl_size_l; 442 - secno acl_secno; 443 - u16 acl_size_s; 445 + __le32 up; /* pointer to file's directory fnode */ 446 + __le32 acl_size_l; 447 + __le32 acl_secno; 448 + __le16 acl_size_s; 444 449 u8 acl_anode; 445 450 u8 zero2; /* history bit count */ 446 - u32 ea_size_l; /* length of disk-resident ea's */ 447 - secno ea_secno; /* first sector of disk-resident ea's*/ 448 - u16 ea_size_s; /* length of fnode-resident ea's */ 451 + __le32 ea_size_l; /* length of disk-resident ea's */ 452 + __le32 ea_secno; /* first sector of disk-resident ea's*/ 453 + __le16 ea_size_s; /* length of fnode-resident ea's */ 449 454 450 - #ifdef __LITTLE_ENDIAN 451 - u8 flag0: 1; 452 - u8 ea_anode: 1; /* 1 -> ea_secno is an anode */ 453 - u8 flag234567: 6; 454 - #else 455 - u8 flag234567: 6; 456 - u8 ea_anode: 1; /* 1 -> ea_secno is an anode */ 457 - u8 flag0: 1; 458 - #endif 459 - 460 - #ifdef __LITTLE_ENDIAN 461 - u8 dirflag: 1; /* 1 -> directory. first & only extent 455 + __le16 flags; /* bit 1 set -> ea_secno is an anode */ 456 + /* bit 8 set -> directory. first & only extent 462 457 points to dnode. */ 463 - u8 flag9012345: 7; 464 - #else 465 - u8 flag9012345: 7; 466 - u8 dirflag: 1; /* 1 -> directory. first & only extent 467 - points to dnode. */ 468 - #endif 469 - 470 458 struct bplus_header btree; /* b+ tree, 8 extents or 12 subtrees */ 471 459 union { 472 460 struct bplus_leaf_node external[8]; 473 461 struct bplus_internal_node internal[12]; 474 462 } u; 475 463 476 - u32 file_size; /* file length, bytes */ 477 - u32 n_needea; /* number of EA's with NEEDEA set */ 464 + __le32 file_size; /* file length, bytes */ 465 + __le32 n_needea; /* number of EA's with NEEDEA set */ 478 466 u8 user_id[16]; /* unused */ 479 - u16 ea_offs; /* offset from start of fnode 467 + __le16 ea_offs; /* offset from start of fnode 480 468 to first fnode-resident ea */ 481 469 u8 dasd_limit_treshhold; 482 470 u8 dasd_limit_delta; 483 - u32 dasd_limit; 484 - u32 dasd_usage; 471 + __le32 dasd_limit; 472 + __le32 dasd_usage; 485 473 u8 ea[316]; /* zero or more EA's, packed together 486 474 with no alignment padding. 487 475 (Do not use this name, get here 488 476 via fnode + ea_offs. I think.) */ 489 477 }; 478 + 479 + static inline bool fnode_in_anode(struct fnode *p) 480 + { 481 + return (p->flags & FNODE_anode) != 0; 482 + } 483 + 484 + static inline bool fnode_is_dir(struct fnode *p) 485 + { 486 + return (p->flags & FNODE_dir) != 0; 487 + } 490 488 491 489 492 490 /* anode: 99.44% pure allocation tree */ ··· 489 499 490 500 struct anode 491 501 { 492 - u32 magic; /* 37e4 0aae */ 493 - anode_secno self; /* pointer to this anode */ 494 - secno up; /* parent anode or fnode */ 502 + __le32 magic; /* 37e4 0aae */ 503 + __le32 self; /* pointer to this anode */ 504 + __le32 up; /* parent anode or fnode */ 495 505 496 506 struct bplus_header btree; /* b+tree, 40 extents or 60 subtrees */ 497 507 union { ··· 499 509 struct bplus_internal_node internal[60]; 500 510 } u; 501 511 502 - u32 fill[3]; /* unused */ 512 + __le32 fill[3]; /* unused */ 503 513 }; 504 514 505 515 ··· 518 528 run, or in multiple runs. Flags in the fnode tell whether the EA list 519 529 is immediate, in a single run, or in multiple runs. */ 520 530 531 + enum {EA_indirect = 1, EA_anode = 2, EA_needea = 128 }; 521 532 struct extended_attribute 522 533 { 523 - #ifdef __LITTLE_ENDIAN 524 - u8 indirect: 1; /* 1 -> value gives sector number 534 + u8 flags; /* bit 0 set -> value gives sector number 525 535 where real value starts */ 526 - u8 anode: 1; /* 1 -> sector is an anode 536 + /* bit 1 set -> sector is an anode 527 537 that points to fragmented value */ 528 - u8 flag23456: 5; 529 - u8 needea: 1; /* required ea */ 530 - #else 531 - u8 needea: 1; /* required ea */ 532 - u8 flag23456: 5; 533 - u8 anode: 1; /* 1 -> sector is an anode 534 - that points to fragmented value */ 535 - u8 indirect: 1; /* 1 -> value gives sector number 536 - where real value starts */ 537 - #endif 538 + /* bit 7 set -> required ea */ 538 539 u8 namelen; /* length of name, bytes */ 539 540 u8 valuelen_lo; /* length of value, bytes */ 540 541 u8 valuelen_hi; /* length of value, bytes */ 541 - u8 name[0]; 542 + u8 name[]; 542 543 /* 543 544 u8 name[namelen]; ascii attrib name 544 545 u8 nul; terminating '\0', not counted 545 546 u8 value[valuelen]; value, arbitrary 546 - if this.indirect, valuelen is 8 and the value is 547 + if this.flags & 1, valuelen is 8 and the value is 547 548 u32 length; real length of value, bytes 548 549 secno secno; sector address where it starts 549 550 if this.anode, the above sector number is the root of an anode tree 550 551 which points to the value. 551 552 */ 552 553 }; 554 + 555 + static inline bool ea_indirect(struct extended_attribute *ea) 556 + { 557 + return ea->flags & EA_indirect; 558 + } 559 + 560 + static inline bool ea_in_anode(struct extended_attribute *ea) 561 + { 562 + return ea->flags & EA_anode; 563 + } 553 564 554 565 /* 555 566 Local Variables:
+8 -8
fs/hpfs/hpfs_fn.h
··· 75 75 unsigned char *sb_cp_table; /* code page tables: */ 76 76 /* 128 bytes uppercasing table & */ 77 77 /* 128 bytes lowercasing table */ 78 - unsigned *sb_bmp_dir; /* main bitmap directory */ 78 + __le32 *sb_bmp_dir; /* main bitmap directory */ 79 79 unsigned sb_c_bitmap; /* current bitmap */ 80 80 unsigned sb_max_fwd_alloc; /* max forwad allocation */ 81 81 int sb_timeshift; ··· 93 93 static inline dnode_secno de_down_pointer (struct hpfs_dirent *de) 94 94 { 95 95 CHKCOND(de->down,("HPFS: de_down_pointer: !de->down\n")); 96 - return le32_to_cpu(*(dnode_secno *) ((void *) de + le16_to_cpu(de->length) - 4)); 96 + return le32_to_cpu(*(__le32 *) ((void *) de + le16_to_cpu(de->length) - 4)); 97 97 } 98 98 99 99 /* The first dir entry in a dnode */ ··· 141 141 142 142 static inline secno ea_sec(struct extended_attribute *ea) 143 143 { 144 - return le32_to_cpu(get_unaligned((secno *)((char *)ea + 9 + ea->namelen))); 144 + return le32_to_cpu(get_unaligned((__le32 *)((char *)ea + 9 + ea->namelen))); 145 145 } 146 146 147 147 static inline secno ea_len(struct extended_attribute *ea) 148 148 { 149 - return le32_to_cpu(get_unaligned((secno *)((char *)ea + 5 + ea->namelen))); 149 + return le32_to_cpu(get_unaligned((__le32 *)((char *)ea + 5 + ea->namelen))); 150 150 } 151 151 152 152 static inline char *ea_data(struct extended_attribute *ea) ··· 171 171 dst->not_8x3 = n; 172 172 } 173 173 174 - static inline unsigned tstbits(u32 *bmp, unsigned b, unsigned n) 174 + static inline unsigned tstbits(__le32 *bmp, unsigned b, unsigned n) 175 175 { 176 176 int i; 177 177 if ((b >= 0x4000) || (b + n - 1 >= 0x4000)) return n; ··· 268 268 269 269 /* map.c */ 270 270 271 - unsigned *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); 272 - unsigned *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); 271 + __le32 *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); 272 + __le32 *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); 273 273 unsigned char *hpfs_load_code_page(struct super_block *, secno); 274 - secno *hpfs_load_bitmap_directory(struct super_block *, secno bmp); 274 + __le32 *hpfs_load_bitmap_directory(struct super_block *, secno bmp); 275 275 struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); 276 276 struct anode *hpfs_map_anode(struct super_block *s, anode_secno, struct buffer_head **); 277 277 struct dnode *hpfs_map_dnode(struct super_block *s, dnode_secno, struct quad_buffer_head *);
+1 -1
fs/hpfs/inode.c
··· 110 110 } 111 111 } 112 112 } 113 - if (fnode->dirflag) { 113 + if (fnode_is_dir(fnode)) { 114 114 int n_dnodes, n_subdirs; 115 115 i->i_mode |= S_IFDIR; 116 116 i->i_op = &hpfs_dir_iops;
+10 -10
fs/hpfs/map.c
··· 8 8 9 9 #include "hpfs_fn.h" 10 10 11 - unsigned *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh) 11 + __le32 *hpfs_map_dnode_bitmap(struct super_block *s, struct quad_buffer_head *qbh) 12 12 { 13 13 return hpfs_map_4sectors(s, hpfs_sb(s)->sb_dmap, qbh, 0); 14 14 } 15 15 16 - unsigned int *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, 16 + __le32 *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, 17 17 struct quad_buffer_head *qbh, char *id) 18 18 { 19 19 secno sec; ··· 89 89 return cp_table; 90 90 } 91 91 92 - secno *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) 92 + __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) 93 93 { 94 94 struct buffer_head *bh; 95 95 int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; 96 96 int i; 97 - secno *b; 97 + __le32 *b; 98 98 if (!(b = kmalloc(n * 512, GFP_KERNEL))) { 99 99 printk("HPFS: can't allocate memory for bitmap directory\n"); 100 100 return NULL; 101 101 } 102 102 for (i=0;i<n;i++) { 103 - secno *d = hpfs_map_sector(s, bmp+i, &bh, n - i - 1); 103 + __le32 *d = hpfs_map_sector(s, bmp+i, &bh, n - i - 1); 104 104 if (!d) { 105 105 kfree(b); 106 106 return NULL; ··· 130 130 (unsigned long)ino); 131 131 goto bail; 132 132 } 133 - if (!fnode->dirflag) { 133 + if (!fnode_is_dir(fnode)) { 134 134 if ((unsigned)fnode->btree.n_used_nodes + (unsigned)fnode->btree.n_free_nodes != 135 - (fnode->btree.internal ? 12 : 8)) { 135 + (bp_internal(&fnode->btree) ? 12 : 8)) { 136 136 hpfs_error(s, 137 137 "bad number of nodes in fnode %08lx", 138 138 (unsigned long)ino); 139 139 goto bail; 140 140 } 141 141 if (le16_to_cpu(fnode->btree.first_free) != 142 - 8 + fnode->btree.n_used_nodes * (fnode->btree.internal ? 8 : 12)) { 142 + 8 + fnode->btree.n_used_nodes * (bp_internal(&fnode->btree) ? 8 : 12)) { 143 143 hpfs_error(s, 144 144 "bad first_free pointer in fnode %08lx", 145 145 (unsigned long)ino); ··· 187 187 goto bail; 188 188 } 189 189 if ((unsigned)anode->btree.n_used_nodes + (unsigned)anode->btree.n_free_nodes != 190 - (anode->btree.internal ? 60 : 40)) { 190 + (bp_internal(&anode->btree) ? 60 : 40)) { 191 191 hpfs_error(s, "bad number of nodes in anode %08x", ano); 192 192 goto bail; 193 193 } 194 194 if (le16_to_cpu(anode->btree.first_free) != 195 - 8 + anode->btree.n_used_nodes * (anode->btree.internal ? 8 : 12)) { 195 + 8 + anode->btree.n_used_nodes * (bp_internal(&anode->btree) ? 8 : 12)) { 196 196 hpfs_error(s, "bad first_free pointer in anode %08x", ano); 197 197 goto bail; 198 198 }
+1 -1
fs/hpfs/namei.c
··· 70 70 fnode->len = len; 71 71 memcpy(fnode->name, name, len > 15 ? 15 : len); 72 72 fnode->up = cpu_to_le32(dir->i_ino); 73 - fnode->dirflag = 1; 73 + fnode->flags |= FNODE_dir; 74 74 fnode->btree.n_free_nodes = 7; 75 75 fnode->btree.n_used_nodes = 1; 76 76 fnode->btree.first_free = cpu_to_le16(0x14);
+2 -2
fs/hpfs/super.c
··· 572 572 mark_buffer_dirty(bh2); 573 573 } 574 574 575 - if (le32_to_cpu(spareblock->hotfixes_used) || le32_to_cpu(spareblock->n_spares_used)) { 575 + if (spareblock->hotfixes_used || spareblock->n_spares_used) { 576 576 if (errs >= 2) { 577 577 printk("HPFS: Hotfixes not supported here, try chkdsk\n"); 578 578 mark_dirty(s, 0); ··· 645 645 root->i_mtime.tv_nsec = 0; 646 646 root->i_ctime.tv_sec = local_to_gmt(s, le32_to_cpu(de->creation_date)); 647 647 root->i_ctime.tv_nsec = 0; 648 - hpfs_i(root)->i_ea_size = le16_to_cpu(de->ea_size); 648 + hpfs_i(root)->i_ea_size = le32_to_cpu(de->ea_size); 649 649 hpfs_i(root)->i_parent_dir = root->i_ino; 650 650 if (root->i_size == -1) 651 651 root->i_size = 2048;
+106 -18
fs/inode.c
··· 1487 1487 return 0; 1488 1488 } 1489 1489 1490 + /* 1491 + * This does the actual work of updating an inodes time or version. Must have 1492 + * had called mnt_want_write() before calling this. 1493 + */ 1494 + static int update_time(struct inode *inode, struct timespec *time, int flags) 1495 + { 1496 + if (inode->i_op->update_time) 1497 + return inode->i_op->update_time(inode, time, flags); 1498 + 1499 + if (flags & S_ATIME) 1500 + inode->i_atime = *time; 1501 + if (flags & S_VERSION) 1502 + inode_inc_iversion(inode); 1503 + if (flags & S_CTIME) 1504 + inode->i_ctime = *time; 1505 + if (flags & S_MTIME) 1506 + inode->i_mtime = *time; 1507 + mark_inode_dirty_sync(inode); 1508 + return 0; 1509 + } 1510 + 1490 1511 /** 1491 1512 * touch_atime - update the access time 1492 - * @mnt: mount the inode is accessed on 1493 - * @dentry: dentry accessed 1513 + * @path: the &struct path to update 1494 1514 * 1495 1515 * Update the accessed time on an inode and mark it for writeback. 1496 1516 * This function automatically handles read only file systems and media, ··· 1545 1525 if (mnt_want_write(mnt)) 1546 1526 return; 1547 1527 1548 - inode->i_atime = now; 1549 - mark_inode_dirty_sync(inode); 1528 + /* 1529 + * File systems can error out when updating inodes if they need to 1530 + * allocate new space to modify an inode (such is the case for 1531 + * Btrfs), but since we touch atime while walking down the path we 1532 + * really don't care if we failed to update the atime of the file, 1533 + * so just ignore the return value. 1534 + */ 1535 + update_time(inode, &now, S_ATIME); 1550 1536 mnt_drop_write(mnt); 1551 1537 } 1552 1538 EXPORT_SYMBOL(touch_atime); 1539 + 1540 + /* 1541 + * The logic we want is 1542 + * 1543 + * if suid or (sgid and xgrp) 1544 + * remove privs 1545 + */ 1546 + int should_remove_suid(struct dentry *dentry) 1547 + { 1548 + umode_t mode = dentry->d_inode->i_mode; 1549 + int kill = 0; 1550 + 1551 + /* suid always must be killed */ 1552 + if (unlikely(mode & S_ISUID)) 1553 + kill = ATTR_KILL_SUID; 1554 + 1555 + /* 1556 + * sgid without any exec bits is just a mandatory locking mark; leave 1557 + * it alone. If some exec bits are set, it's a real sgid; kill it. 1558 + */ 1559 + if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) 1560 + kill |= ATTR_KILL_SGID; 1561 + 1562 + if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode))) 1563 + return kill; 1564 + 1565 + return 0; 1566 + } 1567 + EXPORT_SYMBOL(should_remove_suid); 1568 + 1569 + static int __remove_suid(struct dentry *dentry, int kill) 1570 + { 1571 + struct iattr newattrs; 1572 + 1573 + newattrs.ia_valid = ATTR_FORCE | kill; 1574 + return notify_change(dentry, &newattrs); 1575 + } 1576 + 1577 + int file_remove_suid(struct file *file) 1578 + { 1579 + struct dentry *dentry = file->f_path.dentry; 1580 + struct inode *inode = dentry->d_inode; 1581 + int killsuid; 1582 + int killpriv; 1583 + int error = 0; 1584 + 1585 + /* Fast path for nothing security related */ 1586 + if (IS_NOSEC(inode)) 1587 + return 0; 1588 + 1589 + killsuid = should_remove_suid(dentry); 1590 + killpriv = security_inode_need_killpriv(dentry); 1591 + 1592 + if (killpriv < 0) 1593 + return killpriv; 1594 + if (killpriv) 1595 + error = security_inode_killpriv(dentry); 1596 + if (!error && killsuid) 1597 + error = __remove_suid(dentry, killsuid); 1598 + if (!error && (inode->i_sb->s_flags & MS_NOSEC)) 1599 + inode->i_flags |= S_NOSEC; 1600 + 1601 + return error; 1602 + } 1603 + EXPORT_SYMBOL(file_remove_suid); 1553 1604 1554 1605 /** 1555 1606 * file_update_time - update mtime and ctime time ··· 1631 1540 * usage in the file write path of filesystems, and filesystems may 1632 1541 * choose to explicitly ignore update via this function with the 1633 1542 * S_NOCMTIME inode flag, e.g. for network filesystem where these 1634 - * timestamps are handled by the server. 1543 + * timestamps are handled by the server. This can return an error for 1544 + * file systems who need to allocate space in order to update an inode. 1635 1545 */ 1636 1546 1637 - void file_update_time(struct file *file) 1547 + int file_update_time(struct file *file) 1638 1548 { 1639 1549 struct inode *inode = file->f_path.dentry->d_inode; 1640 1550 struct timespec now; 1641 - enum { S_MTIME = 1, S_CTIME = 2, S_VERSION = 4 } sync_it = 0; 1551 + int sync_it = 0; 1552 + int ret; 1642 1553 1643 1554 /* First try to exhaust all avenues to not sync */ 1644 1555 if (IS_NOCMTIME(inode)) 1645 - return; 1556 + return 0; 1646 1557 1647 1558 now = current_fs_time(inode->i_sb); 1648 1559 if (!timespec_equal(&inode->i_mtime, &now)) ··· 1657 1564 sync_it |= S_VERSION; 1658 1565 1659 1566 if (!sync_it) 1660 - return; 1567 + return 0; 1661 1568 1662 1569 /* Finally allowed to write? Takes lock. */ 1663 1570 if (mnt_want_write_file(file)) 1664 - return; 1571 + return 0; 1665 1572 1666 - /* Only change inode inside the lock region */ 1667 - if (sync_it & S_VERSION) 1668 - inode_inc_iversion(inode); 1669 - if (sync_it & S_CTIME) 1670 - inode->i_ctime = now; 1671 - if (sync_it & S_MTIME) 1672 - inode->i_mtime = now; 1673 - mark_inode_dirty_sync(inode); 1573 + ret = update_time(inode, &now, sync_it); 1674 1574 mnt_drop_write_file(file); 1575 + 1576 + return ret; 1675 1577 } 1676 1578 EXPORT_SYMBOL(file_update_time); 1677 1579
+2 -1
fs/internal.h
··· 56 56 57 57 extern void __init mnt_init(void); 58 58 59 - DECLARE_BRLOCK(vfsmount_lock); 59 + extern struct lglock vfsmount_lock; 60 60 61 61 62 62 /* ··· 100 100 101 101 extern long do_handle_open(int mountdirfd, 102 102 struct file_handle __user *ufh, int open_flag); 103 + extern int open_check_o_direct(struct file *f); 103 104 104 105 /* 105 106 * inode.c
+4 -9
fs/isofs/export.c
··· 107 107 } 108 108 109 109 static int 110 - isofs_export_encode_fh(struct dentry *dentry, 110 + isofs_export_encode_fh(struct inode *inode, 111 111 __u32 *fh32, 112 112 int *max_len, 113 - int connectable) 113 + struct inode *parent) 114 114 { 115 - struct inode * inode = dentry->d_inode; 116 115 struct iso_inode_info * ei = ISOFS_I(inode); 117 116 int len = *max_len; 118 117 int type = 1; ··· 123 124 * offset of the inode and the upper 16 bits of fh32[1] to 124 125 * hold the offset of the parent. 125 126 */ 126 - if (connectable && (len < 5)) { 127 + if (parent && (len < 5)) { 127 128 *max_len = 5; 128 129 return 255; 129 130 } else if (len < 3) { ··· 135 136 fh32[0] = ei->i_iget5_block; 136 137 fh16[2] = (__u16)ei->i_iget5_offset; /* fh16 [sic] */ 137 138 fh32[2] = inode->i_generation; 138 - if (connectable && !S_ISDIR(inode->i_mode)) { 139 - struct inode *parent; 139 + if (parent) { 140 140 struct iso_inode_info *eparent; 141 - spin_lock(&dentry->d_lock); 142 - parent = dentry->d_parent->d_inode; 143 141 eparent = ISOFS_I(parent); 144 142 fh32[3] = eparent->i_iget5_block; 145 143 fh16[3] = (__u16)eparent->i_iget5_offset; /* fh16 [sic] */ 146 144 fh32[4] = parent->i_generation; 147 - spin_unlock(&dentry->d_lock); 148 145 len = 5; 149 146 type = 2; 150 147 }
+4
fs/jffs2/jffs2_fs_sb.h
··· 126 126 struct jffs2_inodirty *wbuf_inodes; 127 127 struct rw_semaphore wbuf_sem; /* Protects the write buffer */ 128 128 129 + struct delayed_work wbuf_dwork; /* write-buffer write-out work */ 130 + int wbuf_queued; /* non-zero delayed work is queued */ 131 + spinlock_t wbuf_dwork_lock; /* protects wbuf_dwork and and wbuf_queued */ 132 + 129 133 unsigned char *oobbuf; 130 134 int oobavail; /* How many bytes are available for JFFS2 in OOB */ 131 135 #endif
+2 -5
fs/jffs2/os-linux.h
··· 95 95 #define jffs2_ubivol(c) (0) 96 96 #define jffs2_ubivol_setup(c) (0) 97 97 #define jffs2_ubivol_cleanup(c) do {} while (0) 98 + #define jffs2_dirty_trigger(c) do {} while (0) 98 99 99 100 #else /* NAND and/or ECC'd NOR support present */ 100 101 ··· 136 135 #define jffs2_nor_wbuf_flash(c) (c->mtd->type == MTD_NORFLASH && ! (c->mtd->flags & MTD_BIT_WRITEABLE)) 137 136 int jffs2_nor_wbuf_flash_setup(struct jffs2_sb_info *c); 138 137 void jffs2_nor_wbuf_flash_cleanup(struct jffs2_sb_info *c); 138 + void jffs2_dirty_trigger(struct jffs2_sb_info *c); 139 139 140 140 #endif /* WRITEBUFFER */ 141 - 142 - static inline void jffs2_dirty_trigger(struct jffs2_sb_info *c) 143 - { 144 - OFNI_BS_2SFFJ(c)->s_dirt = 1; 145 - } 146 141 147 142 /* background.c */ 148 143 int jffs2_start_garbage_collect_thread(struct jffs2_sb_info *c);
-21
fs/jffs2/super.c
··· 63 63 inode_init_once(&f->vfs_inode); 64 64 } 65 65 66 - static void jffs2_write_super(struct super_block *sb) 67 - { 68 - struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); 69 - 70 - lock_super(sb); 71 - sb->s_dirt = 0; 72 - 73 - if (!(sb->s_flags & MS_RDONLY)) { 74 - jffs2_dbg(1, "%s()\n", __func__); 75 - jffs2_flush_wbuf_gc(c, 0); 76 - } 77 - 78 - unlock_super(sb); 79 - } 80 - 81 66 static const char *jffs2_compr_name(unsigned int compr) 82 67 { 83 68 switch (compr) { ··· 97 112 static int jffs2_sync_fs(struct super_block *sb, int wait) 98 113 { 99 114 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); 100 - 101 - jffs2_write_super(sb); 102 115 103 116 mutex_lock(&c->alloc_sem); 104 117 jffs2_flush_wbuf_pad(c); ··· 234 251 .alloc_inode = jffs2_alloc_inode, 235 252 .destroy_inode =jffs2_destroy_inode, 236 253 .put_super = jffs2_put_super, 237 - .write_super = jffs2_write_super, 238 254 .statfs = jffs2_statfs, 239 255 .remount_fs = jffs2_remount_fs, 240 256 .evict_inode = jffs2_evict_inode, ··· 300 318 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); 301 319 302 320 jffs2_dbg(2, "%s()\n", __func__); 303 - 304 - if (sb->s_dirt) 305 - jffs2_write_super(sb); 306 321 307 322 mutex_lock(&c->alloc_sem); 308 323 jffs2_flush_wbuf_pad(c);
+52 -3
fs/jffs2/wbuf.c
··· 20 20 #include <linux/mtd/nand.h> 21 21 #include <linux/jiffies.h> 22 22 #include <linux/sched.h> 23 + #include <linux/writeback.h> 23 24 24 25 #include "nodelist.h" 25 26 ··· 86 85 { 87 86 struct jffs2_inodirty *new; 88 87 89 - /* Mark the superblock dirty so that kupdated will flush... */ 88 + /* Schedule delayed write-buffer write-out */ 90 89 jffs2_dirty_trigger(c); 91 90 92 91 if (jffs2_wbuf_pending_for_ino(c, ino)) ··· 1149 1148 return 1; 1150 1149 } 1151 1150 1151 + static struct jffs2_sb_info *work_to_sb(struct work_struct *work) 1152 + { 1153 + struct delayed_work *dwork; 1154 + 1155 + dwork = container_of(work, struct delayed_work, work); 1156 + return container_of(dwork, struct jffs2_sb_info, wbuf_dwork); 1157 + } 1158 + 1159 + static void delayed_wbuf_sync(struct work_struct *work) 1160 + { 1161 + struct jffs2_sb_info *c = work_to_sb(work); 1162 + struct super_block *sb = OFNI_BS_2SFFJ(c); 1163 + 1164 + spin_lock(&c->wbuf_dwork_lock); 1165 + c->wbuf_queued = 0; 1166 + spin_unlock(&c->wbuf_dwork_lock); 1167 + 1168 + if (!(sb->s_flags & MS_RDONLY)) { 1169 + jffs2_dbg(1, "%s()\n", __func__); 1170 + jffs2_flush_wbuf_gc(c, 0); 1171 + } 1172 + } 1173 + 1174 + void jffs2_dirty_trigger(struct jffs2_sb_info *c) 1175 + { 1176 + struct super_block *sb = OFNI_BS_2SFFJ(c); 1177 + unsigned long delay; 1178 + 1179 + if (sb->s_flags & MS_RDONLY) 1180 + return; 1181 + 1182 + spin_lock(&c->wbuf_dwork_lock); 1183 + if (!c->wbuf_queued) { 1184 + jffs2_dbg(1, "%s()\n", __func__); 1185 + delay = msecs_to_jiffies(dirty_writeback_interval * 10); 1186 + queue_delayed_work(system_long_wq, &c->wbuf_dwork, delay); 1187 + c->wbuf_queued = 1; 1188 + } 1189 + spin_unlock(&c->wbuf_dwork_lock); 1190 + } 1191 + 1152 1192 int jffs2_nand_flash_setup(struct jffs2_sb_info *c) 1153 1193 { 1154 1194 struct nand_ecclayout *oinfo = c->mtd->ecclayout; ··· 1211 1169 1212 1170 /* Initialise write buffer */ 1213 1171 init_rwsem(&c->wbuf_sem); 1172 + spin_lock_init(&c->wbuf_dwork_lock); 1173 + INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); 1214 1174 c->wbuf_pagesize = c->mtd->writesize; 1215 1175 c->wbuf_ofs = 0xFFFFFFFF; 1216 1176 ··· 1251 1207 1252 1208 /* Initialize write buffer */ 1253 1209 init_rwsem(&c->wbuf_sem); 1254 - 1255 - 1210 + spin_lock_init(&c->wbuf_dwork_lock); 1211 + INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); 1256 1212 c->wbuf_pagesize = c->mtd->erasesize; 1257 1213 1258 1214 /* Find a suitable c->sector_size ··· 1311 1267 1312 1268 /* Initialize write buffer */ 1313 1269 init_rwsem(&c->wbuf_sem); 1270 + spin_lock_init(&c->wbuf_dwork_lock); 1271 + INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); 1272 + 1314 1273 c->wbuf_pagesize = c->mtd->writesize; 1315 1274 c->wbuf_ofs = 0xFFFFFFFF; 1316 1275 ··· 1346 1299 return 0; 1347 1300 1348 1301 init_rwsem(&c->wbuf_sem); 1302 + spin_lock_init(&c->wbuf_dwork_lock); 1303 + INIT_DELAYED_WORK(&c->wbuf_dwork, delayed_wbuf_sync); 1349 1304 1350 1305 c->wbuf_pagesize = c->mtd->writesize; 1351 1306 c->wbuf_ofs = 0xFFFFFFFF;
+3 -2
fs/locks.c
··· 1636 1636 SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) 1637 1637 { 1638 1638 struct file *filp; 1639 + int fput_needed; 1639 1640 struct file_lock *lock; 1640 1641 int can_sleep, unlock; 1641 1642 int error; 1642 1643 1643 1644 error = -EBADF; 1644 - filp = fget(fd); 1645 + filp = fget_light(fd, &fput_needed); 1645 1646 if (!filp) 1646 1647 goto out; 1647 1648 ··· 1675 1674 locks_free_lock(lock); 1676 1675 1677 1676 out_putf: 1678 - fput(filp); 1677 + fput_light(filp, fput_needed); 1679 1678 out: 1680 1679 return error; 1681 1680 }
+128 -51
fs/namei.c
··· 449 449 mntget(nd->path.mnt); 450 450 451 451 rcu_read_unlock(); 452 - br_read_unlock(vfsmount_lock); 452 + br_read_unlock(&vfsmount_lock); 453 453 nd->flags &= ~LOOKUP_RCU; 454 454 return 0; 455 455 ··· 507 507 if (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) { 508 508 spin_unlock(&dentry->d_lock); 509 509 rcu_read_unlock(); 510 - br_read_unlock(vfsmount_lock); 510 + br_read_unlock(&vfsmount_lock); 511 511 return -ECHILD; 512 512 } 513 513 BUG_ON(nd->inode != dentry->d_inode); 514 514 spin_unlock(&dentry->d_lock); 515 515 mntget(nd->path.mnt); 516 516 rcu_read_unlock(); 517 - br_read_unlock(vfsmount_lock); 517 + br_read_unlock(&vfsmount_lock); 518 518 } 519 519 520 520 if (likely(!(nd->flags & LOOKUP_JUMPED))) ··· 681 681 struct mount *parent; 682 682 struct dentry *mountpoint; 683 683 684 - br_read_lock(vfsmount_lock); 684 + br_read_lock(&vfsmount_lock); 685 685 parent = mnt->mnt_parent; 686 686 if (&parent->mnt == path->mnt) { 687 - br_read_unlock(vfsmount_lock); 687 + br_read_unlock(&vfsmount_lock); 688 688 return 0; 689 689 } 690 690 mntget(&parent->mnt); 691 691 mountpoint = dget(mnt->mnt_mountpoint); 692 - br_read_unlock(vfsmount_lock); 692 + br_read_unlock(&vfsmount_lock); 693 693 dput(path->dentry); 694 694 path->dentry = mountpoint; 695 695 mntput(path->mnt); ··· 947 947 if (!(nd->flags & LOOKUP_ROOT)) 948 948 nd->root.mnt = NULL; 949 949 rcu_read_unlock(); 950 - br_read_unlock(vfsmount_lock); 950 + br_read_unlock(&vfsmount_lock); 951 951 return -ECHILD; 952 952 } 953 953 ··· 1125 1125 * small and for now I'd prefer to have fast path as straight as possible. 1126 1126 * It _is_ time-critical. 1127 1127 */ 1128 - static int do_lookup(struct nameidata *nd, struct qstr *name, 1129 - struct path *path, struct inode **inode) 1128 + static int lookup_fast(struct nameidata *nd, struct qstr *name, 1129 + struct path *path, struct inode **inode) 1130 1130 { 1131 1131 struct vfsmount *mnt = nd->path.mnt; 1132 1132 struct dentry *dentry, *parent = nd->path.dentry; ··· 1208 1208 goto need_lookup; 1209 1209 } 1210 1210 } 1211 - done: 1211 + 1212 1212 path->mnt = mnt; 1213 1213 path->dentry = dentry; 1214 1214 err = follow_managed(path, nd->flags); ··· 1222 1222 return 0; 1223 1223 1224 1224 need_lookup: 1225 + return 1; 1226 + } 1227 + 1228 + /* Fast lookup failed, do it the slow way */ 1229 + static int lookup_slow(struct nameidata *nd, struct qstr *name, 1230 + struct path *path) 1231 + { 1232 + struct dentry *dentry, *parent; 1233 + int err; 1234 + 1235 + parent = nd->path.dentry; 1225 1236 BUG_ON(nd->inode != parent->d_inode); 1226 1237 1227 1238 mutex_lock(&parent->d_inode->i_mutex); ··· 1240 1229 mutex_unlock(&parent->d_inode->i_mutex); 1241 1230 if (IS_ERR(dentry)) 1242 1231 return PTR_ERR(dentry); 1243 - goto done; 1232 + path->mnt = nd->path.mnt; 1233 + path->dentry = dentry; 1234 + err = follow_managed(path, nd->flags); 1235 + if (unlikely(err < 0)) { 1236 + path_put_conditional(path, nd); 1237 + return err; 1238 + } 1239 + if (err) 1240 + nd->flags |= LOOKUP_JUMPED; 1241 + return 0; 1244 1242 } 1245 1243 1246 1244 static inline int may_lookup(struct nameidata *nd) ··· 1285 1265 if (!(nd->flags & LOOKUP_ROOT)) 1286 1266 nd->root.mnt = NULL; 1287 1267 rcu_read_unlock(); 1288 - br_read_unlock(vfsmount_lock); 1268 + br_read_unlock(&vfsmount_lock); 1289 1269 } 1290 1270 } 1291 1271 ··· 1321 1301 */ 1322 1302 if (unlikely(type != LAST_NORM)) 1323 1303 return handle_dots(nd, type); 1324 - err = do_lookup(nd, name, path, &inode); 1304 + err = lookup_fast(nd, name, path, &inode); 1325 1305 if (unlikely(err)) { 1326 - terminate_walk(nd); 1327 - return err; 1306 + if (err < 0) 1307 + goto out_err; 1308 + 1309 + err = lookup_slow(nd, name, path); 1310 + if (err < 0) 1311 + goto out_err; 1312 + 1313 + inode = path->dentry->d_inode; 1328 1314 } 1329 - if (!inode) { 1330 - path_to_nameidata(path, nd); 1331 - terminate_walk(nd); 1332 - return -ENOENT; 1333 - } 1315 + err = -ENOENT; 1316 + if (!inode) 1317 + goto out_path_put; 1318 + 1334 1319 if (should_follow_link(inode, follow)) { 1335 1320 if (nd->flags & LOOKUP_RCU) { 1336 1321 if (unlikely(unlazy_walk(nd, path->dentry))) { 1337 - terminate_walk(nd); 1338 - return -ECHILD; 1322 + err = -ECHILD; 1323 + goto out_err; 1339 1324 } 1340 1325 } 1341 1326 BUG_ON(inode != path->dentry->d_inode); ··· 1349 1324 path_to_nameidata(path, nd); 1350 1325 nd->inode = inode; 1351 1326 return 0; 1327 + 1328 + out_path_put: 1329 + path_to_nameidata(path, nd); 1330 + out_err: 1331 + terminate_walk(nd); 1332 + return err; 1352 1333 } 1353 1334 1354 1335 /* ··· 1651 1620 nd->path = nd->root; 1652 1621 nd->inode = inode; 1653 1622 if (flags & LOOKUP_RCU) { 1654 - br_read_lock(vfsmount_lock); 1623 + br_read_lock(&vfsmount_lock); 1655 1624 rcu_read_lock(); 1656 1625 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); 1657 1626 } else { ··· 1664 1633 1665 1634 if (*name=='/') { 1666 1635 if (flags & LOOKUP_RCU) { 1667 - br_read_lock(vfsmount_lock); 1636 + br_read_lock(&vfsmount_lock); 1668 1637 rcu_read_lock(); 1669 1638 set_root_rcu(nd); 1670 1639 } else { ··· 1677 1646 struct fs_struct *fs = current->fs; 1678 1647 unsigned seq; 1679 1648 1680 - br_read_lock(vfsmount_lock); 1649 + br_read_lock(&vfsmount_lock); 1681 1650 rcu_read_lock(); 1682 1651 1683 1652 do { ··· 1713 1682 if (fput_needed) 1714 1683 *fp = file; 1715 1684 nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); 1716 - br_read_lock(vfsmount_lock); 1685 + br_read_lock(&vfsmount_lock); 1717 1686 rcu_read_lock(); 1718 1687 } else { 1719 1688 path_get(&file->f_path); ··· 2200 2169 int want_write = 0; 2201 2170 int acc_mode = op->acc_mode; 2202 2171 struct file *filp; 2172 + struct inode *inode; 2173 + int symlink_ok = 0; 2174 + struct path save_parent = { .dentry = NULL, .mnt = NULL }; 2175 + bool retried = false; 2203 2176 int error; 2204 2177 2205 2178 nd->flags &= ~LOOKUP_PARENT; ··· 2235 2200 } 2236 2201 2237 2202 if (!(open_flag & O_CREAT)) { 2238 - int symlink_ok = 0; 2239 2203 if (nd->last.name[nd->last.len]) 2240 2204 nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; 2241 2205 if (open_flag & O_PATH && !(nd->flags & LOOKUP_FOLLOW)) 2242 2206 symlink_ok = 1; 2243 2207 /* we _can_ be in RCU mode here */ 2244 - error = walk_component(nd, path, &nd->last, LAST_NORM, 2245 - !symlink_ok); 2246 - if (error < 0) 2247 - return ERR_PTR(error); 2248 - if (error) /* symlink */ 2249 - return NULL; 2250 - /* sayonara */ 2251 - error = complete_walk(nd); 2252 - if (error) 2253 - return ERR_PTR(error); 2254 - 2255 - error = -ENOTDIR; 2256 - if (nd->flags & LOOKUP_DIRECTORY) { 2257 - if (!nd->inode->i_op->lookup) 2208 + error = lookup_fast(nd, &nd->last, path, &inode); 2209 + if (unlikely(error)) { 2210 + if (error < 0) 2258 2211 goto exit; 2212 + 2213 + error = lookup_slow(nd, &nd->last, path); 2214 + if (error < 0) 2215 + goto exit; 2216 + 2217 + inode = path->dentry->d_inode; 2259 2218 } 2260 - audit_inode(pathname, nd->path.dentry); 2261 - goto ok; 2219 + goto finish_lookup; 2262 2220 } 2263 2221 2264 2222 /* create side of things */ ··· 2269 2241 if (nd->last.name[nd->last.len]) 2270 2242 goto exit; 2271 2243 2244 + retry_lookup: 2272 2245 mutex_lock(&dir->d_inode->i_mutex); 2273 2246 2274 2247 dentry = lookup_hash(nd); ··· 2331 2302 if (error) 2332 2303 nd->flags |= LOOKUP_JUMPED; 2333 2304 2305 + BUG_ON(nd->flags & LOOKUP_RCU); 2306 + inode = path->dentry->d_inode; 2307 + finish_lookup: 2308 + /* we _can_ be in RCU mode here */ 2334 2309 error = -ENOENT; 2335 - if (!path->dentry->d_inode) 2336 - goto exit_dput; 2310 + if (!inode) { 2311 + path_to_nameidata(path, nd); 2312 + goto exit; 2313 + } 2337 2314 2338 - if (path->dentry->d_inode->i_op->follow_link) 2315 + if (should_follow_link(inode, !symlink_ok)) { 2316 + if (nd->flags & LOOKUP_RCU) { 2317 + if (unlikely(unlazy_walk(nd, path->dentry))) { 2318 + error = -ECHILD; 2319 + goto exit; 2320 + } 2321 + } 2322 + BUG_ON(inode != path->dentry->d_inode); 2339 2323 return NULL; 2324 + } 2340 2325 2341 - path_to_nameidata(path, nd); 2342 - nd->inode = path->dentry->d_inode; 2326 + if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) { 2327 + path_to_nameidata(path, nd); 2328 + } else { 2329 + save_parent.dentry = nd->path.dentry; 2330 + save_parent.mnt = mntget(path->mnt); 2331 + nd->path.dentry = path->dentry; 2332 + 2333 + } 2334 + nd->inode = inode; 2343 2335 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */ 2344 2336 error = complete_walk(nd); 2345 - if (error) 2337 + if (error) { 2338 + path_put(&save_parent); 2346 2339 return ERR_PTR(error); 2340 + } 2347 2341 error = -EISDIR; 2348 - if (S_ISDIR(nd->inode->i_mode)) 2342 + if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode)) 2349 2343 goto exit; 2344 + error = -ENOTDIR; 2345 + if ((nd->flags & LOOKUP_DIRECTORY) && !nd->inode->i_op->lookup) 2346 + goto exit; 2347 + audit_inode(pathname, nd->path.dentry); 2350 2348 ok: 2351 2349 if (!S_ISREG(nd->inode->i_mode)) 2352 2350 will_truncate = 0; ··· 2389 2333 if (error) 2390 2334 goto exit; 2391 2335 filp = nameidata_to_filp(nd); 2336 + if (filp == ERR_PTR(-EOPENSTALE) && save_parent.dentry && !retried) { 2337 + BUG_ON(save_parent.dentry != dir); 2338 + path_put(&nd->path); 2339 + nd->path = save_parent; 2340 + nd->inode = dir->d_inode; 2341 + save_parent.mnt = NULL; 2342 + save_parent.dentry = NULL; 2343 + if (want_write) { 2344 + mnt_drop_write(nd->path.mnt); 2345 + want_write = 0; 2346 + } 2347 + retried = true; 2348 + goto retry_lookup; 2349 + } 2392 2350 if (!IS_ERR(filp)) { 2393 2351 error = ima_file_check(filp, op->acc_mode); 2394 2352 if (error) { ··· 2422 2352 out: 2423 2353 if (want_write) 2424 2354 mnt_drop_write(nd->path.mnt); 2425 - path_put(&nd->path); 2355 + path_put(&save_parent); 2356 + terminate_walk(nd); 2426 2357 return filp; 2427 2358 2428 2359 exit_mutex_unlock: ··· 2486 2415 if (base) 2487 2416 fput(base); 2488 2417 release_open_intent(nd); 2418 + if (filp == ERR_PTR(-EOPENSTALE)) { 2419 + if (flags & LOOKUP_RCU) 2420 + filp = ERR_PTR(-ECHILD); 2421 + else 2422 + filp = ERR_PTR(-ESTALE); 2423 + } 2489 2424 return filp; 2490 2425 2491 2426 out_filp:
+72 -70
fs/namespace.c
··· 397 397 { 398 398 int ret = 0; 399 399 400 - br_write_lock(vfsmount_lock); 400 + br_write_lock(&vfsmount_lock); 401 401 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; 402 402 /* 403 403 * After storing MNT_WRITE_HOLD, we'll read the counters. This store ··· 431 431 */ 432 432 smp_wmb(); 433 433 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; 434 - br_write_unlock(vfsmount_lock); 434 + br_write_unlock(&vfsmount_lock); 435 435 return ret; 436 436 } 437 437 438 438 static void __mnt_unmake_readonly(struct mount *mnt) 439 439 { 440 - br_write_lock(vfsmount_lock); 440 + br_write_lock(&vfsmount_lock); 441 441 mnt->mnt.mnt_flags &= ~MNT_READONLY; 442 - br_write_unlock(vfsmount_lock); 442 + br_write_unlock(&vfsmount_lock); 443 443 } 444 444 445 445 int sb_prepare_remount_readonly(struct super_block *sb) ··· 451 451 if (atomic_long_read(&sb->s_remove_count)) 452 452 return -EBUSY; 453 453 454 - br_write_lock(vfsmount_lock); 454 + br_write_lock(&vfsmount_lock); 455 455 list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) { 456 456 if (!(mnt->mnt.mnt_flags & MNT_READONLY)) { 457 457 mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; ··· 473 473 if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD) 474 474 mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; 475 475 } 476 - br_write_unlock(vfsmount_lock); 476 + br_write_unlock(&vfsmount_lock); 477 477 478 478 return err; 479 479 } ··· 522 522 { 523 523 struct mount *child_mnt; 524 524 525 - br_read_lock(vfsmount_lock); 525 + br_read_lock(&vfsmount_lock); 526 526 child_mnt = __lookup_mnt(path->mnt, path->dentry, 1); 527 527 if (child_mnt) { 528 528 mnt_add_count(child_mnt, 1); 529 - br_read_unlock(vfsmount_lock); 529 + br_read_unlock(&vfsmount_lock); 530 530 return &child_mnt->mnt; 531 531 } else { 532 - br_read_unlock(vfsmount_lock); 532 + br_read_unlock(&vfsmount_lock); 533 533 return NULL; 534 534 } 535 535 } ··· 714 714 mnt->mnt.mnt_sb = root->d_sb; 715 715 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 716 716 mnt->mnt_parent = mnt; 717 - br_write_lock(vfsmount_lock); 717 + br_write_lock(&vfsmount_lock); 718 718 list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts); 719 - br_write_unlock(vfsmount_lock); 719 + br_write_unlock(&vfsmount_lock); 720 720 return &mnt->mnt; 721 721 } 722 722 EXPORT_SYMBOL_GPL(vfs_kern_mount); ··· 745 745 mnt->mnt.mnt_root = dget(root); 746 746 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 747 747 mnt->mnt_parent = mnt; 748 - br_write_lock(vfsmount_lock); 748 + br_write_lock(&vfsmount_lock); 749 749 list_add_tail(&mnt->mnt_instance, &sb->s_mounts); 750 - br_write_unlock(vfsmount_lock); 750 + br_write_unlock(&vfsmount_lock); 751 751 752 752 if (flag & CL_SLAVE) { 753 753 list_add(&mnt->mnt_slave, &old->mnt_slave_list); ··· 803 803 { 804 804 put_again: 805 805 #ifdef CONFIG_SMP 806 - br_read_lock(vfsmount_lock); 806 + br_read_lock(&vfsmount_lock); 807 807 if (likely(atomic_read(&mnt->mnt_longterm))) { 808 808 mnt_add_count(mnt, -1); 809 - br_read_unlock(vfsmount_lock); 809 + br_read_unlock(&vfsmount_lock); 810 810 return; 811 811 } 812 - br_read_unlock(vfsmount_lock); 812 + br_read_unlock(&vfsmount_lock); 813 813 814 - br_write_lock(vfsmount_lock); 814 + br_write_lock(&vfsmount_lock); 815 815 mnt_add_count(mnt, -1); 816 816 if (mnt_get_count(mnt)) { 817 - br_write_unlock(vfsmount_lock); 817 + br_write_unlock(&vfsmount_lock); 818 818 return; 819 819 } 820 820 #else 821 821 mnt_add_count(mnt, -1); 822 822 if (likely(mnt_get_count(mnt))) 823 823 return; 824 - br_write_lock(vfsmount_lock); 824 + br_write_lock(&vfsmount_lock); 825 825 #endif 826 826 if (unlikely(mnt->mnt_pinned)) { 827 827 mnt_add_count(mnt, mnt->mnt_pinned + 1); 828 828 mnt->mnt_pinned = 0; 829 - br_write_unlock(vfsmount_lock); 829 + br_write_unlock(&vfsmount_lock); 830 830 acct_auto_close_mnt(&mnt->mnt); 831 831 goto put_again; 832 832 } 833 + 833 834 list_del(&mnt->mnt_instance); 834 - br_write_unlock(vfsmount_lock); 835 + br_write_unlock(&vfsmount_lock); 835 836 mntfree(mnt); 836 837 } 837 838 ··· 858 857 859 858 void mnt_pin(struct vfsmount *mnt) 860 859 { 861 - br_write_lock(vfsmount_lock); 860 + br_write_lock(&vfsmount_lock); 862 861 real_mount(mnt)->mnt_pinned++; 863 - br_write_unlock(vfsmount_lock); 862 + br_write_unlock(&vfsmount_lock); 864 863 } 865 864 EXPORT_SYMBOL(mnt_pin); 866 865 867 866 void mnt_unpin(struct vfsmount *m) 868 867 { 869 868 struct mount *mnt = real_mount(m); 870 - br_write_lock(vfsmount_lock); 869 + br_write_lock(&vfsmount_lock); 871 870 if (mnt->mnt_pinned) { 872 871 mnt_add_count(mnt, 1); 873 872 mnt->mnt_pinned--; 874 873 } 875 - br_write_unlock(vfsmount_lock); 874 + br_write_unlock(&vfsmount_lock); 876 875 } 877 876 EXPORT_SYMBOL(mnt_unpin); 878 877 ··· 989 988 BUG_ON(!m); 990 989 991 990 /* write lock needed for mnt_get_count */ 992 - br_write_lock(vfsmount_lock); 991 + br_write_lock(&vfsmount_lock); 993 992 for (p = mnt; p; p = next_mnt(p, mnt)) { 994 993 actual_refs += mnt_get_count(p); 995 994 minimum_refs += 2; 996 995 } 997 - br_write_unlock(vfsmount_lock); 996 + br_write_unlock(&vfsmount_lock); 998 997 999 998 if (actual_refs > minimum_refs) 1000 999 return 0; ··· 1021 1020 { 1022 1021 int ret = 1; 1023 1022 down_read(&namespace_sem); 1024 - br_write_lock(vfsmount_lock); 1023 + br_write_lock(&vfsmount_lock); 1025 1024 if (propagate_mount_busy(real_mount(mnt), 2)) 1026 1025 ret = 0; 1027 - br_write_unlock(vfsmount_lock); 1026 + br_write_unlock(&vfsmount_lock); 1028 1027 up_read(&namespace_sem); 1029 1028 return ret; 1030 1029 } ··· 1041 1040 struct dentry *dentry; 1042 1041 struct mount *m; 1043 1042 1044 - br_write_lock(vfsmount_lock); 1043 + br_write_lock(&vfsmount_lock); 1045 1044 dentry = mnt->mnt_mountpoint; 1046 1045 m = mnt->mnt_parent; 1047 1046 mnt->mnt_mountpoint = mnt->mnt.mnt_root; 1048 1047 mnt->mnt_parent = mnt; 1049 1048 m->mnt_ghosts--; 1050 - br_write_unlock(vfsmount_lock); 1049 + br_write_unlock(&vfsmount_lock); 1051 1050 dput(dentry); 1052 1051 mntput(&m->mnt); 1053 1052 } ··· 1074 1073 list_del_init(&p->mnt_expire); 1075 1074 list_del_init(&p->mnt_list); 1076 1075 __touch_mnt_namespace(p->mnt_ns); 1076 + if (p->mnt_ns) 1077 + __mnt_make_shortterm(p); 1077 1078 p->mnt_ns = NULL; 1078 - __mnt_make_shortterm(p); 1079 1079 list_del_init(&p->mnt_child); 1080 1080 if (mnt_has_parent(p)) { 1081 1081 p->mnt_parent->mnt_ghosts++; ··· 1114 1112 * probably don't strictly need the lock here if we examined 1115 1113 * all race cases, but it's a slowpath. 1116 1114 */ 1117 - br_write_lock(vfsmount_lock); 1115 + br_write_lock(&vfsmount_lock); 1118 1116 if (mnt_get_count(mnt) != 2) { 1119 - br_write_unlock(vfsmount_lock); 1117 + br_write_unlock(&vfsmount_lock); 1120 1118 return -EBUSY; 1121 1119 } 1122 - br_write_unlock(vfsmount_lock); 1120 + br_write_unlock(&vfsmount_lock); 1123 1121 1124 1122 if (!xchg(&mnt->mnt_expiry_mark, 1)) 1125 1123 return -EAGAIN; ··· 1161 1159 } 1162 1160 1163 1161 down_write(&namespace_sem); 1164 - br_write_lock(vfsmount_lock); 1162 + br_write_lock(&vfsmount_lock); 1165 1163 event++; 1166 1164 1167 1165 if (!(flags & MNT_DETACH)) ··· 1173 1171 umount_tree(mnt, 1, &umount_list); 1174 1172 retval = 0; 1175 1173 } 1176 - br_write_unlock(vfsmount_lock); 1174 + br_write_unlock(&vfsmount_lock); 1177 1175 up_write(&namespace_sem); 1178 1176 release_mounts(&umount_list); 1179 1177 return retval; ··· 1288 1286 q = clone_mnt(p, p->mnt.mnt_root, flag); 1289 1287 if (!q) 1290 1288 goto Enomem; 1291 - br_write_lock(vfsmount_lock); 1289 + br_write_lock(&vfsmount_lock); 1292 1290 list_add_tail(&q->mnt_list, &res->mnt_list); 1293 1291 attach_mnt(q, &path); 1294 - br_write_unlock(vfsmount_lock); 1292 + br_write_unlock(&vfsmount_lock); 1295 1293 } 1296 1294 } 1297 1295 return res; 1298 1296 Enomem: 1299 1297 if (res) { 1300 1298 LIST_HEAD(umount_list); 1301 - br_write_lock(vfsmount_lock); 1299 + br_write_lock(&vfsmount_lock); 1302 1300 umount_tree(res, 0, &umount_list); 1303 - br_write_unlock(vfsmount_lock); 1301 + br_write_unlock(&vfsmount_lock); 1304 1302 release_mounts(&umount_list); 1305 1303 } 1306 1304 return NULL; ··· 1320 1318 { 1321 1319 LIST_HEAD(umount_list); 1322 1320 down_write(&namespace_sem); 1323 - br_write_lock(vfsmount_lock); 1321 + br_write_lock(&vfsmount_lock); 1324 1322 umount_tree(real_mount(mnt), 0, &umount_list); 1325 - br_write_unlock(vfsmount_lock); 1323 + br_write_unlock(&vfsmount_lock); 1326 1324 up_write(&namespace_sem); 1327 1325 release_mounts(&umount_list); 1328 1326 } ··· 1450 1448 if (err) 1451 1449 goto out_cleanup_ids; 1452 1450 1453 - br_write_lock(vfsmount_lock); 1451 + br_write_lock(&vfsmount_lock); 1454 1452 1455 1453 if (IS_MNT_SHARED(dest_mnt)) { 1456 1454 for (p = source_mnt; p; p = next_mnt(p, source_mnt)) ··· 1469 1467 list_del_init(&child->mnt_hash); 1470 1468 commit_tree(child); 1471 1469 } 1472 - br_write_unlock(vfsmount_lock); 1470 + br_write_unlock(&vfsmount_lock); 1473 1471 1474 1472 return 0; 1475 1473 ··· 1567 1565 goto out_unlock; 1568 1566 } 1569 1567 1570 - br_write_lock(vfsmount_lock); 1568 + br_write_lock(&vfsmount_lock); 1571 1569 for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) 1572 1570 change_mnt_propagation(m, type); 1573 - br_write_unlock(vfsmount_lock); 1571 + br_write_unlock(&vfsmount_lock); 1574 1572 1575 1573 out_unlock: 1576 1574 up_write(&namespace_sem); ··· 1619 1617 1620 1618 err = graft_tree(mnt, path); 1621 1619 if (err) { 1622 - br_write_lock(vfsmount_lock); 1620 + br_write_lock(&vfsmount_lock); 1623 1621 umount_tree(mnt, 0, &umount_list); 1624 - br_write_unlock(vfsmount_lock); 1622 + br_write_unlock(&vfsmount_lock); 1625 1623 } 1626 1624 out2: 1627 1625 unlock_mount(path); ··· 1679 1677 else 1680 1678 err = do_remount_sb(sb, flags, data, 0); 1681 1679 if (!err) { 1682 - br_write_lock(vfsmount_lock); 1680 + br_write_lock(&vfsmount_lock); 1683 1681 mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK; 1684 1682 mnt->mnt.mnt_flags = mnt_flags; 1685 - br_write_unlock(vfsmount_lock); 1683 + br_write_unlock(&vfsmount_lock); 1686 1684 } 1687 1685 up_write(&sb->s_umount); 1688 1686 if (!err) { 1689 - br_write_lock(vfsmount_lock); 1687 + br_write_lock(&vfsmount_lock); 1690 1688 touch_mnt_namespace(mnt->mnt_ns); 1691 - br_write_unlock(vfsmount_lock); 1689 + br_write_unlock(&vfsmount_lock); 1692 1690 } 1693 1691 return err; 1694 1692 } ··· 1895 1893 /* remove m from any expiration list it may be on */ 1896 1894 if (!list_empty(&mnt->mnt_expire)) { 1897 1895 down_write(&namespace_sem); 1898 - br_write_lock(vfsmount_lock); 1896 + br_write_lock(&vfsmount_lock); 1899 1897 list_del_init(&mnt->mnt_expire); 1900 - br_write_unlock(vfsmount_lock); 1898 + br_write_unlock(&vfsmount_lock); 1901 1899 up_write(&namespace_sem); 1902 1900 } 1903 1901 mntput(m); ··· 1913 1911 void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list) 1914 1912 { 1915 1913 down_write(&namespace_sem); 1916 - br_write_lock(vfsmount_lock); 1914 + br_write_lock(&vfsmount_lock); 1917 1915 1918 1916 list_add_tail(&real_mount(mnt)->mnt_expire, expiry_list); 1919 1917 1920 - br_write_unlock(vfsmount_lock); 1918 + br_write_unlock(&vfsmount_lock); 1921 1919 up_write(&namespace_sem); 1922 1920 } 1923 1921 EXPORT_SYMBOL(mnt_set_expiry); ··· 1937 1935 return; 1938 1936 1939 1937 down_write(&namespace_sem); 1940 - br_write_lock(vfsmount_lock); 1938 + br_write_lock(&vfsmount_lock); 1941 1939 1942 1940 /* extract from the expiration list every vfsmount that matches the 1943 1941 * following criteria: ··· 1956 1954 touch_mnt_namespace(mnt->mnt_ns); 1957 1955 umount_tree(mnt, 1, &umounts); 1958 1956 } 1959 - br_write_unlock(vfsmount_lock); 1957 + br_write_unlock(&vfsmount_lock); 1960 1958 up_write(&namespace_sem); 1961 1959 1962 1960 release_mounts(&umounts); ··· 2220 2218 struct mount *mnt = real_mount(m); 2221 2219 if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) 2222 2220 return; 2223 - br_write_lock(vfsmount_lock); 2221 + br_write_lock(&vfsmount_lock); 2224 2222 atomic_dec(&mnt->mnt_longterm); 2225 - br_write_unlock(vfsmount_lock); 2223 + br_write_unlock(&vfsmount_lock); 2226 2224 #endif 2227 2225 } 2228 2226 ··· 2252 2250 return ERR_PTR(-ENOMEM); 2253 2251 } 2254 2252 new_ns->root = new; 2255 - br_write_lock(vfsmount_lock); 2253 + br_write_lock(&vfsmount_lock); 2256 2254 list_add_tail(&new_ns->list, &new->mnt_list); 2257 - br_write_unlock(vfsmount_lock); 2255 + br_write_unlock(&vfsmount_lock); 2258 2256 2259 2257 /* 2260 2258 * Second pass: switch the tsk->fs->* elements and mark new vfsmounts ··· 2418 2416 int path_is_under(struct path *path1, struct path *path2) 2419 2417 { 2420 2418 int res; 2421 - br_read_lock(vfsmount_lock); 2419 + br_read_lock(&vfsmount_lock); 2422 2420 res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2); 2423 - br_read_unlock(vfsmount_lock); 2421 + br_read_unlock(&vfsmount_lock); 2424 2422 return res; 2425 2423 } 2426 2424 EXPORT_SYMBOL(path_is_under); ··· 2507 2505 /* make sure we can reach put_old from new_root */ 2508 2506 if (!is_path_reachable(real_mount(old.mnt), old.dentry, &new)) 2509 2507 goto out4; 2510 - br_write_lock(vfsmount_lock); 2508 + br_write_lock(&vfsmount_lock); 2511 2509 detach_mnt(new_mnt, &parent_path); 2512 2510 detach_mnt(root_mnt, &root_parent); 2513 2511 /* mount old root on put_old */ ··· 2515 2513 /* mount new_root on / */ 2516 2514 attach_mnt(new_mnt, &root_parent); 2517 2515 touch_mnt_namespace(current->nsproxy->mnt_ns); 2518 - br_write_unlock(vfsmount_lock); 2516 + br_write_unlock(&vfsmount_lock); 2519 2517 chroot_fs_refs(&root, &new); 2520 2518 error = 0; 2521 2519 out4: ··· 2578 2576 for (u = 0; u < HASH_SIZE; u++) 2579 2577 INIT_LIST_HEAD(&mount_hashtable[u]); 2580 2578 2581 - br_lock_init(vfsmount_lock); 2579 + br_lock_init(&vfsmount_lock); 2582 2580 2583 2581 err = sysfs_init(); 2584 2582 if (err) ··· 2598 2596 if (!atomic_dec_and_test(&ns->count)) 2599 2597 return; 2600 2598 down_write(&namespace_sem); 2601 - br_write_lock(vfsmount_lock); 2599 + br_write_lock(&vfsmount_lock); 2602 2600 umount_tree(ns->root, 0, &umount_list); 2603 - br_write_unlock(vfsmount_lock); 2601 + br_write_unlock(&vfsmount_lock); 2604 2602 up_write(&namespace_sem); 2605 2603 release_mounts(&umount_list); 2606 2604 kfree(ns);
+4 -2
fs/ncpfs/file.c
··· 221 221 222 222 already_written = 0; 223 223 224 + errno = file_update_time(file); 225 + if (errno) 226 + goto outrel; 227 + 224 228 bouncebuffer = vmalloc(bufsize); 225 229 if (!bouncebuffer) { 226 230 errno = -EIO; /* -ENOMEM */ ··· 255 251 } 256 252 } 257 253 vfree(bouncebuffer); 258 - 259 - file_update_time(file); 260 254 261 255 *ppos = pos; 262 256
+5 -5
fs/ncpfs/ncp_fs_sb.h
··· 23 23 unsigned long flags; /* NCP_MOUNT_* flags */ 24 24 unsigned int int_flags; /* internal flags */ 25 25 #define NCP_IMOUNT_LOGGEDIN_POSSIBLE 0x0001 26 - __kernel_uid32_t mounted_uid; /* Who may umount() this filesystem? */ 26 + uid_t mounted_uid; /* Who may umount() this filesystem? */ 27 27 struct pid *wdog_pid; /* Who cares for our watchdog packets? */ 28 28 unsigned int ncp_fd; /* The socket to the ncp port */ 29 29 unsigned int time_out; /* How long should I wait after 30 30 sending a NCP request? */ 31 31 unsigned int retry_count; /* And how often should I retry? */ 32 32 unsigned char mounted_vol[NCP_VOLNAME_LEN + 1]; 33 - __kernel_uid32_t uid; 34 - __kernel_gid32_t gid; 35 - __kernel_mode_t file_mode; 36 - __kernel_mode_t dir_mode; 33 + uid_t uid; 34 + gid_t gid; 35 + umode_t file_mode; 36 + umode_t dir_mode; 37 37 int info_fd; 38 38 }; 39 39
+5 -51
fs/nfs/dir.c
··· 1354 1354 } 1355 1355 1356 1356 #ifdef CONFIG_NFS_V4 1357 - static int nfs_open_revalidate(struct dentry *, struct nameidata *); 1357 + static int nfs4_lookup_revalidate(struct dentry *, struct nameidata *); 1358 1358 1359 1359 const struct dentry_operations nfs4_dentry_operations = { 1360 - .d_revalidate = nfs_open_revalidate, 1360 + .d_revalidate = nfs4_lookup_revalidate, 1361 1361 .d_delete = nfs_dentry_delete, 1362 1362 .d_iput = nfs_dentry_iput, 1363 1363 .d_automount = nfs_d_automount, ··· 1519 1519 return nfs_lookup(dir, dentry, nd); 1520 1520 } 1521 1521 1522 - static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) 1522 + static int nfs4_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) 1523 1523 { 1524 1524 struct dentry *parent = NULL; 1525 1525 struct inode *inode; 1526 1526 struct inode *dir; 1527 - struct nfs_open_context *ctx; 1528 - struct iattr attr; 1529 1527 int openflags, ret = 0; 1530 1528 1531 1529 if (nd->flags & LOOKUP_RCU) ··· 1552 1554 /* We cannot do exclusive creation on a positive dentry */ 1553 1555 if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) 1554 1556 goto no_open_dput; 1555 - /* We can't create new files here */ 1556 - openflags &= ~(O_CREAT|O_EXCL); 1557 1557 1558 - ctx = create_nfs_open_context(dentry, openflags); 1559 - ret = PTR_ERR(ctx); 1560 - if (IS_ERR(ctx)) 1561 - goto out; 1558 + /* Let f_op->open() actually open (and revalidate) the file */ 1559 + ret = 1; 1562 1560 1563 - attr.ia_valid = ATTR_OPEN; 1564 - if (openflags & O_TRUNC) { 1565 - attr.ia_valid |= ATTR_SIZE; 1566 - attr.ia_size = 0; 1567 - nfs_wb_all(inode); 1568 - } 1569 - 1570 - /* 1571 - * Note: we're not holding inode->i_mutex and so may be racing with 1572 - * operations that change the directory. We therefore save the 1573 - * change attribute *before* we do the RPC call. 1574 - */ 1575 - inode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr); 1576 - if (IS_ERR(inode)) { 1577 - ret = PTR_ERR(inode); 1578 - switch (ret) { 1579 - case -EPERM: 1580 - case -EACCES: 1581 - case -EDQUOT: 1582 - case -ENOSPC: 1583 - case -EROFS: 1584 - goto out_put_ctx; 1585 - default: 1586 - goto out_drop; 1587 - } 1588 - } 1589 - iput(inode); 1590 - if (inode != dentry->d_inode) 1591 - goto out_drop; 1592 - 1593 - nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1594 - ret = nfs_intent_set_file(nd, ctx); 1595 - if (ret >= 0) 1596 - ret = 1; 1597 1561 out: 1598 1562 dput(parent); 1599 1563 return ret; 1600 - out_drop: 1601 - d_drop(dentry); 1602 - ret = 0; 1603 - out_put_ctx: 1604 - put_nfs_open_context(ctx); 1605 - goto out; 1606 1564 1607 1565 no_open_dput: 1608 1566 dput(parent);
+73 -4
fs/nfs/file.c
··· 879 879 static int 880 880 nfs4_file_open(struct inode *inode, struct file *filp) 881 881 { 882 + struct nfs_open_context *ctx; 883 + struct dentry *dentry = filp->f_path.dentry; 884 + struct dentry *parent = NULL; 885 + struct inode *dir; 886 + unsigned openflags = filp->f_flags; 887 + struct iattr attr; 888 + int err; 889 + 890 + BUG_ON(inode != dentry->d_inode); 882 891 /* 883 - * NFSv4 opens are handled in d_lookup and d_revalidate. If we get to 884 - * this point, then something is very wrong 892 + * If no cached dentry exists or if it's negative, NFSv4 handled the 893 + * opens in ->lookup() or ->create(). 894 + * 895 + * We only get this far for a cached positive dentry. We skipped 896 + * revalidation, so handle it here by dropping the dentry and returning 897 + * -EOPENSTALE. The VFS will retry the lookup/create/open. 885 898 */ 886 - dprintk("NFS: %s called! inode=%p filp=%p\n", __func__, inode, filp); 887 - return -ENOTDIR; 899 + 900 + dprintk("NFS: open file(%s/%s)\n", 901 + dentry->d_parent->d_name.name, 902 + dentry->d_name.name); 903 + 904 + if ((openflags & O_ACCMODE) == 3) 905 + openflags--; 906 + 907 + /* We can't create new files here */ 908 + openflags &= ~(O_CREAT|O_EXCL); 909 + 910 + parent = dget_parent(dentry); 911 + dir = parent->d_inode; 912 + 913 + ctx = alloc_nfs_open_context(filp->f_path.dentry, filp->f_mode); 914 + err = PTR_ERR(ctx); 915 + if (IS_ERR(ctx)) 916 + goto out; 917 + 918 + attr.ia_valid = ATTR_OPEN; 919 + if (openflags & O_TRUNC) { 920 + attr.ia_valid |= ATTR_SIZE; 921 + attr.ia_size = 0; 922 + nfs_wb_all(inode); 923 + } 924 + 925 + inode = NFS_PROTO(dir)->open_context(dir, ctx, openflags, &attr); 926 + if (IS_ERR(inode)) { 927 + err = PTR_ERR(inode); 928 + switch (err) { 929 + case -EPERM: 930 + case -EACCES: 931 + case -EDQUOT: 932 + case -ENOSPC: 933 + case -EROFS: 934 + goto out_put_ctx; 935 + default: 936 + goto out_drop; 937 + } 938 + } 939 + iput(inode); 940 + if (inode != dentry->d_inode) 941 + goto out_drop; 942 + 943 + nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 944 + nfs_file_set_open_context(filp, ctx); 945 + err = 0; 946 + 947 + out_put_ctx: 948 + put_nfs_open_context(ctx); 949 + out: 950 + dput(parent); 951 + return err; 952 + 953 + out_drop: 954 + d_drop(dentry); 955 + err = -EOPENSTALE; 956 + goto out_put_ctx; 888 957 } 889 958 890 959 const struct file_operations nfs4_file_operations = {
+10 -12
fs/nilfs2/namei.c
··· 508 508 return nilfs_get_dentry(sb, fid->cno, fid->parent_ino, fid->parent_gen); 509 509 } 510 510 511 - static int nilfs_encode_fh(struct dentry *dentry, __u32 *fh, int *lenp, 512 - int connectable) 511 + static int nilfs_encode_fh(struct inode *inode, __u32 *fh, int *lenp, 512 + struct inode *parent) 513 513 { 514 514 struct nilfs_fid *fid = (struct nilfs_fid *)fh; 515 - struct inode *inode = dentry->d_inode; 516 515 struct nilfs_root *root = NILFS_I(inode)->i_root; 517 516 int type; 518 517 519 - if (*lenp < NILFS_FID_SIZE_NON_CONNECTABLE || 520 - (connectable && *lenp < NILFS_FID_SIZE_CONNECTABLE)) 518 + if (parent && *lenp < NILFS_FID_SIZE_CONNECTABLE) { 519 + *lenp = NILFS_FID_SIZE_CONNECTABLE; 521 520 return 255; 521 + } 522 + if (*lenp < NILFS_FID_SIZE_NON_CONNECTABLE) { 523 + *lenp = NILFS_FID_SIZE_NON_CONNECTABLE; 524 + return 255; 525 + } 522 526 523 527 fid->cno = root->cno; 524 528 fid->ino = inode->i_ino; 525 529 fid->gen = inode->i_generation; 526 530 527 - if (connectable && !S_ISDIR(inode->i_mode)) { 528 - struct inode *parent; 529 - 530 - spin_lock(&dentry->d_lock); 531 - parent = dentry->d_parent->d_inode; 531 + if (parent) { 532 532 fid->parent_ino = parent->i_ino; 533 533 fid->parent_gen = parent->i_generation; 534 - spin_unlock(&dentry->d_lock); 535 - 536 534 type = FILEID_NILFS_WITH_PARENT; 537 535 *lenp = NILFS_FID_SIZE_CONNECTABLE; 538 536 } else {
+6 -6
fs/notify/fsnotify.c
··· 123 123 } 124 124 EXPORT_SYMBOL_GPL(__fsnotify_parent); 125 125 126 - static int send_to_group(struct inode *to_tell, struct vfsmount *mnt, 126 + static int send_to_group(struct inode *to_tell, 127 127 struct fsnotify_mark *inode_mark, 128 128 struct fsnotify_mark *vfsmount_mark, 129 129 __u32 mask, void *data, ··· 168 168 vfsmount_test_mask &= ~inode_mark->ignored_mask; 169 169 } 170 170 171 - pr_debug("%s: group=%p to_tell=%p mnt=%p mask=%x inode_mark=%p" 171 + pr_debug("%s: group=%p to_tell=%p mask=%x inode_mark=%p" 172 172 " inode_test_mask=%x vfsmount_mark=%p vfsmount_test_mask=%x" 173 173 " data=%p data_is=%d cookie=%d event=%p\n", 174 - __func__, group, to_tell, mnt, mask, inode_mark, 174 + __func__, group, to_tell, mask, inode_mark, 175 175 inode_test_mask, vfsmount_mark, vfsmount_test_mask, data, 176 176 data_is, cookie, *event); 177 177 ··· 258 258 259 259 if (inode_group > vfsmount_group) { 260 260 /* handle inode */ 261 - ret = send_to_group(to_tell, NULL, inode_mark, NULL, mask, data, 261 + ret = send_to_group(to_tell, inode_mark, NULL, mask, data, 262 262 data_is, cookie, file_name, &event); 263 263 /* we didn't use the vfsmount_mark */ 264 264 vfsmount_group = NULL; 265 265 } else if (vfsmount_group > inode_group) { 266 - ret = send_to_group(to_tell, &mnt->mnt, NULL, vfsmount_mark, mask, data, 266 + ret = send_to_group(to_tell, NULL, vfsmount_mark, mask, data, 267 267 data_is, cookie, file_name, &event); 268 268 inode_group = NULL; 269 269 } else { 270 - ret = send_to_group(to_tell, &mnt->mnt, inode_mark, vfsmount_mark, 270 + ret = send_to_group(to_tell, inode_mark, vfsmount_mark, 271 271 mask, data, data_is, cookie, file_name, 272 272 &event); 273 273 }
+3 -1
fs/ntfs/file.c
··· 2096 2096 err = file_remove_suid(file); 2097 2097 if (err) 2098 2098 goto out; 2099 - file_update_time(file); 2099 + err = file_update_time(file); 2100 + if (err) 2101 + goto out; 2100 2102 written = ntfs_file_buffered_write(iocb, iov, nr_segs, pos, ppos, 2101 2103 count); 2102 2104 out:
+22 -20
fs/ocfs2/blockcheck.c
··· 422 422 struct ocfs2_blockcheck_stats *stats) 423 423 { 424 424 int rc = 0; 425 - struct ocfs2_block_check check; 425 + u32 bc_crc32e; 426 + u16 bc_ecc; 426 427 u32 crc, ecc; 427 428 428 429 ocfs2_blockcheck_inc_check(stats); 429 430 430 - check.bc_crc32e = le32_to_cpu(bc->bc_crc32e); 431 - check.bc_ecc = le16_to_cpu(bc->bc_ecc); 431 + bc_crc32e = le32_to_cpu(bc->bc_crc32e); 432 + bc_ecc = le16_to_cpu(bc->bc_ecc); 432 433 433 434 memset(bc, 0, sizeof(struct ocfs2_block_check)); 434 435 435 436 /* Fast path - if the crc32 validates, we're good to go */ 436 437 crc = crc32_le(~0, data, blocksize); 437 - if (crc == check.bc_crc32e) 438 + if (crc == bc_crc32e) 438 439 goto out; 439 440 440 441 ocfs2_blockcheck_inc_failure(stats); 441 442 mlog(ML_ERROR, 442 443 "CRC32 failed: stored: 0x%x, computed 0x%x. Applying ECC.\n", 443 - (unsigned int)check.bc_crc32e, (unsigned int)crc); 444 + (unsigned int)bc_crc32e, (unsigned int)crc); 444 445 445 446 /* Ok, try ECC fixups */ 446 447 ecc = ocfs2_hamming_encode_block(data, blocksize); 447 - ocfs2_hamming_fix_block(data, blocksize, ecc ^ check.bc_ecc); 448 + ocfs2_hamming_fix_block(data, blocksize, ecc ^ bc_ecc); 448 449 449 450 /* And check the crc32 again */ 450 451 crc = crc32_le(~0, data, blocksize); 451 - if (crc == check.bc_crc32e) { 452 + if (crc == bc_crc32e) { 452 453 ocfs2_blockcheck_inc_recover(stats); 453 454 goto out; 454 455 } 455 456 456 457 mlog(ML_ERROR, "Fixed CRC32 failed: stored: 0x%x, computed 0x%x\n", 457 - (unsigned int)check.bc_crc32e, (unsigned int)crc); 458 + (unsigned int)bc_crc32e, (unsigned int)crc); 458 459 459 460 rc = -EIO; 460 461 461 462 out: 462 - bc->bc_crc32e = cpu_to_le32(check.bc_crc32e); 463 - bc->bc_ecc = cpu_to_le16(check.bc_ecc); 463 + bc->bc_crc32e = cpu_to_le32(bc_crc32e); 464 + bc->bc_ecc = cpu_to_le16(bc_ecc); 464 465 465 466 return rc; 466 467 } ··· 529 528 struct ocfs2_blockcheck_stats *stats) 530 529 { 531 530 int i, rc = 0; 532 - struct ocfs2_block_check check; 531 + u32 bc_crc32e; 532 + u16 bc_ecc; 533 533 u32 crc, ecc, fix; 534 534 535 535 BUG_ON(nr < 0); ··· 540 538 541 539 ocfs2_blockcheck_inc_check(stats); 542 540 543 - check.bc_crc32e = le32_to_cpu(bc->bc_crc32e); 544 - check.bc_ecc = le16_to_cpu(bc->bc_ecc); 541 + bc_crc32e = le32_to_cpu(bc->bc_crc32e); 542 + bc_ecc = le16_to_cpu(bc->bc_ecc); 545 543 546 544 memset(bc, 0, sizeof(struct ocfs2_block_check)); 547 545 548 546 /* Fast path - if the crc32 validates, we're good to go */ 549 547 for (i = 0, crc = ~0; i < nr; i++) 550 548 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); 551 - if (crc == check.bc_crc32e) 549 + if (crc == bc_crc32e) 552 550 goto out; 553 551 554 552 ocfs2_blockcheck_inc_failure(stats); 555 553 mlog(ML_ERROR, 556 554 "CRC32 failed: stored: %u, computed %u. Applying ECC.\n", 557 - (unsigned int)check.bc_crc32e, (unsigned int)crc); 555 + (unsigned int)bc_crc32e, (unsigned int)crc); 558 556 559 557 /* Ok, try ECC fixups */ 560 558 for (i = 0, ecc = 0; i < nr; i++) { ··· 567 565 bhs[i]->b_size * 8, 568 566 bhs[i]->b_size * 8 * i); 569 567 } 570 - fix = ecc ^ check.bc_ecc; 568 + fix = ecc ^ bc_ecc; 571 569 for (i = 0; i < nr; i++) { 572 570 /* 573 571 * Try the fix against each buffer. It will only affect ··· 580 578 /* And check the crc32 again */ 581 579 for (i = 0, crc = ~0; i < nr; i++) 582 580 crc = crc32_le(crc, bhs[i]->b_data, bhs[i]->b_size); 583 - if (crc == check.bc_crc32e) { 581 + if (crc == bc_crc32e) { 584 582 ocfs2_blockcheck_inc_recover(stats); 585 583 goto out; 586 584 } 587 585 588 586 mlog(ML_ERROR, "Fixed CRC32 failed: stored: %u, computed %u\n", 589 - (unsigned int)check.bc_crc32e, (unsigned int)crc); 587 + (unsigned int)bc_crc32e, (unsigned int)crc); 590 588 591 589 rc = -EIO; 592 590 593 591 out: 594 - bc->bc_crc32e = cpu_to_le32(check.bc_crc32e); 595 - bc->bc_ecc = cpu_to_le16(check.bc_ecc); 592 + bc->bc_crc32e = cpu_to_le32(bc_crc32e); 593 + bc->bc_ecc = cpu_to_le16(bc_ecc); 596 594 597 595 return rc; 598 596 }
+1 -1
fs/ocfs2/dlm/dlmast.c
··· 293 293 struct dlm_proxy_ast *past = (struct dlm_proxy_ast *) msg->buf; 294 294 char *name; 295 295 struct list_head *iter, *head=NULL; 296 - u64 cookie; 296 + __be64 cookie; 297 297 u32 flags; 298 298 u8 node; 299 299
+3 -3
fs/ocfs2/dlm/dlmcommon.h
··· 679 679 }; 680 680 681 681 union dlm_query_join_response { 682 - u32 intval; 682 + __be32 intval; 683 683 struct dlm_query_join_packet packet; 684 684 }; 685 685 ··· 755 755 struct dlm_node_info { 756 756 u8 ni_nodenum; 757 757 u8 pad1; 758 - u16 ni_ipv4_port; 759 - u32 ni_ipv4_address; 758 + __be16 ni_ipv4_port; 759 + __be32 ni_ipv4_address; 760 760 }; 761 761 762 762 struct dlm_query_nodeinfo {
+1 -1
fs/ocfs2/dlm/dlmdomain.c
··· 818 818 union dlm_query_join_response response; 819 819 820 820 response.packet = *packet; 821 - *wire = cpu_to_be32(response.intval); 821 + *wire = be32_to_cpu(response.intval); 822 822 } 823 823 824 824 static void dlm_query_join_wire_to_packet(u32 wire,
+7 -12
fs/ocfs2/export.c
··· 177 177 return parent; 178 178 } 179 179 180 - static int ocfs2_encode_fh(struct dentry *dentry, u32 *fh_in, int *max_len, 181 - int connectable) 180 + static int ocfs2_encode_fh(struct inode *inode, u32 *fh_in, int *max_len, 181 + struct inode *parent) 182 182 { 183 - struct inode *inode = dentry->d_inode; 184 183 int len = *max_len; 185 184 int type = 1; 186 185 u64 blkno; 187 186 u32 generation; 188 187 __le32 *fh = (__force __le32 *) fh_in; 189 188 189 + #ifdef TRACE_HOOKS_ARE_NOT_BRAINDEAD_IN_YOUR_OPINION 190 + #error "You go ahead and fix that mess, then. Somehow" 190 191 trace_ocfs2_encode_fh_begin(dentry, dentry->d_name.len, 191 192 dentry->d_name.name, 192 193 fh, len, connectable); 194 + #endif 193 195 194 - if (connectable && (len < 6)) { 196 + if (parent && (len < 6)) { 195 197 *max_len = 6; 196 198 type = 255; 197 199 goto bail; ··· 213 211 fh[1] = cpu_to_le32((u32)(blkno & 0xffffffff)); 214 212 fh[2] = cpu_to_le32(generation); 215 213 216 - if (connectable && !S_ISDIR(inode->i_mode)) { 217 - struct inode *parent; 218 - 219 - spin_lock(&dentry->d_lock); 220 - 221 - parent = dentry->d_parent->d_inode; 214 + if (parent) { 222 215 blkno = OCFS2_I(parent)->ip_blkno; 223 216 generation = parent->i_generation; 224 217 225 218 fh[3] = cpu_to_le32((u32)(blkno >> 32)); 226 219 fh[4] = cpu_to_le32((u32)(blkno & 0xffffffff)); 227 220 fh[5] = cpu_to_le32(generation); 228 - 229 - spin_unlock(&dentry->d_lock); 230 221 231 222 len = 6; 232 223 type = 2;
+6 -7
fs/ocfs2/inode.c
··· 273 273 inode->i_gid = le32_to_cpu(fe->i_gid); 274 274 275 275 /* Fast symlinks will have i_size but no allocated clusters. */ 276 - if (S_ISLNK(inode->i_mode) && !fe->i_clusters) 276 + if (S_ISLNK(inode->i_mode) && !fe->i_clusters) { 277 277 inode->i_blocks = 0; 278 - else 278 + inode->i_mapping->a_ops = &ocfs2_fast_symlink_aops; 279 + } else { 279 280 inode->i_blocks = ocfs2_inode_sector_count(inode); 280 - inode->i_mapping->a_ops = &ocfs2_aops; 281 + inode->i_mapping->a_ops = &ocfs2_aops; 282 + } 281 283 inode->i_atime.tv_sec = le64_to_cpu(fe->i_atime); 282 284 inode->i_atime.tv_nsec = le32_to_cpu(fe->i_atime_nsec); 283 285 inode->i_mtime.tv_sec = le64_to_cpu(fe->i_mtime); ··· 333 331 OCFS2_I(inode)->ip_dir_lock_gen = 1; 334 332 break; 335 333 case S_IFLNK: 336 - if (ocfs2_inode_is_fast_symlink(inode)) 337 - inode->i_op = &ocfs2_fast_symlink_inode_operations; 338 - else 339 - inode->i_op = &ocfs2_symlink_inode_operations; 334 + inode->i_op = &ocfs2_symlink_inode_operations; 340 335 i_size_write(inode, le64_to_cpu(fe->i_size)); 341 336 break; 342 337 default:
+14 -17
fs/ocfs2/ioctl.c
··· 864 864 if (status) 865 865 break; 866 866 867 - reqp = (struct ocfs2_info_request *)(unsigned long)req_addr; 867 + reqp = (struct ocfs2_info_request __user *)(unsigned long)req_addr; 868 868 if (!reqp) { 869 869 status = -EINVAL; 870 870 goto bail; ··· 888 888 struct ocfs2_space_resv sr; 889 889 struct ocfs2_new_group_input input; 890 890 struct reflink_arguments args; 891 - const char *old_path, *new_path; 891 + const char __user *old_path; 892 + const char __user *new_path; 892 893 bool preserve; 893 894 struct ocfs2_info info; 895 + void __user *argp = (void __user *)arg; 894 896 895 897 switch (cmd) { 896 898 case OCFS2_IOC_GETFLAGS: ··· 939 937 940 938 return ocfs2_group_add(inode, &input); 941 939 case OCFS2_IOC_REFLINK: 942 - if (copy_from_user(&args, (struct reflink_arguments *)arg, 943 - sizeof(args))) 940 + if (copy_from_user(&args, argp, sizeof(args))) 944 941 return -EFAULT; 945 - old_path = (const char *)(unsigned long)args.old_path; 946 - new_path = (const char *)(unsigned long)args.new_path; 942 + old_path = (const char __user *)(unsigned long)args.old_path; 943 + new_path = (const char __user *)(unsigned long)args.new_path; 947 944 preserve = (args.preserve != 0); 948 945 949 946 return ocfs2_reflink_ioctl(inode, old_path, new_path, preserve); 950 947 case OCFS2_IOC_INFO: 951 - if (copy_from_user(&info, (struct ocfs2_info __user *)arg, 952 - sizeof(struct ocfs2_info))) 948 + if (copy_from_user(&info, argp, sizeof(struct ocfs2_info))) 953 949 return -EFAULT; 954 950 955 951 return ocfs2_info_handle(inode, &info, 0); ··· 960 960 if (!capable(CAP_SYS_ADMIN)) 961 961 return -EPERM; 962 962 963 - if (copy_from_user(&range, (struct fstrim_range *)arg, 964 - sizeof(range))) 963 + if (copy_from_user(&range, argp, sizeof(range))) 965 964 return -EFAULT; 966 965 967 966 ret = ocfs2_trim_fs(sb, &range); 968 967 if (ret < 0) 969 968 return ret; 970 969 971 - if (copy_to_user((struct fstrim_range *)arg, &range, 972 - sizeof(range))) 970 + if (copy_to_user(argp, &range, sizeof(range))) 973 971 return -EFAULT; 974 972 975 973 return 0; 976 974 } 977 975 case OCFS2_IOC_MOVE_EXT: 978 - return ocfs2_ioctl_move_extents(filp, (void __user *)arg); 976 + return ocfs2_ioctl_move_extents(filp, argp); 979 977 default: 980 978 return -ENOTTY; 981 979 } ··· 986 988 struct reflink_arguments args; 987 989 struct inode *inode = file->f_path.dentry->d_inode; 988 990 struct ocfs2_info info; 991 + void __user *argp = (void __user *)arg; 989 992 990 993 switch (cmd) { 991 994 case OCFS2_IOC32_GETFLAGS: ··· 1005 1006 case FITRIM: 1006 1007 break; 1007 1008 case OCFS2_IOC_REFLINK: 1008 - if (copy_from_user(&args, (struct reflink_arguments *)arg, 1009 - sizeof(args))) 1009 + if (copy_from_user(&args, argp, sizeof(args))) 1010 1010 return -EFAULT; 1011 1011 preserve = (args.preserve != 0); 1012 1012 1013 1013 return ocfs2_reflink_ioctl(inode, compat_ptr(args.old_path), 1014 1014 compat_ptr(args.new_path), preserve); 1015 1015 case OCFS2_IOC_INFO: 1016 - if (copy_from_user(&info, (struct ocfs2_info __user *)arg, 1017 - sizeof(struct ocfs2_info))) 1016 + if (copy_from_user(&info, argp, sizeof(struct ocfs2_info))) 1018 1017 return -EFAULT; 1019 1018 1020 1019 return ocfs2_info_handle(inode, &info, 1);
+2 -4
fs/ocfs2/move_extents.c
··· 1082 1082 context->file = filp; 1083 1083 1084 1084 if (argp) { 1085 - if (copy_from_user(&range, (struct ocfs2_move_extents *)argp, 1086 - sizeof(range))) { 1085 + if (copy_from_user(&range, argp, sizeof(range))) { 1087 1086 status = -EFAULT; 1088 1087 goto out; 1089 1088 } ··· 1137 1138 * length and new_offset even if failure happens somewhere. 1138 1139 */ 1139 1140 if (argp) { 1140 - if (copy_to_user((struct ocfs2_move_extents *)argp, &range, 1141 - sizeof(range))) 1141 + if (copy_to_user(argp, &range, sizeof(range))) 1142 1142 status = -EFAULT; 1143 1143 } 1144 1144
+3 -2
fs/ocfs2/namei.c
··· 1724 1724 fe = (struct ocfs2_dinode *) new_fe_bh->b_data; 1725 1725 inode->i_rdev = 0; 1726 1726 newsize = l - 1; 1727 + inode->i_op = &ocfs2_symlink_inode_operations; 1727 1728 if (l > ocfs2_fast_symlink_chars(sb)) { 1728 1729 u32 offset = 0; 1729 1730 1730 - inode->i_op = &ocfs2_symlink_inode_operations; 1731 1731 status = dquot_alloc_space_nodirty(inode, 1732 1732 ocfs2_clusters_to_bytes(osb->sb, 1)); 1733 1733 if (status) 1734 1734 goto bail; 1735 1735 did_quota = 1; 1736 + inode->i_mapping->a_ops = &ocfs2_aops; 1736 1737 status = ocfs2_add_inode_data(osb, inode, &offset, 1, 0, 1737 1738 new_fe_bh, 1738 1739 handle, data_ac, NULL, ··· 1751 1750 i_size_write(inode, newsize); 1752 1751 inode->i_blocks = ocfs2_inode_sector_count(inode); 1753 1752 } else { 1754 - inode->i_op = &ocfs2_fast_symlink_inode_operations; 1753 + inode->i_mapping->a_ops = &ocfs2_fast_symlink_aops; 1755 1754 memcpy((char *) fe->id2.i_symlink, symname, l); 1756 1755 i_size_write(inode, newsize); 1757 1756 inode->i_blocks = 0;
+21 -94
fs/ocfs2/symlink.c
··· 54 54 #include "buffer_head_io.h" 55 55 56 56 57 - static char *ocfs2_fast_symlink_getlink(struct inode *inode, 58 - struct buffer_head **bh) 57 + static int ocfs2_fast_symlink_readpage(struct file *unused, struct page *page) 59 58 { 60 - int status; 61 - char *link = NULL; 59 + struct inode *inode = page->mapping->host; 60 + struct buffer_head *bh; 61 + int status = ocfs2_read_inode_block(inode, &bh); 62 62 struct ocfs2_dinode *fe; 63 + const char *link; 64 + void *kaddr; 65 + size_t len; 63 66 64 - status = ocfs2_read_inode_block(inode, bh); 65 67 if (status < 0) { 66 68 mlog_errno(status); 67 - link = ERR_PTR(status); 68 - goto bail; 69 + return status; 69 70 } 70 71 71 - fe = (struct ocfs2_dinode *) (*bh)->b_data; 72 + fe = (struct ocfs2_dinode *) bh->b_data; 72 73 link = (char *) fe->id2.i_symlink; 73 - bail: 74 - 75 - return link; 76 - } 77 - 78 - static int ocfs2_readlink(struct dentry *dentry, 79 - char __user *buffer, 80 - int buflen) 81 - { 82 - int ret; 83 - char *link; 84 - struct buffer_head *bh = NULL; 85 - struct inode *inode = dentry->d_inode; 86 - 87 - link = ocfs2_fast_symlink_getlink(inode, &bh); 88 - if (IS_ERR(link)) { 89 - ret = PTR_ERR(link); 90 - goto out; 91 - } 92 - 93 - /* 94 - * Without vfsmount we can't update atime now, 95 - * but we will update atime here ultimately. 96 - */ 97 - ret = vfs_readlink(dentry, buffer, buflen, link); 98 - 74 + /* will be less than a page size */ 75 + len = strnlen(link, ocfs2_fast_symlink_chars(inode->i_sb)); 76 + kaddr = kmap_atomic(page); 77 + memcpy(kaddr, link, len + 1); 78 + kunmap_atomic(kaddr); 79 + SetPageUptodate(page); 80 + unlock_page(page); 99 81 brelse(bh); 100 - out: 101 - if (ret < 0) 102 - mlog_errno(ret); 103 - return ret; 82 + return 0; 104 83 } 105 84 106 - static void *ocfs2_fast_follow_link(struct dentry *dentry, 107 - struct nameidata *nd) 108 - { 109 - int status = 0; 110 - int len; 111 - char *target, *link = ERR_PTR(-ENOMEM); 112 - struct inode *inode = dentry->d_inode; 113 - struct buffer_head *bh = NULL; 114 - 115 - BUG_ON(!ocfs2_inode_is_fast_symlink(inode)); 116 - target = ocfs2_fast_symlink_getlink(inode, &bh); 117 - if (IS_ERR(target)) { 118 - status = PTR_ERR(target); 119 - mlog_errno(status); 120 - goto bail; 121 - } 122 - 123 - /* Fast symlinks can't be large */ 124 - len = strnlen(target, ocfs2_fast_symlink_chars(inode->i_sb)); 125 - link = kzalloc(len + 1, GFP_NOFS); 126 - if (!link) { 127 - status = -ENOMEM; 128 - mlog_errno(status); 129 - goto bail; 130 - } 131 - 132 - memcpy(link, target, len); 133 - 134 - bail: 135 - nd_set_link(nd, status ? ERR_PTR(status) : link); 136 - brelse(bh); 137 - 138 - if (status) 139 - mlog_errno(status); 140 - return NULL; 141 - } 142 - 143 - static void ocfs2_fast_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie) 144 - { 145 - char *link = nd_get_link(nd); 146 - if (!IS_ERR(link)) 147 - kfree(link); 148 - } 85 + const struct address_space_operations ocfs2_fast_symlink_aops = { 86 + .readpage = ocfs2_fast_symlink_readpage, 87 + }; 149 88 150 89 const struct inode_operations ocfs2_symlink_inode_operations = { 151 - .readlink = page_readlink, 90 + .readlink = generic_readlink, 152 91 .follow_link = page_follow_link_light, 153 92 .put_link = page_put_link, 154 - .getattr = ocfs2_getattr, 155 - .setattr = ocfs2_setattr, 156 - .setxattr = generic_setxattr, 157 - .getxattr = generic_getxattr, 158 - .listxattr = ocfs2_listxattr, 159 - .removexattr = generic_removexattr, 160 - .fiemap = ocfs2_fiemap, 161 - }; 162 - const struct inode_operations ocfs2_fast_symlink_inode_operations = { 163 - .readlink = ocfs2_readlink, 164 - .follow_link = ocfs2_fast_follow_link, 165 - .put_link = ocfs2_fast_put_link, 166 93 .getattr = ocfs2_getattr, 167 94 .setattr = ocfs2_setattr, 168 95 .setxattr = generic_setxattr,
+1 -1
fs/ocfs2/symlink.h
··· 27 27 #define OCFS2_SYMLINK_H 28 28 29 29 extern const struct inode_operations ocfs2_symlink_inode_operations; 30 - extern const struct inode_operations ocfs2_fast_symlink_inode_operations; 30 + extern const struct address_space_operations ocfs2_fast_symlink_aops; 31 31 32 32 /* 33 33 * Test whether an inode is a fast symlink.
+57 -19
fs/open.c
··· 654 654 return error; 655 655 } 656 656 657 - static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, 658 - struct file *f, 659 - int (*open)(struct inode *, struct file *), 660 - const struct cred *cred) 657 + int open_check_o_direct(struct file *f) 658 + { 659 + /* NB: we're sure to have correct a_ops only after f_op->open */ 660 + if (f->f_flags & O_DIRECT) { 661 + if (!f->f_mapping->a_ops || 662 + ((!f->f_mapping->a_ops->direct_IO) && 663 + (!f->f_mapping->a_ops->get_xip_mem))) { 664 + return -EINVAL; 665 + } 666 + } 667 + return 0; 668 + } 669 + 670 + static struct file *do_dentry_open(struct dentry *dentry, struct vfsmount *mnt, 671 + struct file *f, 672 + int (*open)(struct inode *, struct file *), 673 + const struct cred *cred) 661 674 { 662 675 static const struct file_operations empty_fops = {}; 663 676 struct inode *inode; ··· 726 713 727 714 file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping); 728 715 729 - /* NB: we're sure to have correct a_ops only after f_op->open */ 730 - if (f->f_flags & O_DIRECT) { 731 - if (!f->f_mapping->a_ops || 732 - ((!f->f_mapping->a_ops->direct_IO) && 733 - (!f->f_mapping->a_ops->get_xip_mem))) { 734 - fput(f); 735 - f = ERR_PTR(-EINVAL); 736 - } 737 - } 738 - 739 716 return f; 740 717 741 718 cleanup_all: ··· 747 744 f->f_path.dentry = NULL; 748 745 f->f_path.mnt = NULL; 749 746 cleanup_file: 750 - put_filp(f); 751 747 dput(dentry); 752 748 mntput(mnt); 753 749 return ERR_PTR(error); 750 + } 751 + 752 + static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, 753 + struct file *f, 754 + int (*open)(struct inode *, struct file *), 755 + const struct cred *cred) 756 + { 757 + struct file *res = do_dentry_open(dentry, mnt, f, open, cred); 758 + if (!IS_ERR(res)) { 759 + int error = open_check_o_direct(f); 760 + if (error) { 761 + fput(res); 762 + res = ERR_PTR(error); 763 + } 764 + } else { 765 + put_filp(f); 766 + } 767 + return res; 754 768 } 755 769 756 770 /** ··· 824 804 825 805 /* Pick up the filp from the open intent */ 826 806 filp = nd->intent.open.file; 827 - nd->intent.open.file = NULL; 828 807 829 808 /* Has the filesystem initialised the file for us? */ 830 - if (filp->f_path.dentry == NULL) { 809 + if (filp->f_path.dentry != NULL) { 810 + nd->intent.open.file = NULL; 811 + } else { 812 + struct file *res; 813 + 831 814 path_get(&nd->path); 832 - filp = __dentry_open(nd->path.dentry, nd->path.mnt, filp, 833 - NULL, cred); 815 + res = do_dentry_open(nd->path.dentry, nd->path.mnt, 816 + filp, NULL, cred); 817 + if (!IS_ERR(res)) { 818 + int error; 819 + 820 + nd->intent.open.file = NULL; 821 + BUG_ON(res != filp); 822 + 823 + error = open_check_o_direct(filp); 824 + if (error) { 825 + fput(filp); 826 + filp = ERR_PTR(error); 827 + } 828 + } else { 829 + /* Allow nd->intent.open.file to be recycled */ 830 + filp = res; 831 + } 834 832 } 835 833 return filp; 836 834 }
+5 -2
fs/pipe.c
··· 654 654 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLRDNORM); 655 655 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN); 656 656 } 657 - if (ret > 0) 658 - file_update_time(filp); 657 + if (ret > 0) { 658 + int err = file_update_time(filp); 659 + if (err) 660 + ret = err; 661 + } 659 662 return ret; 660 663 } 661 664
+2 -2
fs/pnode.c
··· 257 257 prev_src_mnt = child; 258 258 } 259 259 out: 260 - br_write_lock(vfsmount_lock); 260 + br_write_lock(&vfsmount_lock); 261 261 while (!list_empty(&tmp_list)) { 262 262 child = list_first_entry(&tmp_list, struct mount, mnt_hash); 263 263 umount_tree(child, 0, &umount_list); 264 264 } 265 - br_write_unlock(vfsmount_lock); 265 + br_write_unlock(&vfsmount_lock); 266 266 release_mounts(&umount_list); 267 267 return ret; 268 268 }
+2 -2
fs/proc_namespace.c
··· 23 23 24 24 poll_wait(file, &p->ns->poll, wait); 25 25 26 - br_read_lock(vfsmount_lock); 26 + br_read_lock(&vfsmount_lock); 27 27 if (p->m.poll_event != ns->event) { 28 28 p->m.poll_event = ns->event; 29 29 res |= POLLERR | POLLPRI; 30 30 } 31 - br_read_unlock(vfsmount_lock); 31 + br_read_unlock(&vfsmount_lock); 32 32 33 33 return res; 34 34 }
+14 -19
fs/readdir.c
··· 108 108 int error; 109 109 struct file * file; 110 110 struct readdir_callback buf; 111 + int fput_needed; 111 112 112 - error = -EBADF; 113 - file = fget(fd); 113 + file = fget_light(fd, &fput_needed); 114 114 if (!file) 115 - goto out; 115 + return -EBADF; 116 116 117 117 buf.result = 0; 118 118 buf.dirent = dirent; ··· 121 121 if (buf.result) 122 122 error = buf.result; 123 123 124 - fput(file); 125 - out: 124 + fput_light(file, fput_needed); 126 125 return error; 127 126 } 128 127 ··· 194 195 struct file * file; 195 196 struct linux_dirent __user * lastdirent; 196 197 struct getdents_callback buf; 198 + int fput_needed; 197 199 int error; 198 200 199 - error = -EFAULT; 200 201 if (!access_ok(VERIFY_WRITE, dirent, count)) 201 - goto out; 202 + return -EFAULT; 202 203 203 - error = -EBADF; 204 - file = fget(fd); 204 + file = fget_light(fd, &fput_needed); 205 205 if (!file) 206 - goto out; 206 + return -EBADF; 207 207 208 208 buf.current_dir = dirent; 209 209 buf.previous = NULL; ··· 219 221 else 220 222 error = count - buf.count; 221 223 } 222 - fput(file); 223 - out: 224 + fput_light(file, fput_needed); 224 225 return error; 225 226 } 226 227 ··· 275 278 struct file * file; 276 279 struct linux_dirent64 __user * lastdirent; 277 280 struct getdents_callback64 buf; 281 + int fput_needed; 278 282 int error; 279 283 280 - error = -EFAULT; 281 284 if (!access_ok(VERIFY_WRITE, dirent, count)) 282 - goto out; 285 + return -EFAULT; 283 286 284 - error = -EBADF; 285 - file = fget(fd); 287 + file = fget_light(fd, &fput_needed); 286 288 if (!file) 287 - goto out; 289 + return -EBADF; 288 290 289 291 buf.current_dir = dirent; 290 292 buf.previous = NULL; ··· 301 305 else 302 306 error = count - buf.count; 303 307 } 304 - fput(file); 305 - out: 308 + fput_light(file, fput_needed); 306 309 return error; 307 310 }
+11 -17
fs/reiserfs/inode.c
··· 1592 1592 (fh_type == 6) ? fid->raw[5] : 0); 1593 1593 } 1594 1594 1595 - int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp, 1596 - int need_parent) 1595 + int reiserfs_encode_fh(struct inode *inode, __u32 * data, int *lenp, 1596 + struct inode *parent) 1597 1597 { 1598 - struct inode *inode = dentry->d_inode; 1599 1598 int maxlen = *lenp; 1600 1599 1601 - if (need_parent && (maxlen < 5)) { 1600 + if (parent && (maxlen < 5)) { 1602 1601 *lenp = 5; 1603 1602 return 255; 1604 1603 } else if (maxlen < 3) { ··· 1609 1610 data[1] = le32_to_cpu(INODE_PKEY(inode)->k_dir_id); 1610 1611 data[2] = inode->i_generation; 1611 1612 *lenp = 3; 1612 - /* no room for directory info? return what we've stored so far */ 1613 - if (maxlen < 5 || !need_parent) 1614 - return 3; 1615 - 1616 - spin_lock(&dentry->d_lock); 1617 - inode = dentry->d_parent->d_inode; 1618 - data[3] = inode->i_ino; 1619 - data[4] = le32_to_cpu(INODE_PKEY(inode)->k_dir_id); 1620 - *lenp = 5; 1621 - if (maxlen >= 6) { 1622 - data[5] = inode->i_generation; 1623 - *lenp = 6; 1613 + if (parent) { 1614 + data[3] = parent->i_ino; 1615 + data[4] = le32_to_cpu(INODE_PKEY(parent)->k_dir_id); 1616 + *lenp = 5; 1617 + if (maxlen >= 6) { 1618 + data[5] = parent->i_generation; 1619 + *lenp = 6; 1620 + } 1624 1621 } 1625 - spin_unlock(&dentry->d_lock); 1626 1622 return *lenp; 1627 1623 } 1628 1624
+7 -8
fs/reiserfs/journal.c
··· 1923 1923 * the workqueue job (flush_async_commit) needs this lock 1924 1924 */ 1925 1925 reiserfs_write_unlock(sb); 1926 + 1927 + cancel_delayed_work_sync(&REISERFS_SB(sb)->old_work); 1926 1928 flush_workqueue(commit_wq); 1927 1929 1928 1930 if (!reiserfs_mounted_fs_count) { ··· 3233 3231 th->t_trans_id, journal->j_trans_id); 3234 3232 } 3235 3233 3236 - sb->s_dirt = 1; 3237 - 3238 3234 prepared = test_clear_buffer_journal_prepared(bh); 3239 3235 clear_buffer_journal_restore_dirty(bh); 3240 3236 /* already in this transaction, we are done */ ··· 3316 3316 journal->j_first = cn; 3317 3317 journal->j_last = cn; 3318 3318 } 3319 + reiserfs_schedule_old_flush(sb); 3319 3320 return 0; 3320 3321 } 3321 3322 ··· 3493 3492 ** flushes any old transactions to disk 3494 3493 ** ends the current transaction if it is too old 3495 3494 */ 3496 - int reiserfs_flush_old_commits(struct super_block *sb) 3495 + void reiserfs_flush_old_commits(struct super_block *sb) 3497 3496 { 3498 3497 time_t now; 3499 3498 struct reiserfs_transaction_handle th; ··· 3503 3502 /* safety check so we don't flush while we are replaying the log during 3504 3503 * mount 3505 3504 */ 3506 - if (list_empty(&journal->j_journal_list)) { 3507 - return 0; 3508 - } 3505 + if (list_empty(&journal->j_journal_list)) 3506 + return; 3509 3507 3510 3508 /* check the current transaction. If there are no writers, and it is 3511 3509 * too old, finish it, and force the commit blocks to disk ··· 3526 3526 do_journal_end(&th, sb, 1, COMMIT_NOW | WAIT); 3527 3527 } 3528 3528 } 3529 - return sb->s_dirt; 3530 3529 } 3531 3530 3532 3531 /* ··· 3954 3955 ** it tells us if we should continue with the journal_end, or just return 3955 3956 */ 3956 3957 if (!check_journal_end(th, sb, nblocks, flags)) { 3957 - sb->s_dirt = 1; 3958 + reiserfs_schedule_old_flush(sb); 3958 3959 wake_queued_writers(sb); 3959 3960 reiserfs_async_progress_wait(sb); 3960 3961 goto out;
+9 -3
fs/reiserfs/reiserfs.h
··· 480 480 struct dentry *priv_root; /* root of /.reiserfs_priv */ 481 481 struct dentry *xattr_root; /* root of /.reiserfs_priv/xattrs */ 482 482 int j_errno; 483 + 484 + int work_queued; /* non-zero delayed work is queued */ 485 + struct delayed_work old_work; /* old transactions flush delayed work */ 486 + spinlock_t old_work_lock; /* protects old_work and work_queued */ 487 + 483 488 #ifdef CONFIG_QUOTA 484 489 char *s_qf_names[MAXQUOTAS]; 485 490 int s_jquota_fmt; ··· 2457 2452 int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *); 2458 2453 int reiserfs_commit_page(struct inode *inode, struct page *page, 2459 2454 unsigned from, unsigned to); 2460 - int reiserfs_flush_old_commits(struct super_block *); 2455 + void reiserfs_flush_old_commits(struct super_block *); 2461 2456 int reiserfs_commit_for_inode(struct inode *); 2462 2457 int reiserfs_inode_needs_commit(struct inode *); 2463 2458 void reiserfs_update_inode_transaction(struct inode *); ··· 2492 2487 int reiserfs_allocate_list_bitmaps(struct super_block *s, 2493 2488 struct reiserfs_list_bitmap *, unsigned int); 2494 2489 2490 + void reiserfs_schedule_old_flush(struct super_block *s); 2495 2491 void add_save_link(struct reiserfs_transaction_handle *th, 2496 2492 struct inode *inode, int truncate); 2497 2493 int remove_save_link(struct inode *inode, int truncate); ··· 2617 2611 int fh_len, int fh_type); 2618 2612 struct dentry *reiserfs_fh_to_parent(struct super_block *sb, struct fid *fid, 2619 2613 int fh_len, int fh_type); 2620 - int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp, 2621 - int connectable); 2614 + int reiserfs_encode_fh(struct inode *inode, __u32 * data, int *lenp, 2615 + struct inode *parent); 2622 2616 2623 2617 int reiserfs_truncate_file(struct inode *, int update_timestamps); 2624 2618 void make_cpu_key(struct cpu_key *cpu_key, struct inode *inode, loff_t offset,
-1
fs/reiserfs/resize.c
··· 200 200 (bmap_nr_new - bmap_nr))); 201 201 PUT_SB_BLOCK_COUNT(s, block_count_new); 202 202 PUT_SB_BMAP_NR(s, bmap_would_wrap(bmap_nr_new) ? : bmap_nr_new); 203 - s->s_dirt = 1; 204 203 205 204 journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB(s)); 206 205
+55 -19
fs/reiserfs/super.c
··· 72 72 if (!journal_begin(&th, s, 1)) 73 73 if (!journal_end_sync(&th, s, 1)) 74 74 reiserfs_flush_old_commits(s); 75 - s->s_dirt = 0; /* Even if it's not true. 76 - * We'll loop forever in sync_supers otherwise */ 77 75 reiserfs_write_unlock(s); 78 76 return 0; 79 77 } 80 78 81 - static void reiserfs_write_super(struct super_block *s) 79 + static void flush_old_commits(struct work_struct *work) 82 80 { 81 + struct reiserfs_sb_info *sbi; 82 + struct super_block *s; 83 + 84 + sbi = container_of(work, struct reiserfs_sb_info, old_work.work); 85 + s = sbi->s_journal->j_work_sb; 86 + 87 + spin_lock(&sbi->old_work_lock); 88 + sbi->work_queued = 0; 89 + spin_unlock(&sbi->old_work_lock); 90 + 83 91 reiserfs_sync_fs(s, 1); 92 + } 93 + 94 + void reiserfs_schedule_old_flush(struct super_block *s) 95 + { 96 + struct reiserfs_sb_info *sbi = REISERFS_SB(s); 97 + unsigned long delay; 98 + 99 + if (s->s_flags & MS_RDONLY) 100 + return; 101 + 102 + spin_lock(&sbi->old_work_lock); 103 + if (!sbi->work_queued) { 104 + delay = msecs_to_jiffies(dirty_writeback_interval * 10); 105 + queue_delayed_work(system_long_wq, &sbi->old_work, delay); 106 + sbi->work_queued = 1; 107 + } 108 + spin_unlock(&sbi->old_work_lock); 109 + } 110 + 111 + static void cancel_old_flush(struct super_block *s) 112 + { 113 + struct reiserfs_sb_info *sbi = REISERFS_SB(s); 114 + 115 + cancel_delayed_work_sync(&REISERFS_SB(s)->old_work); 116 + spin_lock(&sbi->old_work_lock); 117 + sbi->work_queued = 0; 118 + spin_unlock(&sbi->old_work_lock); 84 119 } 85 120 86 121 static int reiserfs_freeze(struct super_block *s) 87 122 { 88 123 struct reiserfs_transaction_handle th; 124 + 125 + cancel_old_flush(s); 126 + 89 127 reiserfs_write_lock(s); 90 128 if (!(s->s_flags & MS_RDONLY)) { 91 129 int err = journal_begin(&th, s, 1); ··· 137 99 journal_end_sync(&th, s, 1); 138 100 } 139 101 } 140 - s->s_dirt = 0; 141 102 reiserfs_write_unlock(s); 142 103 return 0; 143 104 } ··· 520 483 521 484 reiserfs_write_lock(s); 522 485 523 - if (s->s_dirt) 524 - reiserfs_write_super(s); 525 - 526 486 /* change file system state to current state if it was mounted with read-write permissions */ 527 487 if (!(s->s_flags & MS_RDONLY)) { 528 488 if (!journal_begin(&th, s, 10)) { ··· 726 692 .dirty_inode = reiserfs_dirty_inode, 727 693 .evict_inode = reiserfs_evict_inode, 728 694 .put_super = reiserfs_put_super, 729 - .write_super = reiserfs_write_super, 730 695 .sync_fs = reiserfs_sync_fs, 731 696 .freeze_fs = reiserfs_freeze, 732 697 .unfreeze_fs = reiserfs_unfreeze, ··· 1433 1400 err = journal_end(&th, s, 10); 1434 1401 if (err) 1435 1402 goto out_err; 1436 - s->s_dirt = 0; 1437 1403 1438 1404 if (!(*mount_flags & MS_RDONLY)) { 1439 1405 dquot_resume(s, -1); ··· 1762 1730 return -ENOMEM; 1763 1731 s->s_fs_info = sbi; 1764 1732 /* Set default values for options: non-aggressive tails, RO on errors */ 1765 - REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_SMALLTAIL); 1766 - REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_ERROR_RO); 1767 - REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_BARRIER_FLUSH); 1733 + sbi->s_mount_opt |= (1 << REISERFS_SMALLTAIL); 1734 + sbi->s_mount_opt |= (1 << REISERFS_ERROR_RO); 1735 + sbi->s_mount_opt |= (1 << REISERFS_BARRIER_FLUSH); 1768 1736 /* no preallocation minimum, be smart in 1769 1737 reiserfs_file_write instead */ 1770 - REISERFS_SB(s)->s_alloc_options.preallocmin = 0; 1738 + sbi->s_alloc_options.preallocmin = 0; 1771 1739 /* Preallocate by 16 blocks (17-1) at once */ 1772 - REISERFS_SB(s)->s_alloc_options.preallocsize = 17; 1740 + sbi->s_alloc_options.preallocsize = 17; 1773 1741 /* setup default block allocator options */ 1774 1742 reiserfs_init_alloc_options(s); 1775 1743 1776 - mutex_init(&REISERFS_SB(s)->lock); 1777 - REISERFS_SB(s)->lock_depth = -1; 1744 + spin_lock_init(&sbi->old_work_lock); 1745 + INIT_DELAYED_WORK(&sbi->old_work, flush_old_commits); 1746 + mutex_init(&sbi->lock); 1747 + sbi->lock_depth = -1; 1778 1748 1779 1749 jdev_name = NULL; 1780 1750 if (reiserfs_parse_options ··· 1785 1751 goto error_unlocked; 1786 1752 } 1787 1753 if (jdev_name && jdev_name[0]) { 1788 - REISERFS_SB(s)->s_jdev = kstrdup(jdev_name, GFP_KERNEL); 1789 - if (!REISERFS_SB(s)->s_jdev) { 1754 + sbi->s_jdev = kstrdup(jdev_name, GFP_KERNEL); 1755 + if (!sbi->s_jdev) { 1790 1756 SWARN(silent, s, "", "Cannot allocate memory for " 1791 1757 "journal device name"); 1792 1758 goto error; ··· 1844 1810 /* make data=ordered the default */ 1845 1811 if (!reiserfs_data_log(s) && !reiserfs_data_ordered(s) && 1846 1812 !reiserfs_data_writeback(s)) { 1847 - REISERFS_SB(s)->s_mount_opt |= (1 << REISERFS_DATA_ORDERED); 1813 + sbi->s_mount_opt |= (1 << REISERFS_DATA_ORDERED); 1848 1814 } 1849 1815 1850 1816 if (reiserfs_data_log(s)) { ··· 2036 2002 journal_release_error(NULL, s); 2037 2003 reiserfs_write_unlock(s); 2038 2004 } 2005 + 2006 + cancel_delayed_work_sync(&REISERFS_SB(s)->old_work); 2039 2007 2040 2008 reiserfs_free_bitmap_cache(s); 2041 2009 if (SB_BUFFER_WITH_SB(s))
+4 -3
fs/signalfd.c
··· 269 269 if (ufd < 0) 270 270 kfree(ctx); 271 271 } else { 272 - struct file *file = fget(ufd); 272 + int fput_needed; 273 + struct file *file = fget_light(ufd, &fput_needed); 273 274 if (!file) 274 275 return -EBADF; 275 276 ctx = file->private_data; 276 277 if (file->f_op != &signalfd_fops) { 277 - fput(file); 278 + fput_light(file, fput_needed); 278 279 return -EINVAL; 279 280 } 280 281 spin_lock_irq(&current->sighand->siglock); ··· 283 282 spin_unlock_irq(&current->sighand->siglock); 284 283 285 284 wake_up(&current->sighand->signalfd_wqh); 286 - fput(file); 285 + fput_light(file, fput_needed); 287 286 } 288 287 289 288 return ufd;
+4 -2
fs/splice.c
··· 1003 1003 mutex_lock_nested(&inode->i_mutex, I_MUTEX_CHILD); 1004 1004 ret = file_remove_suid(out); 1005 1005 if (!ret) { 1006 - file_update_time(out); 1007 - ret = splice_from_pipe_feed(pipe, &sd, pipe_to_file); 1006 + ret = file_update_time(out); 1007 + if (!ret) 1008 + ret = splice_from_pipe_feed(pipe, &sd, 1009 + pipe_to_file); 1008 1010 } 1009 1011 mutex_unlock(&inode->i_mutex); 1010 1012 } while (ret > 0);
+3 -2
fs/statfs.c
··· 87 87 88 88 int fd_statfs(int fd, struct kstatfs *st) 89 89 { 90 - struct file *file = fget(fd); 90 + int fput_needed; 91 + struct file *file = fget_light(fd, &fput_needed); 91 92 int error = -EBADF; 92 93 if (file) { 93 94 error = vfs_statfs(&file->f_path, st); 94 - fput(file); 95 + fput_light(file, fput_needed); 95 96 } 96 97 return error; 97 98 }
+3 -2
fs/sync.c
··· 188 188 { 189 189 struct file *file; 190 190 int ret = -EBADF; 191 + int fput_needed; 191 192 192 - file = fget(fd); 193 + file = fget_light(fd, &fput_needed); 193 194 if (file) { 194 195 ret = vfs_fsync(file, datasync); 195 - fput(file); 196 + fput_light(file, fput_needed); 196 197 } 197 198 return ret; 198 199 }
+1 -10
fs/ubifs/dir.c
··· 1127 1127 struct ubifs_inode *ui = ubifs_inode(inode); 1128 1128 1129 1129 mutex_lock(&ui->ui_mutex); 1130 - stat->dev = inode->i_sb->s_dev; 1131 - stat->ino = inode->i_ino; 1132 - stat->mode = inode->i_mode; 1133 - stat->nlink = inode->i_nlink; 1134 - stat->uid = inode->i_uid; 1135 - stat->gid = inode->i_gid; 1136 - stat->rdev = inode->i_rdev; 1137 - stat->atime = inode->i_atime; 1138 - stat->mtime = inode->i_mtime; 1139 - stat->ctime = inode->i_ctime; 1130 + generic_fillattr(inode, stat); 1140 1131 stat->blksize = UBIFS_BLOCK_SIZE; 1141 1132 stat->size = ui->ui_size; 1142 1133
+5 -9
fs/udf/namei.c
··· 1260 1260 fid->udf.parent_partref, 1261 1261 fid->udf.parent_generation); 1262 1262 } 1263 - static int udf_encode_fh(struct dentry *de, __u32 *fh, int *lenp, 1264 - int connectable) 1263 + static int udf_encode_fh(struct inode *inode, __u32 *fh, int *lenp, 1264 + struct inode *parent) 1265 1265 { 1266 1266 int len = *lenp; 1267 - struct inode *inode = de->d_inode; 1268 1267 struct kernel_lb_addr location = UDF_I(inode)->i_location; 1269 1268 struct fid *fid = (struct fid *)fh; 1270 1269 int type = FILEID_UDF_WITHOUT_PARENT; 1271 1270 1272 - if (connectable && (len < 5)) { 1271 + if (parent && (len < 5)) { 1273 1272 *lenp = 5; 1274 1273 return 255; 1275 1274 } else if (len < 3) { ··· 1281 1282 fid->udf.partref = location.partitionReferenceNum; 1282 1283 fid->udf.generation = inode->i_generation; 1283 1284 1284 - if (connectable && !S_ISDIR(inode->i_mode)) { 1285 - spin_lock(&de->d_lock); 1286 - inode = de->d_parent->d_inode; 1287 - location = UDF_I(inode)->i_location; 1285 + if (parent) { 1286 + location = UDF_I(parent)->i_location; 1288 1287 fid->udf.parent_block = location.logicalBlockNum; 1289 1288 fid->udf.parent_partref = location.partitionReferenceNum; 1290 1289 fid->udf.parent_generation = inode->i_generation; 1291 - spin_unlock(&de->d_lock); 1292 1290 *lenp = 5; 1293 1291 type = FILEID_UDF_WITH_PARENT; 1294 1292 }
+3 -2
fs/utimes.c
··· 140 140 goto out; 141 141 142 142 if (filename == NULL && dfd != AT_FDCWD) { 143 + int fput_needed; 143 144 struct file *file; 144 145 145 146 if (flags & AT_SYMLINK_NOFOLLOW) 146 147 goto out; 147 148 148 - file = fget(dfd); 149 + file = fget_light(dfd, &fput_needed); 149 150 error = -EBADF; 150 151 if (!file) 151 152 goto out; 152 153 153 154 error = utimes_common(&file->f_path, times); 154 - fput(file); 155 + fput_light(file, fput_needed); 155 156 } else { 156 157 struct path path; 157 158 int lookup_flags = 0;
+12 -8
fs/xattr.c
··· 399 399 SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name, 400 400 const void __user *,value, size_t, size, int, flags) 401 401 { 402 + int fput_needed; 402 403 struct file *f; 403 404 struct dentry *dentry; 404 405 int error = -EBADF; 405 406 406 - f = fget(fd); 407 + f = fget_light(fd, &fput_needed); 407 408 if (!f) 408 409 return error; 409 410 dentry = f->f_path.dentry; ··· 414 413 error = setxattr(dentry, name, value, size, flags); 415 414 mnt_drop_write_file(f); 416 415 } 417 - fput(f); 416 + fput_light(f, fput_needed); 418 417 return error; 419 418 } 420 419 ··· 487 486 SYSCALL_DEFINE4(fgetxattr, int, fd, const char __user *, name, 488 487 void __user *, value, size_t, size) 489 488 { 489 + int fput_needed; 490 490 struct file *f; 491 491 ssize_t error = -EBADF; 492 492 493 - f = fget(fd); 493 + f = fget_light(fd, &fput_needed); 494 494 if (!f) 495 495 return error; 496 496 audit_inode(NULL, f->f_path.dentry); 497 497 error = getxattr(f->f_path.dentry, name, value, size); 498 - fput(f); 498 + fput_light(f, fput_needed); 499 499 return error; 500 500 } 501 501 ··· 568 566 569 567 SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size) 570 568 { 569 + int fput_needed; 571 570 struct file *f; 572 571 ssize_t error = -EBADF; 573 572 574 - f = fget(fd); 573 + f = fget_light(fd, &fput_needed); 575 574 if (!f) 576 575 return error; 577 576 audit_inode(NULL, f->f_path.dentry); 578 577 error = listxattr(f->f_path.dentry, list, size); 579 - fput(f); 578 + fput_light(f, fput_needed); 580 579 return error; 581 580 } 582 581 ··· 637 634 638 635 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name) 639 636 { 637 + int fput_needed; 640 638 struct file *f; 641 639 struct dentry *dentry; 642 640 int error = -EBADF; 643 641 644 - f = fget(fd); 642 + f = fget_light(fd, &fput_needed); 645 643 if (!f) 646 644 return error; 647 645 dentry = f->f_path.dentry; ··· 652 648 error = removexattr(dentry, name); 653 649 mnt_drop_write_file(f); 654 650 } 655 - fput(f); 651 + fput_light(f, fput_needed); 656 652 return error; 657 653 } 658 654
+5 -5
fs/xfs/kmem.c
··· 46 46 } 47 47 48 48 void * 49 - kmem_alloc(size_t size, unsigned int __nocast flags) 49 + kmem_alloc(size_t size, xfs_km_flags_t flags) 50 50 { 51 51 int retries = 0; 52 52 gfp_t lflags = kmem_flags_convert(flags); ··· 65 65 } 66 66 67 67 void * 68 - kmem_zalloc(size_t size, unsigned int __nocast flags) 68 + kmem_zalloc(size_t size, xfs_km_flags_t flags) 69 69 { 70 70 void *ptr; 71 71 ··· 87 87 88 88 void * 89 89 kmem_realloc(const void *ptr, size_t newsize, size_t oldsize, 90 - unsigned int __nocast flags) 90 + xfs_km_flags_t flags) 91 91 { 92 92 void *new; 93 93 ··· 102 102 } 103 103 104 104 void * 105 - kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags) 105 + kmem_zone_alloc(kmem_zone_t *zone, xfs_km_flags_t flags) 106 106 { 107 107 int retries = 0; 108 108 gfp_t lflags = kmem_flags_convert(flags); ··· 121 121 } 122 122 123 123 void * 124 - kmem_zone_zalloc(kmem_zone_t *zone, unsigned int __nocast flags) 124 + kmem_zone_zalloc(kmem_zone_t *zone, xfs_km_flags_t flags) 125 125 { 126 126 void *ptr; 127 127
+11 -10
fs/xfs/kmem.h
··· 27 27 * General memory allocation interfaces 28 28 */ 29 29 30 - #define KM_SLEEP 0x0001u 31 - #define KM_NOSLEEP 0x0002u 32 - #define KM_NOFS 0x0004u 33 - #define KM_MAYFAIL 0x0008u 30 + typedef unsigned __bitwise xfs_km_flags_t; 31 + #define KM_SLEEP ((__force xfs_km_flags_t)0x0001u) 32 + #define KM_NOSLEEP ((__force xfs_km_flags_t)0x0002u) 33 + #define KM_NOFS ((__force xfs_km_flags_t)0x0004u) 34 + #define KM_MAYFAIL ((__force xfs_km_flags_t)0x0008u) 34 35 35 36 /* 36 37 * We use a special process flag to avoid recursive callbacks into ··· 39 38 * warnings, so we explicitly skip any generic ones (silly of us). 40 39 */ 41 40 static inline gfp_t 42 - kmem_flags_convert(unsigned int __nocast flags) 41 + kmem_flags_convert(xfs_km_flags_t flags) 43 42 { 44 43 gfp_t lflags; 45 44 ··· 55 54 return lflags; 56 55 } 57 56 58 - extern void *kmem_alloc(size_t, unsigned int __nocast); 59 - extern void *kmem_zalloc(size_t, unsigned int __nocast); 60 - extern void *kmem_realloc(const void *, size_t, size_t, unsigned int __nocast); 57 + extern void *kmem_alloc(size_t, xfs_km_flags_t); 58 + extern void *kmem_zalloc(size_t, xfs_km_flags_t); 59 + extern void *kmem_realloc(const void *, size_t, size_t, xfs_km_flags_t); 61 60 extern void kmem_free(const void *); 62 61 63 62 static inline void *kmem_zalloc_large(size_t size) ··· 108 107 kmem_cache_destroy(zone); 109 108 } 110 109 111 - extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); 112 - extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); 110 + extern void *kmem_zone_alloc(kmem_zone_t *, xfs_km_flags_t); 111 + extern void *kmem_zone_zalloc(kmem_zone_t *, xfs_km_flags_t); 113 112 114 113 #endif /* __XFS_SUPPORT_KMEM_H__ */
+9 -14
fs/xfs/xfs_export.c
··· 52 52 53 53 STATIC int 54 54 xfs_fs_encode_fh( 55 - struct dentry *dentry, 56 - __u32 *fh, 57 - int *max_len, 58 - int connectable) 55 + struct inode *inode, 56 + __u32 *fh, 57 + int *max_len, 58 + struct inode *parent) 59 59 { 60 60 struct fid *fid = (struct fid *)fh; 61 61 struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fh; 62 - struct inode *inode = dentry->d_inode; 63 62 int fileid_type; 64 63 int len; 65 64 66 65 /* Directories don't need their parent encoded, they have ".." */ 67 - if (S_ISDIR(inode->i_mode) || !connectable) 66 + if (!parent) 68 67 fileid_type = FILEID_INO32_GEN; 69 68 else 70 69 fileid_type = FILEID_INO32_GEN_PARENT; ··· 95 96 96 97 switch (fileid_type) { 97 98 case FILEID_INO32_GEN_PARENT: 98 - spin_lock(&dentry->d_lock); 99 - fid->i32.parent_ino = XFS_I(dentry->d_parent->d_inode)->i_ino; 100 - fid->i32.parent_gen = dentry->d_parent->d_inode->i_generation; 101 - spin_unlock(&dentry->d_lock); 99 + fid->i32.parent_ino = XFS_I(parent)->i_ino; 100 + fid->i32.parent_gen = parent->i_generation; 102 101 /*FALLTHRU*/ 103 102 case FILEID_INO32_GEN: 104 103 fid->i32.ino = XFS_I(inode)->i_ino; 105 104 fid->i32.gen = inode->i_generation; 106 105 break; 107 106 case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: 108 - spin_lock(&dentry->d_lock); 109 - fid64->parent_ino = XFS_I(dentry->d_parent->d_inode)->i_ino; 110 - fid64->parent_gen = dentry->d_parent->d_inode->i_generation; 111 - spin_unlock(&dentry->d_lock); 107 + fid64->parent_ino = XFS_I(parent)->i_ino; 108 + fid64->parent_gen = parent->i_generation; 112 109 /*FALLTHRU*/ 113 110 case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: 114 111 fid64->ino = XFS_I(inode)->i_ino;
+5 -2
fs/xfs/xfs_file.c
··· 586 586 * lock above. Eventually we should look into a way to avoid 587 587 * the pointless lock roundtrip. 588 588 */ 589 - if (likely(!(file->f_mode & FMODE_NOCMTIME))) 590 - file_update_time(file); 589 + if (likely(!(file->f_mode & FMODE_NOCMTIME))) { 590 + error = file_update_time(file); 591 + if (error) 592 + return error; 593 + } 591 594 592 595 /* 593 596 * If we're writing the file then make sure to clear the setuid and
+1 -1
fs/xfs/xfs_log.c
··· 3152 3152 int cnt, 3153 3153 char client, 3154 3154 bool permanent, 3155 - int alloc_flags) 3155 + xfs_km_flags_t alloc_flags) 3156 3156 { 3157 3157 struct xlog_ticket *tic; 3158 3158 uint num_headers;
+1 -1
fs/xfs/xfs_log_priv.h
··· 555 555 extern kmem_zone_t *xfs_log_ticket_zone; 556 556 struct xlog_ticket *xlog_ticket_alloc(struct log *log, int unit_bytes, 557 557 int count, char client, bool permanent, 558 - int alloc_flags); 558 + xfs_km_flags_t alloc_flags); 559 559 560 560 561 561 static inline void
+1 -1
fs/xfs/xfs_trans.c
··· 584 584 _xfs_trans_alloc( 585 585 xfs_mount_t *mp, 586 586 uint type, 587 - uint memflags) 587 + xfs_km_flags_t memflags) 588 588 { 589 589 xfs_trans_t *tp; 590 590
+1 -1
fs/xfs/xfs_trans.h
··· 443 443 * XFS transaction mechanism exported interfaces. 444 444 */ 445 445 xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint); 446 - xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint, uint); 446 + xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint, xfs_km_flags_t); 447 447 xfs_trans_t *xfs_trans_dup(xfs_trans_t *); 448 448 int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, 449 449 uint, uint);
-4
include/asm-generic/posix_types.h
··· 23 23 typedef unsigned int __kernel_mode_t; 24 24 #endif 25 25 26 - #ifndef __kernel_nlink_t 27 - typedef __kernel_ulong_t __kernel_nlink_t; 28 - #endif 29 - 30 26 #ifndef __kernel_pid_t 31 27 typedef int __kernel_pid_t; 32 28 #endif
+1
include/linux/errno.h
··· 17 17 #define ENOIOCTLCMD 515 /* No ioctl command */ 18 18 #define ERESTART_RESTARTBLOCK 516 /* restart by calling sys_restart_syscall */ 19 19 #define EPROBE_DEFER 517 /* Driver requests probe retry */ 20 + #define EOPENSTALE 518 /* open found a stale dentry */ 20 21 21 22 /* Defined for the NFSv3 protocol */ 22 23 #define EBADHANDLE 521 /* Illegal NFS file handle */
+2 -2
include/linux/exportfs.h
··· 165 165 */ 166 166 167 167 struct export_operations { 168 - int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, 169 - int connectable); 168 + int (*encode_fh)(struct inode *inode, __u32 *fh, int *max_len, 169 + struct inode *parent); 170 170 struct dentry * (*fh_to_dentry)(struct super_block *sb, struct fid *fid, 171 171 int fh_len, int fh_type); 172 172 struct dentry * (*fh_to_parent)(struct super_block *sb, struct fid *fid,
+9 -1
include/linux/fs.h
··· 1692 1692 int (*removexattr) (struct dentry *, const char *); 1693 1693 int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, 1694 1694 u64 len); 1695 + int (*update_time)(struct inode *, struct timespec *, int); 1695 1696 } ____cacheline_aligned; 1696 1697 1697 1698 struct seq_file; ··· 1850 1849 inode->i_version++; 1851 1850 spin_unlock(&inode->i_lock); 1852 1851 } 1852 + 1853 + enum file_time_flags { 1854 + S_ATIME = 1, 1855 + S_MTIME = 2, 1856 + S_CTIME = 4, 1857 + S_VERSION = 8, 1858 + }; 1853 1859 1854 1860 extern void touch_atime(struct path *); 1855 1861 static inline void file_accessed(struct file *file) ··· 2591 2583 extern int inode_newsize_ok(const struct inode *, loff_t offset); 2592 2584 extern void setattr_copy(struct inode *inode, const struct iattr *attr); 2593 2585 2594 - extern void file_update_time(struct file *file); 2586 + extern int file_update_time(struct file *file); 2595 2587 2596 2588 extern int generic_show_options(struct seq_file *m, struct dentry *root); 2597 2589 extern void save_mount_options(struct super_block *sb, char *options);
+1 -1
include/linux/fsnotify_backend.h
··· 60 60 #define FS_EVENTS_POSS_ON_CHILD (FS_ACCESS | FS_MODIFY | FS_ATTRIB |\ 61 61 FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN |\ 62 62 FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE |\ 63 - FS_DELETE) 63 + FS_DELETE | FS_OPEN_PERM | FS_ACCESS_PERM) 64 64 65 65 #define FS_MOVE (FS_MOVED_FROM | FS_MOVED_TO) 66 66
+26 -153
include/linux/lglock.h
··· 23 23 #include <linux/lockdep.h> 24 24 #include <linux/percpu.h> 25 25 #include <linux/cpu.h> 26 + #include <linux/notifier.h> 26 27 27 28 /* can make br locks by using local lock for read side, global lock for write */ 28 - #define br_lock_init(name) name##_lock_init() 29 - #define br_read_lock(name) name##_local_lock() 30 - #define br_read_unlock(name) name##_local_unlock() 31 - #define br_write_lock(name) name##_global_lock_online() 32 - #define br_write_unlock(name) name##_global_unlock_online() 29 + #define br_lock_init(name) lg_lock_init(name, #name) 30 + #define br_read_lock(name) lg_local_lock(name) 31 + #define br_read_unlock(name) lg_local_unlock(name) 32 + #define br_write_lock(name) lg_global_lock(name) 33 + #define br_write_unlock(name) lg_global_unlock(name) 33 34 34 - #define DECLARE_BRLOCK(name) DECLARE_LGLOCK(name) 35 35 #define DEFINE_BRLOCK(name) DEFINE_LGLOCK(name) 36 - 37 - 38 - #define lg_lock_init(name) name##_lock_init() 39 - #define lg_local_lock(name) name##_local_lock() 40 - #define lg_local_unlock(name) name##_local_unlock() 41 - #define lg_local_lock_cpu(name, cpu) name##_local_lock_cpu(cpu) 42 - #define lg_local_unlock_cpu(name, cpu) name##_local_unlock_cpu(cpu) 43 - #define lg_global_lock(name) name##_global_lock() 44 - #define lg_global_unlock(name) name##_global_unlock() 45 - #define lg_global_lock_online(name) name##_global_lock_online() 46 - #define lg_global_unlock_online(name) name##_global_unlock_online() 47 36 48 37 #ifdef CONFIG_DEBUG_LOCK_ALLOC 49 38 #define LOCKDEP_INIT_MAP lockdep_init_map ··· 48 59 #define DEFINE_LGLOCK_LOCKDEP(name) 49 60 #endif 50 61 51 - 52 - #define DECLARE_LGLOCK(name) \ 53 - extern void name##_lock_init(void); \ 54 - extern void name##_local_lock(void); \ 55 - extern void name##_local_unlock(void); \ 56 - extern void name##_local_lock_cpu(int cpu); \ 57 - extern void name##_local_unlock_cpu(int cpu); \ 58 - extern void name##_global_lock(void); \ 59 - extern void name##_global_unlock(void); \ 60 - extern void name##_global_lock_online(void); \ 61 - extern void name##_global_unlock_online(void); \ 62 + struct lglock { 63 + arch_spinlock_t __percpu *lock; 64 + #ifdef CONFIG_DEBUG_LOCK_ALLOC 65 + struct lock_class_key lock_key; 66 + struct lockdep_map lock_dep_map; 67 + #endif 68 + }; 62 69 63 70 #define DEFINE_LGLOCK(name) \ 64 - \ 65 - DEFINE_SPINLOCK(name##_cpu_lock); \ 66 - cpumask_t name##_cpus __read_mostly; \ 67 - DEFINE_PER_CPU(arch_spinlock_t, name##_lock); \ 68 - DEFINE_LGLOCK_LOCKDEP(name); \ 69 - \ 70 - static int \ 71 - name##_lg_cpu_callback(struct notifier_block *nb, \ 72 - unsigned long action, void *hcpu) \ 73 - { \ 74 - switch (action & ~CPU_TASKS_FROZEN) { \ 75 - case CPU_UP_PREPARE: \ 76 - spin_lock(&name##_cpu_lock); \ 77 - cpu_set((unsigned long)hcpu, name##_cpus); \ 78 - spin_unlock(&name##_cpu_lock); \ 79 - break; \ 80 - case CPU_UP_CANCELED: case CPU_DEAD: \ 81 - spin_lock(&name##_cpu_lock); \ 82 - cpu_clear((unsigned long)hcpu, name##_cpus); \ 83 - spin_unlock(&name##_cpu_lock); \ 84 - } \ 85 - return NOTIFY_OK; \ 86 - } \ 87 - static struct notifier_block name##_lg_cpu_notifier = { \ 88 - .notifier_call = name##_lg_cpu_callback, \ 89 - }; \ 90 - void name##_lock_init(void) { \ 91 - int i; \ 92 - LOCKDEP_INIT_MAP(&name##_lock_dep_map, #name, &name##_lock_key, 0); \ 93 - for_each_possible_cpu(i) { \ 94 - arch_spinlock_t *lock; \ 95 - lock = &per_cpu(name##_lock, i); \ 96 - *lock = (arch_spinlock_t)__ARCH_SPIN_LOCK_UNLOCKED; \ 97 - } \ 98 - register_hotcpu_notifier(&name##_lg_cpu_notifier); \ 99 - get_online_cpus(); \ 100 - for_each_online_cpu(i) \ 101 - cpu_set(i, name##_cpus); \ 102 - put_online_cpus(); \ 103 - } \ 104 - EXPORT_SYMBOL(name##_lock_init); \ 105 - \ 106 - void name##_local_lock(void) { \ 107 - arch_spinlock_t *lock; \ 108 - preempt_disable(); \ 109 - rwlock_acquire_read(&name##_lock_dep_map, 0, 0, _THIS_IP_); \ 110 - lock = &__get_cpu_var(name##_lock); \ 111 - arch_spin_lock(lock); \ 112 - } \ 113 - EXPORT_SYMBOL(name##_local_lock); \ 114 - \ 115 - void name##_local_unlock(void) { \ 116 - arch_spinlock_t *lock; \ 117 - rwlock_release(&name##_lock_dep_map, 1, _THIS_IP_); \ 118 - lock = &__get_cpu_var(name##_lock); \ 119 - arch_spin_unlock(lock); \ 120 - preempt_enable(); \ 121 - } \ 122 - EXPORT_SYMBOL(name##_local_unlock); \ 123 - \ 124 - void name##_local_lock_cpu(int cpu) { \ 125 - arch_spinlock_t *lock; \ 126 - preempt_disable(); \ 127 - rwlock_acquire_read(&name##_lock_dep_map, 0, 0, _THIS_IP_); \ 128 - lock = &per_cpu(name##_lock, cpu); \ 129 - arch_spin_lock(lock); \ 130 - } \ 131 - EXPORT_SYMBOL(name##_local_lock_cpu); \ 132 - \ 133 - void name##_local_unlock_cpu(int cpu) { \ 134 - arch_spinlock_t *lock; \ 135 - rwlock_release(&name##_lock_dep_map, 1, _THIS_IP_); \ 136 - lock = &per_cpu(name##_lock, cpu); \ 137 - arch_spin_unlock(lock); \ 138 - preempt_enable(); \ 139 - } \ 140 - EXPORT_SYMBOL(name##_local_unlock_cpu); \ 141 - \ 142 - void name##_global_lock_online(void) { \ 143 - int i; \ 144 - spin_lock(&name##_cpu_lock); \ 145 - rwlock_acquire(&name##_lock_dep_map, 0, 0, _RET_IP_); \ 146 - for_each_cpu(i, &name##_cpus) { \ 147 - arch_spinlock_t *lock; \ 148 - lock = &per_cpu(name##_lock, i); \ 149 - arch_spin_lock(lock); \ 150 - } \ 151 - } \ 152 - EXPORT_SYMBOL(name##_global_lock_online); \ 153 - \ 154 - void name##_global_unlock_online(void) { \ 155 - int i; \ 156 - rwlock_release(&name##_lock_dep_map, 1, _RET_IP_); \ 157 - for_each_cpu(i, &name##_cpus) { \ 158 - arch_spinlock_t *lock; \ 159 - lock = &per_cpu(name##_lock, i); \ 160 - arch_spin_unlock(lock); \ 161 - } \ 162 - spin_unlock(&name##_cpu_lock); \ 163 - } \ 164 - EXPORT_SYMBOL(name##_global_unlock_online); \ 165 - \ 166 - void name##_global_lock(void) { \ 167 - int i; \ 168 - preempt_disable(); \ 169 - rwlock_acquire(&name##_lock_dep_map, 0, 0, _RET_IP_); \ 170 - for_each_possible_cpu(i) { \ 171 - arch_spinlock_t *lock; \ 172 - lock = &per_cpu(name##_lock, i); \ 173 - arch_spin_lock(lock); \ 174 - } \ 175 - } \ 176 - EXPORT_SYMBOL(name##_global_lock); \ 177 - \ 178 - void name##_global_unlock(void) { \ 179 - int i; \ 180 - rwlock_release(&name##_lock_dep_map, 1, _RET_IP_); \ 181 - for_each_possible_cpu(i) { \ 182 - arch_spinlock_t *lock; \ 183 - lock = &per_cpu(name##_lock, i); \ 184 - arch_spin_unlock(lock); \ 185 - } \ 186 - preempt_enable(); \ 187 - } \ 188 - EXPORT_SYMBOL(name##_global_unlock); 71 + DEFINE_LGLOCK_LOCKDEP(name); \ 72 + DEFINE_PER_CPU(arch_spinlock_t, name ## _lock) \ 73 + = __ARCH_SPIN_LOCK_UNLOCKED; \ 74 + struct lglock name = { .lock = &name ## _lock } 75 + 76 + void lg_lock_init(struct lglock *lg, char *name); 77 + void lg_local_lock(struct lglock *lg); 78 + void lg_local_unlock(struct lglock *lg); 79 + void lg_local_lock_cpu(struct lglock *lg, int cpu); 80 + void lg_local_unlock_cpu(struct lglock *lg, int cpu); 81 + void lg_global_lock(struct lglock *lg); 82 + void lg_global_unlock(struct lglock *lg); 83 + 189 84 #endif
+1 -1
include/linux/mm.h
··· 1392 1392 extern unsigned long mmap_region(struct file *file, unsigned long addr, 1393 1393 unsigned long len, unsigned long flags, 1394 1394 vm_flags_t vm_flags, unsigned long pgoff); 1395 - extern unsigned long do_mmap(struct file *, unsigned long, 1395 + extern unsigned long do_mmap_pgoff(struct file *, unsigned long, 1396 1396 unsigned long, unsigned long, 1397 1397 unsigned long, unsigned long); 1398 1398 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
+22 -18
include/linux/security.h
··· 86 86 extern int cap_inode_removexattr(struct dentry *dentry, const char *name); 87 87 extern int cap_inode_need_killpriv(struct dentry *dentry); 88 88 extern int cap_inode_killpriv(struct dentry *dentry); 89 - extern int cap_file_mmap(struct file *file, unsigned long reqprot, 90 - unsigned long prot, unsigned long flags, 91 - unsigned long addr, unsigned long addr_only); 89 + extern int cap_mmap_addr(unsigned long addr); 90 + extern int cap_mmap_file(struct file *file, unsigned long reqprot, 91 + unsigned long prot, unsigned long flags); 92 92 extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); 93 93 extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, 94 94 unsigned long arg4, unsigned long arg5); ··· 586 586 * simple integer value. When @arg represents a user space pointer, it 587 587 * should never be used by the security module. 588 588 * Return 0 if permission is granted. 589 - * @file_mmap : 589 + * @mmap_addr : 590 + * Check permissions for a mmap operation at @addr. 591 + * @addr contains virtual address that will be used for the operation. 592 + * Return 0 if permission is granted. 593 + * @mmap_file : 590 594 * Check permissions for a mmap operation. The @file may be NULL, e.g. 591 595 * if mapping anonymous memory. 592 596 * @file contains the file structure for file to map (may be NULL). 593 597 * @reqprot contains the protection requested by the application. 594 598 * @prot contains the protection that will be applied by the kernel. 595 599 * @flags contains the operational flags. 596 - * @addr contains virtual address that will be used for the operation. 597 - * @addr_only contains a boolean: 0 if file-backed VMA, otherwise 1. 598 600 * Return 0 if permission is granted. 599 601 * @file_mprotect: 600 602 * Check permissions before changing memory access permissions. ··· 1483 1481 void (*file_free_security) (struct file *file); 1484 1482 int (*file_ioctl) (struct file *file, unsigned int cmd, 1485 1483 unsigned long arg); 1486 - int (*file_mmap) (struct file *file, 1484 + int (*mmap_addr) (unsigned long addr); 1485 + int (*mmap_file) (struct file *file, 1487 1486 unsigned long reqprot, unsigned long prot, 1488 - unsigned long flags, unsigned long addr, 1489 - unsigned long addr_only); 1487 + unsigned long flags); 1490 1488 int (*file_mprotect) (struct vm_area_struct *vma, 1491 1489 unsigned long reqprot, 1492 1490 unsigned long prot); ··· 1745 1743 int security_file_alloc(struct file *file); 1746 1744 void security_file_free(struct file *file); 1747 1745 int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 1748 - int security_file_mmap(struct file *file, unsigned long reqprot, 1749 - unsigned long prot, unsigned long flags, 1750 - unsigned long addr, unsigned long addr_only); 1746 + int security_mmap_file(struct file *file, unsigned long prot, 1747 + unsigned long flags); 1748 + int security_mmap_addr(unsigned long addr); 1751 1749 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, 1752 1750 unsigned long prot); 1753 1751 int security_file_lock(struct file *file, unsigned int cmd); ··· 2183 2181 return 0; 2184 2182 } 2185 2183 2186 - static inline int security_file_mmap(struct file *file, unsigned long reqprot, 2187 - unsigned long prot, 2188 - unsigned long flags, 2189 - unsigned long addr, 2190 - unsigned long addr_only) 2184 + static inline int security_mmap_file(struct file *file, unsigned long prot, 2185 + unsigned long flags) 2191 2186 { 2192 - return cap_file_mmap(file, reqprot, prot, flags, addr, addr_only); 2187 + return 0; 2188 + } 2189 + 2190 + static inline int security_mmap_addr(unsigned long addr) 2191 + { 2192 + return cap_mmap_addr(addr); 2193 2193 } 2194 2194 2195 2195 static inline int security_file_mprotect(struct vm_area_struct *vma,
+1 -1
include/linux/types.h
··· 25 25 typedef __kernel_ino_t ino_t; 26 26 typedef __kernel_mode_t mode_t; 27 27 typedef unsigned short umode_t; 28 - typedef __kernel_nlink_t nlink_t; 28 + typedef __u32 nlink_t; 29 29 typedef __kernel_off_t off_t; 30 30 typedef __kernel_pid_t pid_t; 31 31 typedef __kernel_daddr_t daddr_t;
+6 -1
ipc/shm.c
··· 1036 1036 sfd->file = shp->shm_file; 1037 1037 sfd->vm_ops = NULL; 1038 1038 1039 + err = security_mmap_file(file, prot, flags); 1040 + if (err) 1041 + goto out_fput; 1042 + 1039 1043 down_write(&current->mm->mmap_sem); 1040 1044 if (addr && !(shmflg & SHM_REMAP)) { 1041 1045 err = -EINVAL; ··· 1054 1050 goto invalid; 1055 1051 } 1056 1052 1057 - user_addr = do_mmap (file, addr, size, prot, flags, 0); 1053 + user_addr = do_mmap_pgoff(file, addr, size, prot, flags, 0); 1058 1054 *raddr = user_addr; 1059 1055 err = 0; 1060 1056 if (IS_ERR_VALUE(user_addr)) ··· 1062 1058 invalid: 1063 1059 up_write(&current->mm->mmap_sem); 1064 1060 1061 + out_fput: 1065 1062 fput(file); 1066 1063 1067 1064 out_nattch:
+1 -1
kernel/Makefile
··· 10 10 kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ 11 11 hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ 12 12 notifier.o ksysfs.o cred.o \ 13 - async.o range.o groups.o 13 + async.o range.o groups.o lglock.o 14 14 15 15 ifdef CONFIG_FUNCTION_TRACER 16 16 # Do not trace debug files and internal ftrace files
+89
kernel/lglock.c
··· 1 + /* See include/linux/lglock.h for description */ 2 + #include <linux/module.h> 3 + #include <linux/lglock.h> 4 + #include <linux/cpu.h> 5 + #include <linux/string.h> 6 + 7 + /* 8 + * Note there is no uninit, so lglocks cannot be defined in 9 + * modules (but it's fine to use them from there) 10 + * Could be added though, just undo lg_lock_init 11 + */ 12 + 13 + void lg_lock_init(struct lglock *lg, char *name) 14 + { 15 + LOCKDEP_INIT_MAP(&lg->lock_dep_map, name, &lg->lock_key, 0); 16 + } 17 + EXPORT_SYMBOL(lg_lock_init); 18 + 19 + void lg_local_lock(struct lglock *lg) 20 + { 21 + arch_spinlock_t *lock; 22 + 23 + preempt_disable(); 24 + rwlock_acquire_read(&lg->lock_dep_map, 0, 0, _RET_IP_); 25 + lock = this_cpu_ptr(lg->lock); 26 + arch_spin_lock(lock); 27 + } 28 + EXPORT_SYMBOL(lg_local_lock); 29 + 30 + void lg_local_unlock(struct lglock *lg) 31 + { 32 + arch_spinlock_t *lock; 33 + 34 + rwlock_release(&lg->lock_dep_map, 1, _RET_IP_); 35 + lock = this_cpu_ptr(lg->lock); 36 + arch_spin_unlock(lock); 37 + preempt_enable(); 38 + } 39 + EXPORT_SYMBOL(lg_local_unlock); 40 + 41 + void lg_local_lock_cpu(struct lglock *lg, int cpu) 42 + { 43 + arch_spinlock_t *lock; 44 + 45 + preempt_disable(); 46 + rwlock_acquire_read(&lg->lock_dep_map, 0, 0, _RET_IP_); 47 + lock = per_cpu_ptr(lg->lock, cpu); 48 + arch_spin_lock(lock); 49 + } 50 + EXPORT_SYMBOL(lg_local_lock_cpu); 51 + 52 + void lg_local_unlock_cpu(struct lglock *lg, int cpu) 53 + { 54 + arch_spinlock_t *lock; 55 + 56 + rwlock_release(&lg->lock_dep_map, 1, _RET_IP_); 57 + lock = per_cpu_ptr(lg->lock, cpu); 58 + arch_spin_unlock(lock); 59 + preempt_enable(); 60 + } 61 + EXPORT_SYMBOL(lg_local_unlock_cpu); 62 + 63 + void lg_global_lock(struct lglock *lg) 64 + { 65 + int i; 66 + 67 + preempt_disable(); 68 + rwlock_acquire(&lg->lock_dep_map, 0, 0, _RET_IP_); 69 + for_each_possible_cpu(i) { 70 + arch_spinlock_t *lock; 71 + lock = per_cpu_ptr(lg->lock, i); 72 + arch_spin_lock(lock); 73 + } 74 + } 75 + EXPORT_SYMBOL(lg_global_lock); 76 + 77 + void lg_global_unlock(struct lglock *lg) 78 + { 79 + int i; 80 + 81 + rwlock_release(&lg->lock_dep_map, 1, _RET_IP_); 82 + for_each_possible_cpu(i) { 83 + arch_spinlock_t *lock; 84 + lock = per_cpu_ptr(lg->lock, i); 85 + arch_spin_unlock(lock); 86 + } 87 + preempt_enable(); 88 + } 89 + EXPORT_SYMBOL(lg_global_unlock);
+2 -4
mm/cleancache.c
··· 80 80 static int cleancache_get_key(struct inode *inode, 81 81 struct cleancache_filekey *key) 82 82 { 83 - int (*fhfn)(struct dentry *, __u32 *fh, int *, int); 83 + int (*fhfn)(struct inode *, __u32 *fh, int *, struct inode *); 84 84 int len = 0, maxlen = CLEANCACHE_KEY_MAX; 85 85 struct super_block *sb = inode->i_sb; 86 86 ··· 88 88 if (sb->s_export_op != NULL) { 89 89 fhfn = sb->s_export_op->encode_fh; 90 90 if (fhfn) { 91 - struct dentry d; 92 - d.d_inode = inode; 93 - len = (*fhfn)(&d, &key->u.fh[0], &maxlen, 0); 91 + len = (*fhfn)(inode, &key->u.fh[0], &maxlen, NULL); 94 92 if (len <= 0 || len == 255) 95 93 return -1; 96 94 if (maxlen > CLEANCACHE_KEY_MAX)
+3 -66
mm/filemap.c
··· 1899 1899 } 1900 1900 EXPORT_SYMBOL(read_cache_page); 1901 1901 1902 - /* 1903 - * The logic we want is 1904 - * 1905 - * if suid or (sgid and xgrp) 1906 - * remove privs 1907 - */ 1908 - int should_remove_suid(struct dentry *dentry) 1909 - { 1910 - umode_t mode = dentry->d_inode->i_mode; 1911 - int kill = 0; 1912 - 1913 - /* suid always must be killed */ 1914 - if (unlikely(mode & S_ISUID)) 1915 - kill = ATTR_KILL_SUID; 1916 - 1917 - /* 1918 - * sgid without any exec bits is just a mandatory locking mark; leave 1919 - * it alone. If some exec bits are set, it's a real sgid; kill it. 1920 - */ 1921 - if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) 1922 - kill |= ATTR_KILL_SGID; 1923 - 1924 - if (unlikely(kill && !capable(CAP_FSETID) && S_ISREG(mode))) 1925 - return kill; 1926 - 1927 - return 0; 1928 - } 1929 - EXPORT_SYMBOL(should_remove_suid); 1930 - 1931 - static int __remove_suid(struct dentry *dentry, int kill) 1932 - { 1933 - struct iattr newattrs; 1934 - 1935 - newattrs.ia_valid = ATTR_FORCE | kill; 1936 - return notify_change(dentry, &newattrs); 1937 - } 1938 - 1939 - int file_remove_suid(struct file *file) 1940 - { 1941 - struct dentry *dentry = file->f_path.dentry; 1942 - struct inode *inode = dentry->d_inode; 1943 - int killsuid; 1944 - int killpriv; 1945 - int error = 0; 1946 - 1947 - /* Fast path for nothing security related */ 1948 - if (IS_NOSEC(inode)) 1949 - return 0; 1950 - 1951 - killsuid = should_remove_suid(dentry); 1952 - killpriv = security_inode_need_killpriv(dentry); 1953 - 1954 - if (killpriv < 0) 1955 - return killpriv; 1956 - if (killpriv) 1957 - error = security_inode_killpriv(dentry); 1958 - if (!error && killsuid) 1959 - error = __remove_suid(dentry, killsuid); 1960 - if (!error && (inode->i_sb->s_flags & MS_NOSEC)) 1961 - inode->i_flags |= S_NOSEC; 1962 - 1963 - return error; 1964 - } 1965 - EXPORT_SYMBOL(file_remove_suid); 1966 - 1967 1902 static size_t __iovec_copy_from_user_inatomic(char *vaddr, 1968 1903 const struct iovec *iov, size_t base, size_t bytes) 1969 1904 { ··· 2424 2489 if (err) 2425 2490 goto out; 2426 2491 2427 - file_update_time(file); 2492 + err = file_update_time(file); 2493 + if (err) 2494 + goto out; 2428 2495 2429 2496 /* coalesce the iovecs and go direct-to-BIO for O_DIRECT */ 2430 2497 if (unlikely(file->f_flags & O_DIRECT)) {
+3 -1
mm/filemap_xip.c
··· 426 426 if (ret) 427 427 goto out_backing; 428 428 429 - file_update_time(filp); 429 + ret = file_update_time(filp); 430 + if (ret) 431 + goto out_backing; 430 432 431 433 ret = __xip_file_write (filp, buf, count, pos, ppos); 432 434
+4
mm/internal.h
··· 350 350 extern u64 hwpoison_filter_flags_value; 351 351 extern u64 hwpoison_filter_memcg; 352 352 extern u32 hwpoison_filter_enable; 353 + 354 + extern unsigned long vm_mmap_pgoff(struct file *, unsigned long, 355 + unsigned long, unsigned long, 356 + unsigned long, unsigned long);
+6 -48
mm/mmap.c
··· 971 971 * The caller must hold down_write(&current->mm->mmap_sem). 972 972 */ 973 973 974 - static unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, 974 + unsigned long do_mmap_pgoff(struct file *file, unsigned long addr, 975 975 unsigned long len, unsigned long prot, 976 976 unsigned long flags, unsigned long pgoff) 977 977 { 978 978 struct mm_struct * mm = current->mm; 979 979 struct inode *inode; 980 980 vm_flags_t vm_flags; 981 - int error; 982 - unsigned long reqprot = prot; 983 981 984 982 /* 985 983 * Does the application expect PROT_READ to imply PROT_EXEC? ··· 1099 1101 } 1100 1102 } 1101 1103 1102 - error = security_file_mmap(file, reqprot, prot, flags, addr, 0); 1103 - if (error) 1104 - return error; 1105 - 1106 1104 return mmap_region(file, addr, len, flags, vm_flags, pgoff); 1107 1105 } 1108 - 1109 - unsigned long do_mmap(struct file *file, unsigned long addr, 1110 - unsigned long len, unsigned long prot, 1111 - unsigned long flag, unsigned long offset) 1112 - { 1113 - if (unlikely(offset + PAGE_ALIGN(len) < offset)) 1114 - return -EINVAL; 1115 - if (unlikely(offset & ~PAGE_MASK)) 1116 - return -EINVAL; 1117 - return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); 1118 - } 1119 - EXPORT_SYMBOL(do_mmap); 1120 - 1121 - unsigned long vm_mmap(struct file *file, unsigned long addr, 1122 - unsigned long len, unsigned long prot, 1123 - unsigned long flag, unsigned long offset) 1124 - { 1125 - unsigned long ret; 1126 - struct mm_struct *mm = current->mm; 1127 - 1128 - down_write(&mm->mmap_sem); 1129 - ret = do_mmap(file, addr, len, prot, flag, offset); 1130 - up_write(&mm->mmap_sem); 1131 - return ret; 1132 - } 1133 - EXPORT_SYMBOL(vm_mmap); 1134 1106 1135 1107 SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, 1136 1108 unsigned long, prot, unsigned long, flags, ··· 1133 1165 1134 1166 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 1135 1167 1136 - down_write(&current->mm->mmap_sem); 1137 - retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); 1138 - up_write(&current->mm->mmap_sem); 1139 - 1168 + retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff); 1140 1169 if (file) 1141 1170 fput(file); 1142 1171 out: ··· 1594 1629 if (addr & ~PAGE_MASK) 1595 1630 return -EINVAL; 1596 1631 1597 - return arch_rebalance_pgtables(addr, len); 1632 + addr = arch_rebalance_pgtables(addr, len); 1633 + error = security_mmap_addr(addr); 1634 + return error ? error : addr; 1598 1635 } 1599 1636 1600 1637 EXPORT_SYMBOL(get_unmapped_area); ··· 1786 1819 return -ENOMEM; 1787 1820 1788 1821 address &= PAGE_MASK; 1789 - error = security_file_mmap(NULL, 0, 0, 0, address, 1); 1822 + error = security_mmap_addr(address); 1790 1823 if (error) 1791 1824 return error; 1792 1825 ··· 2126 2159 2127 2160 return 0; 2128 2161 } 2129 - EXPORT_SYMBOL(do_munmap); 2130 2162 2131 2163 int vm_munmap(unsigned long start, size_t len) 2132 2164 { ··· 2172 2206 len = PAGE_ALIGN(len); 2173 2207 if (!len) 2174 2208 return addr; 2175 - 2176 - error = security_file_mmap(NULL, 0, 0, 0, addr, 1); 2177 - if (error) 2178 - return error; 2179 2209 2180 2210 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; 2181 2211 ··· 2524 2562 2525 2563 vma->vm_ops = &special_mapping_vmops; 2526 2564 vma->vm_private_data = pages; 2527 - 2528 - ret = security_file_mmap(NULL, 0, 0, 0, vma->vm_start, 1); 2529 - if (ret) 2530 - goto out; 2531 2565 2532 2566 ret = insert_vm_struct(mm, vma); 2533 2567 if (ret)
+5 -21
mm/mremap.c
··· 371 371 if ((addr <= new_addr) && (addr+old_len) > new_addr) 372 372 goto out; 373 373 374 - ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1); 375 - if (ret) 376 - goto out; 377 - 378 374 ret = do_munmap(mm, new_addr, new_len); 379 375 if (ret) 380 376 goto out; ··· 428 432 * MREMAP_FIXED option added 5-Dec-1999 by Benjamin LaHaise 429 433 * This option implies MREMAP_MAYMOVE. 430 434 */ 431 - unsigned long do_mremap(unsigned long addr, 432 - unsigned long old_len, unsigned long new_len, 433 - unsigned long flags, unsigned long new_addr) 435 + SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, 436 + unsigned long, new_len, unsigned long, flags, 437 + unsigned long, new_addr) 434 438 { 435 439 struct mm_struct *mm = current->mm; 436 440 struct vm_area_struct *vma; 437 441 unsigned long ret = -EINVAL; 438 442 unsigned long charged = 0; 443 + 444 + down_write(&current->mm->mmap_sem); 439 445 440 446 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE)) 441 447 goto out; ··· 528 530 goto out; 529 531 } 530 532 531 - ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1); 532 - if (ret) 533 - goto out; 534 533 ret = move_vma(vma, addr, old_len, new_len, new_addr); 535 534 } 536 535 out: 537 536 if (ret & ~PAGE_MASK) 538 537 vm_unacct_memory(charged); 539 - return ret; 540 - } 541 - 542 - SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, 543 - unsigned long, new_len, unsigned long, flags, 544 - unsigned long, new_addr) 545 - { 546 - unsigned long ret; 547 - 548 - down_write(&current->mm->mmap_sem); 549 - ret = do_mremap(addr, old_len, new_len, flags, new_addr); 550 538 up_write(&current->mm->mmap_sem); 551 539 return ret; 552 540 }
+3 -32
mm/nommu.c
··· 889 889 unsigned long *_capabilities) 890 890 { 891 891 unsigned long capabilities, rlen; 892 - unsigned long reqprot = prot; 893 892 int ret; 894 893 895 894 /* do the simple checks first */ ··· 1046 1047 } 1047 1048 1048 1049 /* allow the security API to have its say */ 1049 - ret = security_file_mmap(file, reqprot, prot, flags, addr, 0); 1050 + ret = security_mmap_addr(addr); 1050 1051 if (ret < 0) 1051 1052 return ret; 1052 1053 ··· 1232 1233 /* 1233 1234 * handle mapping creation for uClinux 1234 1235 */ 1235 - static unsigned long do_mmap_pgoff(struct file *file, 1236 + unsigned long do_mmap_pgoff(struct file *file, 1236 1237 unsigned long addr, 1237 1238 unsigned long len, 1238 1239 unsigned long prot, ··· 1470 1471 return -ENOMEM; 1471 1472 } 1472 1473 1473 - unsigned long do_mmap(struct file *file, unsigned long addr, 1474 - unsigned long len, unsigned long prot, 1475 - unsigned long flag, unsigned long offset) 1476 - { 1477 - if (unlikely(offset + PAGE_ALIGN(len) < offset)) 1478 - return -EINVAL; 1479 - if (unlikely(offset & ~PAGE_MASK)) 1480 - return -EINVAL; 1481 - return do_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); 1482 - } 1483 - EXPORT_SYMBOL(do_mmap); 1484 - 1485 - unsigned long vm_mmap(struct file *file, unsigned long addr, 1486 - unsigned long len, unsigned long prot, 1487 - unsigned long flag, unsigned long offset) 1488 - { 1489 - unsigned long ret; 1490 - struct mm_struct *mm = current->mm; 1491 - 1492 - down_write(&mm->mmap_sem); 1493 - ret = do_mmap(file, addr, len, prot, flag, offset); 1494 - up_write(&mm->mmap_sem); 1495 - return ret; 1496 - } 1497 - EXPORT_SYMBOL(vm_mmap); 1498 - 1499 1474 SYSCALL_DEFINE6(mmap_pgoff, unsigned long, addr, unsigned long, len, 1500 1475 unsigned long, prot, unsigned long, flags, 1501 1476 unsigned long, fd, unsigned long, pgoff) ··· 1486 1513 1487 1514 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 1488 1515 1489 - down_write(&current->mm->mmap_sem); 1490 - retval = do_mmap_pgoff(file, addr, len, prot, flags, pgoff); 1491 - up_write(&current->mm->mmap_sem); 1516 + ret = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff); 1492 1517 1493 1518 if (file) 1494 1519 fput(file);
+2 -4
mm/shmem.c
··· 2439 2439 return dentry; 2440 2440 } 2441 2441 2442 - static int shmem_encode_fh(struct dentry *dentry, __u32 *fh, int *len, 2443 - int connectable) 2442 + static int shmem_encode_fh(struct inode *inode, __u32 *fh, int *len, 2443 + struct inode *parent) 2444 2444 { 2445 - struct inode *inode = dentry->d_inode; 2446 - 2447 2445 if (*len < 3) { 2448 2446 *len = 3; 2449 2447 return 255;
+30
mm/util.c
··· 4 4 #include <linux/export.h> 5 5 #include <linux/err.h> 6 6 #include <linux/sched.h> 7 + #include <linux/security.h> 7 8 #include <asm/uaccess.h> 8 9 9 10 #include "internal.h" ··· 341 340 return ret; 342 341 } 343 342 EXPORT_SYMBOL_GPL(get_user_pages_fast); 343 + 344 + unsigned long vm_mmap_pgoff(struct file *file, unsigned long addr, 345 + unsigned long len, unsigned long prot, 346 + unsigned long flag, unsigned long pgoff) 347 + { 348 + unsigned long ret; 349 + struct mm_struct *mm = current->mm; 350 + 351 + ret = security_mmap_file(file, prot, flag); 352 + if (!ret) { 353 + down_write(&mm->mmap_sem); 354 + ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff); 355 + up_write(&mm->mmap_sem); 356 + } 357 + return ret; 358 + } 359 + 360 + unsigned long vm_mmap(struct file *file, unsigned long addr, 361 + unsigned long len, unsigned long prot, 362 + unsigned long flag, unsigned long offset) 363 + { 364 + if (unlikely(offset + PAGE_ALIGN(len) < offset)) 365 + return -EINVAL; 366 + if (unlikely(offset & ~PAGE_MASK)) 367 + return -EINVAL; 368 + 369 + return vm_mmap_pgoff(file, addr, len, prot, flag, offset >> PAGE_SHIFT); 370 + } 371 + EXPORT_SYMBOL(vm_mmap); 344 372 345 373 /* Tracepoints definitions. */ 346 374 EXPORT_TRACEPOINT_SYMBOL(kmalloc);
-2
net/sched/sch_atm.c
··· 16 16 #include <net/netlink.h> 17 17 #include <net/pkt_sched.h> 18 18 19 - extern struct socket *sockfd_lookup(int fd, int *err); /* @@@ fix this */ 20 - 21 19 /* 22 20 * The ATM queuing discipline provides a framework for invoking classifiers 23 21 * (aka "filters"), which in turn select classes of this queuing discipline.
+4 -11
security/apparmor/lsm.c
··· 490 490 return common_file_perm(op, file, mask); 491 491 } 492 492 493 - static int apparmor_file_mmap(struct file *file, unsigned long reqprot, 494 - unsigned long prot, unsigned long flags, 495 - unsigned long addr, unsigned long addr_only) 493 + static int apparmor_mmap_file(struct file *file, unsigned long reqprot, 494 + unsigned long prot, unsigned long flags) 496 495 { 497 - int rc = 0; 498 - 499 - /* do DAC check */ 500 - rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only); 501 - if (rc || addr_only) 502 - return rc; 503 - 504 496 return common_mmap(OP_FMMAP, file, prot, flags); 505 497 } 506 498 ··· 638 646 .file_permission = apparmor_file_permission, 639 647 .file_alloc_security = apparmor_file_alloc_security, 640 648 .file_free_security = apparmor_file_free_security, 641 - .file_mmap = apparmor_file_mmap, 649 + .mmap_file = apparmor_mmap_file, 650 + .mmap_addr = cap_mmap_addr, 642 651 .file_mprotect = apparmor_file_mprotect, 643 652 .file_lock = apparmor_file_lock, 644 653
+2 -1
security/capability.c
··· 949 949 set_to_cap_if_null(ops, file_alloc_security); 950 950 set_to_cap_if_null(ops, file_free_security); 951 951 set_to_cap_if_null(ops, file_ioctl); 952 - set_to_cap_if_null(ops, file_mmap); 952 + set_to_cap_if_null(ops, mmap_addr); 953 + set_to_cap_if_null(ops, mmap_file); 953 954 set_to_cap_if_null(ops, file_mprotect); 954 955 set_to_cap_if_null(ops, file_lock); 955 956 set_to_cap_if_null(ops, file_fcntl);
+8 -9
security/commoncap.c
··· 958 958 } 959 959 960 960 /* 961 - * cap_file_mmap - check if able to map given addr 962 - * @file: unused 963 - * @reqprot: unused 964 - * @prot: unused 965 - * @flags: unused 961 + * cap_mmap_addr - check if able to map given addr 966 962 * @addr: address attempting to be mapped 967 - * @addr_only: unused 968 963 * 969 964 * If the process is attempting to map memory below dac_mmap_min_addr they need 970 965 * CAP_SYS_RAWIO. The other parameters to this function are unused by the 971 966 * capability security module. Returns 0 if this mapping should be allowed 972 967 * -EPERM if not. 973 968 */ 974 - int cap_file_mmap(struct file *file, unsigned long reqprot, 975 - unsigned long prot, unsigned long flags, 976 - unsigned long addr, unsigned long addr_only) 969 + int cap_mmap_addr(unsigned long addr) 977 970 { 978 971 int ret = 0; 979 972 ··· 978 985 current->flags |= PF_SUPERPRIV; 979 986 } 980 987 return ret; 988 + } 989 + 990 + int cap_mmap_file(struct file *file, unsigned long reqprot, 991 + unsigned long prot, unsigned long flags) 992 + { 993 + return 0; 981 994 }
+46 -5
security/security.c
··· 20 20 #include <linux/ima.h> 21 21 #include <linux/evm.h> 22 22 #include <linux/fsnotify.h> 23 + #include <linux/mman.h> 24 + #include <linux/mount.h> 25 + #include <linux/personality.h> 23 26 #include <net/flow.h> 24 27 25 28 #define MAX_LSM_EVM_XATTR 2 ··· 660 657 return security_ops->file_ioctl(file, cmd, arg); 661 658 } 662 659 663 - int security_file_mmap(struct file *file, unsigned long reqprot, 664 - unsigned long prot, unsigned long flags, 665 - unsigned long addr, unsigned long addr_only) 660 + static inline unsigned long mmap_prot(struct file *file, unsigned long prot) 661 + { 662 + /* 663 + * Does we have PROT_READ and does the application expect 664 + * it to imply PROT_EXEC? If not, nothing to talk about... 665 + */ 666 + if ((prot & (PROT_READ | PROT_EXEC)) != PROT_READ) 667 + return prot; 668 + if (!(current->personality & READ_IMPLIES_EXEC)) 669 + return prot; 670 + /* 671 + * if that's an anonymous mapping, let it. 672 + */ 673 + if (!file) 674 + return prot | PROT_EXEC; 675 + /* 676 + * ditto if it's not on noexec mount, except that on !MMU we need 677 + * BDI_CAP_EXEC_MMAP (== VM_MAYEXEC) in this case 678 + */ 679 + if (!(file->f_path.mnt->mnt_flags & MNT_NOEXEC)) { 680 + #ifndef CONFIG_MMU 681 + unsigned long caps = 0; 682 + struct address_space *mapping = file->f_mapping; 683 + if (mapping && mapping->backing_dev_info) 684 + caps = mapping->backing_dev_info->capabilities; 685 + if (!(caps & BDI_CAP_EXEC_MAP)) 686 + return prot; 687 + #endif 688 + return prot | PROT_EXEC; 689 + } 690 + /* anything on noexec mount won't get PROT_EXEC */ 691 + return prot; 692 + } 693 + 694 + int security_mmap_file(struct file *file, unsigned long prot, 695 + unsigned long flags) 666 696 { 667 697 int ret; 668 - 669 - ret = security_ops->file_mmap(file, reqprot, prot, flags, addr, addr_only); 698 + ret = security_ops->mmap_file(file, prot, 699 + mmap_prot(file, prot), flags); 670 700 if (ret) 671 701 return ret; 672 702 return ima_file_mmap(file, prot); 703 + } 704 + 705 + int security_mmap_addr(unsigned long addr) 706 + { 707 + return security_ops->mmap_addr(addr); 673 708 } 674 709 675 710 int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
+8 -7
security/selinux/hooks.c
··· 3083 3083 return rc; 3084 3084 } 3085 3085 3086 - static int selinux_file_mmap(struct file *file, unsigned long reqprot, 3087 - unsigned long prot, unsigned long flags, 3088 - unsigned long addr, unsigned long addr_only) 3086 + static int selinux_mmap_addr(unsigned long addr) 3089 3087 { 3090 3088 int rc = 0; 3091 3089 u32 sid = current_sid(); ··· 3102 3104 } 3103 3105 3104 3106 /* do DAC check on address space usage */ 3105 - rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only); 3106 - if (rc || addr_only) 3107 - return rc; 3107 + return cap_mmap_addr(addr); 3108 + } 3108 3109 3110 + static int selinux_mmap_file(struct file *file, unsigned long reqprot, 3111 + unsigned long prot, unsigned long flags) 3112 + { 3109 3113 if (selinux_checkreqprot) 3110 3114 prot = reqprot; 3111 3115 ··· 5570 5570 .file_alloc_security = selinux_file_alloc_security, 5571 5571 .file_free_security = selinux_file_free_security, 5572 5572 .file_ioctl = selinux_file_ioctl, 5573 - .file_mmap = selinux_file_mmap, 5573 + .mmap_file = selinux_mmap_file, 5574 + .mmap_addr = selinux_mmap_addr, 5574 5575 .file_mprotect = selinux_file_mprotect, 5575 5576 .file_lock = selinux_file_lock, 5576 5577 .file_fcntl = selinux_file_fcntl,
+7 -29
security/selinux/selinuxfs.c
··· 1259 1259 if (!inode) 1260 1260 goto out; 1261 1261 1262 - ret = -EINVAL; 1263 - len = snprintf(page, PAGE_SIZE, "/%s/%s", BOOL_DIR_NAME, names[i]); 1264 - if (len < 0) 1265 - goto out; 1266 - 1267 1262 ret = -ENAMETOOLONG; 1263 + len = snprintf(page, PAGE_SIZE, "/%s/%s", BOOL_DIR_NAME, names[i]); 1268 1264 if (len >= PAGE_SIZE) 1269 1265 goto out; 1270 1266 ··· 1553 1557 static ssize_t sel_read_class(struct file *file, char __user *buf, 1554 1558 size_t count, loff_t *ppos) 1555 1559 { 1556 - ssize_t rc, len; 1557 - char *page; 1558 1560 unsigned long ino = file->f_path.dentry->d_inode->i_ino; 1559 - 1560 - page = (char *)__get_free_page(GFP_KERNEL); 1561 - if (!page) 1562 - return -ENOMEM; 1563 - 1564 - len = snprintf(page, PAGE_SIZE, "%d", sel_ino_to_class(ino)); 1565 - rc = simple_read_from_buffer(buf, count, ppos, page, len); 1566 - free_page((unsigned long)page); 1567 - 1568 - return rc; 1561 + char res[TMPBUFLEN]; 1562 + ssize_t len = snprintf(res, sizeof(res), "%d", sel_ino_to_class(ino)); 1563 + return simple_read_from_buffer(buf, count, ppos, res, len); 1569 1564 } 1570 1565 1571 1566 static const struct file_operations sel_class_ops = { ··· 1567 1580 static ssize_t sel_read_perm(struct file *file, char __user *buf, 1568 1581 size_t count, loff_t *ppos) 1569 1582 { 1570 - ssize_t rc, len; 1571 - char *page; 1572 1583 unsigned long ino = file->f_path.dentry->d_inode->i_ino; 1573 - 1574 - page = (char *)__get_free_page(GFP_KERNEL); 1575 - if (!page) 1576 - return -ENOMEM; 1577 - 1578 - len = snprintf(page, PAGE_SIZE, "%d", sel_ino_to_perm(ino)); 1579 - rc = simple_read_from_buffer(buf, count, ppos, page, len); 1580 - free_page((unsigned long)page); 1581 - 1582 - return rc; 1584 + char res[TMPBUFLEN]; 1585 + ssize_t len = snprintf(res, sizeof(res), "%d", sel_ino_to_perm(ino)); 1586 + return simple_read_from_buffer(buf, count, ppos, res, len); 1583 1587 } 1584 1588 1585 1589 static const struct file_operations sel_perm_ops = {
+5 -10
security/smack/smack_lsm.c
··· 1171 1171 } 1172 1172 1173 1173 /** 1174 - * smack_file_mmap : 1174 + * smack_mmap_file : 1175 1175 * Check permissions for a mmap operation. The @file may be NULL, e.g. 1176 1176 * if mapping anonymous memory. 1177 1177 * @file contains the file structure for file to map (may be NULL). ··· 1180 1180 * @flags contains the operational flags. 1181 1181 * Return 0 if permission is granted. 1182 1182 */ 1183 - static int smack_file_mmap(struct file *file, 1183 + static int smack_mmap_file(struct file *file, 1184 1184 unsigned long reqprot, unsigned long prot, 1185 - unsigned long flags, unsigned long addr, 1186 - unsigned long addr_only) 1185 + unsigned long flags) 1187 1186 { 1188 1187 struct smack_known *skp; 1189 1188 struct smack_rule *srp; ··· 1196 1197 int mmay; 1197 1198 int tmay; 1198 1199 int rc; 1199 - 1200 - /* do DAC check on address space usage */ 1201 - rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only); 1202 - if (rc || addr_only) 1203 - return rc; 1204 1200 1205 1201 if (file == NULL || file->f_dentry == NULL) 1206 1202 return 0; ··· 3476 3482 .file_ioctl = smack_file_ioctl, 3477 3483 .file_lock = smack_file_lock, 3478 3484 .file_fcntl = smack_file_fcntl, 3479 - .file_mmap = smack_file_mmap, 3485 + .mmap_file = smack_mmap_file, 3486 + .mmap_addr = cap_mmap_addr, 3480 3487 .file_set_fowner = smack_file_set_fowner, 3481 3488 .file_send_sigiotask = smack_file_send_sigiotask, 3482 3489 .file_receive = smack_file_receive,