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

Pull more VFS bits from Al Viro:
"Unfortunately, it looks like xattr series will have to wait until the
next cycle ;-/

This pile contains 9p cleanups and fixes (races in v9fs_fid_add()
etc), fixup for nommu breakage in shmem.c, several cleanups and a bit
more file_inode() work"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
constify path_get/path_put and fs_struct.c stuff
fix nommu breakage in shmem.c
cache the value of file_inode() in struct file
9p: if v9fs_fid_lookup() gets to asking server, it'd better have hashed dentry
9p: make sure ->lookup() adds fid to the right dentry
9p: untangle ->lookup() a bit
9p: double iput() in ->lookup() if d_materialise_unique() fails
9p: v9fs_fid_add() can't fail now
v9fs: get rid of v9fs_dentry
9p: turn fid->dlist into hlist
9p: don't bother with private lock in ->d_fsdata; dentry->d_lock will do just fine
more file_inode() open-coded instances
selinux: opened file can't have NULL or negative ->f_path.dentry

(In the meantime, the hlist traversal macros have changed, so this
required a semantic conflict fixup for the newly hlistified fid->dlist)

Changed files
+108 -171
arch
s390
hypfs
x86
kernel
drivers
staging
comedi
tty
fs
include
kernel
mm
security
selinux
+2 -4
arch/s390/hypfs/inode.c
··· 171 171 unsigned long nr_segs, loff_t offset) 172 172 { 173 173 int rc; 174 - struct super_block *sb; 175 - struct hypfs_sb_info *fs_info; 174 + struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; 175 + struct hypfs_sb_info *fs_info = sb->s_fs_info; 176 176 size_t count = iov_length(iov, nr_segs); 177 177 178 - sb = iocb->ki_filp->f_path.dentry->d_inode->i_sb; 179 - fs_info = sb->s_fs_info; 180 178 /* 181 179 * Currently we only allow one update per second for two reasons: 182 180 * 1. diag 204 is VERY expensive
+4 -5
arch/x86/kernel/msr.c
··· 71 71 u32 __user *tmp = (u32 __user *) buf; 72 72 u32 data[2]; 73 73 u32 reg = *ppos; 74 - int cpu = iminor(file->f_path.dentry->d_inode); 74 + int cpu = iminor(file_inode(file)); 75 75 int err = 0; 76 76 ssize_t bytes = 0; 77 77 ··· 99 99 const u32 __user *tmp = (const u32 __user *)buf; 100 100 u32 data[2]; 101 101 u32 reg = *ppos; 102 - int cpu = iminor(file->f_path.dentry->d_inode); 102 + int cpu = iminor(file_inode(file)); 103 103 int err = 0; 104 104 ssize_t bytes = 0; 105 105 ··· 125 125 { 126 126 u32 __user *uregs = (u32 __user *)arg; 127 127 u32 regs[8]; 128 - int cpu = iminor(file->f_path.dentry->d_inode); 128 + int cpu = iminor(file_inode(file)); 129 129 int err; 130 130 131 131 switch (ioc) { ··· 171 171 172 172 static int msr_open(struct inode *inode, struct file *file) 173 173 { 174 - unsigned int cpu; 174 + unsigned int cpu = iminor(file_inode(file)); 175 175 struct cpuinfo_x86 *c; 176 176 177 177 if (!capable(CAP_SYS_RAWIO)) 178 178 return -EPERM; 179 179 180 - cpu = iminor(file->f_path.dentry->d_inode); 181 180 if (cpu >= nr_cpu_ids || !cpu_online(cpu)) 182 181 return -ENXIO; /* No such CPU */ 183 182
+7 -7
drivers/staging/comedi/comedi_fops.c
··· 580 580 struct comedi_devinfo __user *arg, 581 581 struct file *file) 582 582 { 583 - const unsigned minor = iminor(file->f_dentry->d_inode); 583 + const unsigned minor = iminor(file_inode(file)); 584 584 struct comedi_file_info *info = comedi_file_info_from_minor(minor); 585 585 struct comedi_subdevice *s; 586 586 struct comedi_devinfo devinfo; ··· 1615 1615 static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, 1616 1616 unsigned long arg) 1617 1617 { 1618 - const unsigned minor = iminor(file->f_dentry->d_inode); 1618 + const unsigned minor = iminor(file_inode(file)); 1619 1619 struct comedi_file_info *info = comedi_file_info_from_minor(minor); 1620 1620 struct comedi_device *dev = comedi_dev_from_file_info(info); 1621 1621 int rc; ··· 1743 1743 1744 1744 static int comedi_mmap(struct file *file, struct vm_area_struct *vma) 1745 1745 { 1746 - const unsigned minor = iminor(file->f_dentry->d_inode); 1746 + const unsigned minor = iminor(file_inode(file)); 1747 1747 struct comedi_file_info *info = comedi_file_info_from_minor(minor); 1748 1748 struct comedi_device *dev = comedi_dev_from_file_info(info); 1749 1749 struct comedi_subdevice *s; ··· 1823 1823 static unsigned int comedi_poll(struct file *file, poll_table *wait) 1824 1824 { 1825 1825 unsigned int mask = 0; 1826 - const unsigned minor = iminor(file->f_dentry->d_inode); 1826 + const unsigned minor = iminor(file_inode(file)); 1827 1827 struct comedi_file_info *info = comedi_file_info_from_minor(minor); 1828 1828 struct comedi_device *dev = comedi_dev_from_file_info(info); 1829 1829 struct comedi_subdevice *s; ··· 1869 1869 struct comedi_async *async; 1870 1870 int n, m, count = 0, retval = 0; 1871 1871 DECLARE_WAITQUEUE(wait, current); 1872 - const unsigned minor = iminor(file->f_dentry->d_inode); 1872 + const unsigned minor = iminor(file_inode(file)); 1873 1873 struct comedi_file_info *info = comedi_file_info_from_minor(minor); 1874 1874 struct comedi_device *dev = comedi_dev_from_file_info(info); 1875 1875 ··· 1964 1964 struct comedi_async *async; 1965 1965 int n, m, count = 0, retval = 0; 1966 1966 DECLARE_WAITQUEUE(wait, current); 1967 - const unsigned minor = iminor(file->f_dentry->d_inode); 1967 + const unsigned minor = iminor(file_inode(file)); 1968 1968 struct comedi_file_info *info = comedi_file_info_from_minor(minor); 1969 1969 struct comedi_device *dev = comedi_dev_from_file_info(info); 1970 1970 ··· 2133 2133 2134 2134 static int comedi_fasync(int fd, struct file *file, int on) 2135 2135 { 2136 - const unsigned minor = iminor(file->f_dentry->d_inode); 2136 + const unsigned minor = iminor(file_inode(file)); 2137 2137 struct comedi_device *dev = comedi_dev_from_minor(minor); 2138 2138 2139 2139 if (!dev)
+6 -10
drivers/tty/tty_io.c
··· 960 960 loff_t *ppos) 961 961 { 962 962 int i; 963 - struct inode *inode = file->f_path.dentry->d_inode; 964 963 struct tty_struct *tty = file_tty(file); 965 964 struct tty_ldisc *ld; 966 965 967 - if (tty_paranoia_check(tty, inode, "tty_read")) 966 + if (tty_paranoia_check(tty, file_inode(file), "tty_read")) 968 967 return -EIO; 969 968 if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags))) 970 969 return -EIO; ··· 1131 1132 static ssize_t tty_write(struct file *file, const char __user *buf, 1132 1133 size_t count, loff_t *ppos) 1133 1134 { 1134 - struct inode *inode = file->f_path.dentry->d_inode; 1135 1135 struct tty_struct *tty = file_tty(file); 1136 1136 struct tty_ldisc *ld; 1137 1137 ssize_t ret; 1138 1138 1139 - if (tty_paranoia_check(tty, inode, "tty_write")) 1139 + if (tty_paranoia_check(tty, file_inode(file), "tty_write")) 1140 1140 return -EIO; 1141 1141 if (!tty || !tty->ops->write || 1142 1142 (test_bit(TTY_IO_ERROR, &tty->flags))) ··· 2045 2047 struct tty_ldisc *ld; 2046 2048 int ret = 0; 2047 2049 2048 - if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_poll")) 2050 + if (tty_paranoia_check(tty, file_inode(filp), "tty_poll")) 2049 2051 return 0; 2050 2052 2051 2053 ld = tty_ldisc_ref_wait(tty); ··· 2061 2063 unsigned long flags; 2062 2064 int retval = 0; 2063 2065 2064 - if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync")) 2066 + if (tty_paranoia_check(tty, file_inode(filp), "tty_fasync")) 2065 2067 goto out; 2066 2068 2067 2069 retval = fasync_helper(fd, filp, on, &tty->fasync); ··· 2635 2637 void __user *p = (void __user *)arg; 2636 2638 int retval; 2637 2639 struct tty_ldisc *ld; 2638 - struct inode *inode = file->f_dentry->d_inode; 2639 2640 2640 - if (tty_paranoia_check(tty, inode, "tty_ioctl")) 2641 + if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) 2641 2642 return -EINVAL; 2642 2643 2643 2644 real_tty = tty_pair_get_tty(tty); ··· 2777 2780 static long tty_compat_ioctl(struct file *file, unsigned int cmd, 2778 2781 unsigned long arg) 2779 2782 { 2780 - struct inode *inode = file->f_dentry->d_inode; 2781 2783 struct tty_struct *tty = file_tty(file); 2782 2784 struct tty_ldisc *ld; 2783 2785 int retval = -ENOIOCTLCMD; 2784 2786 2785 - if (tty_paranoia_check(tty, inode, "tty_ioctl")) 2787 + if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) 2786 2788 return -EINVAL; 2787 2789 2788 2790 if (tty->ops->compat_ioctl) {
+25 -29
fs/9p/fid.c
··· 41 41 * 42 42 */ 43 43 44 - int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) 44 + static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid) 45 45 { 46 - struct v9fs_dentry *dent; 46 + hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata); 47 + } 47 48 48 - p9_debug(P9_DEBUG_VFS, "fid %d dentry %s\n", 49 - fid->fid, dentry->d_name.name); 50 - 51 - dent = dentry->d_fsdata; 52 - if (!dent) { 53 - dent = kmalloc(sizeof(struct v9fs_dentry), GFP_KERNEL); 54 - if (!dent) 55 - return -ENOMEM; 56 - 57 - spin_lock_init(&dent->lock); 58 - INIT_LIST_HEAD(&dent->fidlist); 59 - dentry->d_fsdata = dent; 60 - } 61 - 62 - spin_lock(&dent->lock); 63 - list_add(&fid->dlist, &dent->fidlist); 64 - spin_unlock(&dent->lock); 65 - 66 - return 0; 49 + void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) 50 + { 51 + spin_lock(&dentry->d_lock); 52 + __add_fid(dentry, fid); 53 + spin_unlock(&dentry->d_lock); 67 54 } 68 55 69 56 /** ··· 63 76 64 77 static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) 65 78 { 66 - struct v9fs_dentry *dent; 67 79 struct p9_fid *fid, *ret; 68 80 69 81 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", 70 82 dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), 71 83 any); 72 - dent = (struct v9fs_dentry *) dentry->d_fsdata; 73 84 ret = NULL; 74 - if (dent) { 75 - spin_lock(&dent->lock); 76 - list_for_each_entry(fid, &dent->fidlist, dlist) { 85 + /* we'll recheck under lock if there's anything to look in */ 86 + if (dentry->d_fsdata) { 87 + struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata; 88 + spin_lock(&dentry->d_lock); 89 + hlist_for_each_entry(fid, h, dlist) { 77 90 if (any || uid_eq(fid->uid, uid)) { 78 91 ret = fid; 79 92 break; 80 93 } 81 94 } 82 - spin_unlock(&dent->lock); 95 + spin_unlock(&dentry->d_lock); 83 96 } 84 97 85 98 return ret; ··· 202 215 } 203 216 kfree(wnames); 204 217 fid_out: 205 - if (!IS_ERR(fid)) 206 - v9fs_fid_add(dentry, fid); 218 + if (!IS_ERR(fid)) { 219 + spin_lock(&dentry->d_lock); 220 + if (d_unhashed(dentry)) { 221 + spin_unlock(&dentry->d_lock); 222 + p9_client_clunk(fid); 223 + fid = ERR_PTR(-ENOENT); 224 + } else { 225 + __add_fid(dentry, fid); 226 + spin_unlock(&dentry->d_lock); 227 + } 228 + } 207 229 err_out: 208 230 up_read(&v9ses->rename_sem); 209 231 return fid;
+1 -21
fs/9p/fid.h
··· 23 23 #define FS_9P_FID_H 24 24 #include <linux/list.h> 25 25 26 - /** 27 - * struct v9fs_dentry - 9p private data stored in dentry d_fsdata 28 - * @lock: protects the fidlist 29 - * @fidlist: list of FIDs currently associated with this dentry 30 - * 31 - * This structure defines the 9p private data associated with 32 - * a particular dentry. In particular, this private data is used 33 - * to lookup which 9P FID handle should be used for a particular VFS 34 - * operation. FID handles are associated with dentries instead of 35 - * inodes in order to more closely map functionality to the Plan 9 36 - * expected behavior for FID reclaimation and tracking. 37 - * 38 - * See Also: Mapping FIDs to Linux VFS model in 39 - * Design and Implementation of the Linux 9P File System documentation 40 - */ 41 - struct v9fs_dentry { 42 - spinlock_t lock; /* protect fidlist */ 43 - struct list_head fidlist; 44 - }; 45 - 46 26 struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); 47 27 struct p9_fid *v9fs_fid_clone(struct dentry *dentry); 48 - int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); 28 + void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); 49 29 struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); 50 30 #endif
+4 -13
fs/9p/vfs_dentry.c
··· 83 83 84 84 static void v9fs_dentry_release(struct dentry *dentry) 85 85 { 86 - struct v9fs_dentry *dent; 87 - struct p9_fid *temp, *current_fid; 88 - 86 + struct hlist_node *p, *n; 89 87 p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n", 90 88 dentry->d_name.name, dentry); 91 - dent = dentry->d_fsdata; 92 - if (dent) { 93 - list_for_each_entry_safe(current_fid, temp, &dent->fidlist, 94 - dlist) { 95 - p9_client_clunk(current_fid); 96 - } 97 - 98 - kfree(dent); 99 - dentry->d_fsdata = NULL; 100 - } 89 + hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata) 90 + p9_client_clunk(hlist_entry(p, struct p9_fid, dlist)); 91 + dentry->d_fsdata = NULL; 101 92 } 102 93 103 94 static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
+14 -26
fs/9p/vfs_inode.c
··· 692 692 "inode creation failed %d\n", err); 693 693 goto error; 694 694 } 695 - err = v9fs_fid_add(dentry, fid); 696 - if (err < 0) 697 - goto error; 695 + v9fs_fid_add(dentry, fid); 698 696 d_instantiate(dentry, inode); 699 697 } 700 698 return ofid; ··· 788 790 struct p9_fid *dfid, *fid; 789 791 struct inode *inode; 790 792 char *name; 791 - int result = 0; 792 793 793 794 p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n", 794 795 dir, dentry->d_name.name, dentry, flags); ··· 805 808 name = (char *) dentry->d_name.name; 806 809 fid = p9_client_walk(dfid, 1, &name, 1); 807 810 if (IS_ERR(fid)) { 808 - result = PTR_ERR(fid); 809 - if (result == -ENOENT) { 810 - inode = NULL; 811 - goto inst_out; 811 + if (fid == ERR_PTR(-ENOENT)) { 812 + d_add(dentry, NULL); 813 + return NULL; 812 814 } 813 - 814 - return ERR_PTR(result); 815 + return ERR_CAST(fid); 815 816 } 816 817 /* 817 818 * Make sure we don't use a wrong inode due to parallel ··· 821 826 else 822 827 inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); 823 828 if (IS_ERR(inode)) { 824 - result = PTR_ERR(inode); 825 - inode = NULL; 826 - goto error; 829 + p9_client_clunk(fid); 830 + return ERR_CAST(inode); 827 831 } 828 - result = v9fs_fid_add(dentry, fid); 829 - if (result < 0) 830 - goto error_iput; 831 - inst_out: 832 832 /* 833 833 * If we had a rename on the server and a parallel lookup 834 834 * for the new name, then make sure we instantiate with ··· 832 842 * k/b. 833 843 */ 834 844 res = d_materialise_unique(dentry, inode); 835 - if (!IS_ERR(res)) 836 - return res; 837 - result = PTR_ERR(res); 838 - error_iput: 839 - iput(inode); 840 - error: 841 - p9_client_clunk(fid); 842 - 843 - return ERR_PTR(result); 845 + if (!res) 846 + v9fs_fid_add(dentry, fid); 847 + else if (!IS_ERR(res)) 848 + v9fs_fid_add(res, fid); 849 + else 850 + p9_client_clunk(fid); 851 + return res; 844 852 } 845 853 846 854 static int
+7 -12
fs/9p/vfs_inode_dotl.c
··· 333 333 /* Now set the ACL based on the default value */ 334 334 v9fs_set_create_acl(inode, fid, dacl, pacl); 335 335 336 - err = v9fs_fid_add(dentry, fid); 337 - if (err < 0) 338 - goto error; 336 + v9fs_fid_add(dentry, fid); 339 337 d_instantiate(dentry, inode); 340 338 341 339 v9inode = V9FS_I(inode); ··· 451 453 err); 452 454 goto error; 453 455 } 454 - err = v9fs_fid_add(dentry, fid); 455 - if (err < 0) 456 - goto error; 456 + v9fs_fid_add(dentry, fid); 457 457 v9fs_set_create_acl(inode, fid, dacl, pacl); 458 458 d_instantiate(dentry, inode); 459 459 fid = NULL; 460 + err = 0; 460 461 } else { 461 462 /* 462 463 * Not in cached mode. No need to populate ··· 744 747 err); 745 748 goto error; 746 749 } 747 - err = v9fs_fid_add(dentry, fid); 748 - if (err < 0) 749 - goto error; 750 + v9fs_fid_add(dentry, fid); 750 751 d_instantiate(dentry, inode); 751 752 fid = NULL; 753 + err = 0; 752 754 } else { 753 755 /* Not in cached mode. No need to populate inode with stat */ 754 756 inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); ··· 896 900 goto error; 897 901 } 898 902 v9fs_set_create_acl(inode, fid, dacl, pacl); 899 - err = v9fs_fid_add(dentry, fid); 900 - if (err < 0) 901 - goto error; 903 + v9fs_fid_add(dentry, fid); 902 904 d_instantiate(dentry, inode); 903 905 fid = NULL; 906 + err = 0; 904 907 } else { 905 908 /* 906 909 * Not in cached mode. No need to populate inode with stat.
+1 -1
fs/ext4/indirect.c
··· 1606 1606 1607 1607 int ext4_ind_punch_hole(struct file *file, loff_t offset, loff_t length) 1608 1608 { 1609 - struct inode *inode = file->f_path.dentry->d_inode; 1609 + struct inode *inode = file_inode(file); 1610 1610 struct super_block *sb = inode->i_sb; 1611 1611 ext4_lblk_t first_block, stop_block; 1612 1612 struct address_space *mapping = inode->i_mapping;
+3 -3
fs/f2fs/file.c
··· 29 29 struct vm_fault *vmf) 30 30 { 31 31 struct page *page = vmf->page; 32 - struct inode *inode = vma->vm_file->f_path.dentry->d_inode; 32 + struct inode *inode = file_inode(vma->vm_file); 33 33 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 34 34 block_t old_blk_addr; 35 35 struct dnode_of_data dn; ··· 544 544 static long f2fs_fallocate(struct file *file, int mode, 545 545 loff_t offset, loff_t len) 546 546 { 547 - struct inode *inode = file->f_path.dentry->d_inode; 547 + struct inode *inode = file_inode(file); 548 548 long ret; 549 549 550 550 if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) ··· 577 577 578 578 long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 579 579 { 580 - struct inode *inode = filp->f_dentry->d_inode; 580 + struct inode *inode = file_inode(filp); 581 581 struct f2fs_inode_info *fi = F2FS_I(inode); 582 582 unsigned int flags; 583 583 int ret;
+2
fs/file_table.c
··· 176 176 return file; 177 177 178 178 file->f_path = *path; 179 + file->f_inode = path->dentry->d_inode; 179 180 file->f_mapping = path->dentry->d_inode->i_mapping; 180 181 file->f_mode = mode; 181 182 file->f_op = fop; ··· 259 258 drop_file_write_access(file); 260 259 file->f_path.dentry = NULL; 261 260 file->f_path.mnt = NULL; 261 + file->f_inode = NULL; 262 262 file_free(file); 263 263 dput(dentry); 264 264 mntput(mnt);
+3 -3
fs/fs_struct.c
··· 10 10 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. 11 11 * It can block. 12 12 */ 13 - void set_fs_root(struct fs_struct *fs, struct path *path) 13 + void set_fs_root(struct fs_struct *fs, const struct path *path) 14 14 { 15 15 struct path old_root; 16 16 ··· 29 29 * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. 30 30 * It can block. 31 31 */ 32 - void set_fs_pwd(struct fs_struct *fs, struct path *path) 32 + void set_fs_pwd(struct fs_struct *fs, const struct path *path) 33 33 { 34 34 struct path old_pwd; 35 35 ··· 53 53 return 1; 54 54 } 55 55 56 - void chroot_fs_refs(struct path *old_root, struct path *new_root) 56 + void chroot_fs_refs(const struct path *old_root, const struct path *new_root) 57 57 { 58 58 struct task_struct *g, *p; 59 59 struct fs_struct *fs;
+1 -1
fs/fuse/dev.c
··· 532 532 533 533 void fuse_force_forget(struct file *file, u64 nodeid) 534 534 { 535 - struct inode *inode = file->f_path.dentry->d_inode; 535 + struct inode *inode = file_inode(file); 536 536 struct fuse_conn *fc = get_fuse_conn(inode); 537 537 struct fuse_req *req; 538 538 struct fuse_forget_in inarg;
+12 -12
fs/fuse/file.c
··· 355 355 356 356 static int fuse_flush(struct file *file, fl_owner_t id) 357 357 { 358 - struct inode *inode = file->f_path.dentry->d_inode; 358 + struct inode *inode = file_inode(file); 359 359 struct fuse_conn *fc = get_fuse_conn(inode); 360 360 struct fuse_file *ff = file->private_data; 361 361 struct fuse_req *req; ··· 1215 1215 unsigned long nr_segs, loff_t *ppos) 1216 1216 { 1217 1217 ssize_t res; 1218 - struct inode *inode = file->f_path.dentry->d_inode; 1218 + struct inode *inode = file_inode(file); 1219 1219 1220 1220 if (is_bad_inode(inode)) 1221 1221 return -EIO; ··· 1238 1238 static ssize_t __fuse_direct_write(struct file *file, const struct iovec *iov, 1239 1239 unsigned long nr_segs, loff_t *ppos) 1240 1240 { 1241 - struct inode *inode = file->f_path.dentry->d_inode; 1241 + struct inode *inode = file_inode(file); 1242 1242 size_t count = iov_length(iov, nr_segs); 1243 1243 ssize_t res; 1244 1244 ··· 1258 1258 size_t count, loff_t *ppos) 1259 1259 { 1260 1260 struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count }; 1261 - struct inode *inode = file->f_path.dentry->d_inode; 1261 + struct inode *inode = file_inode(file); 1262 1262 ssize_t res; 1263 1263 1264 1264 if (is_bad_inode(inode)) ··· 1485 1485 static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) 1486 1486 { 1487 1487 if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) { 1488 - struct inode *inode = file->f_dentry->d_inode; 1488 + struct inode *inode = file_inode(file); 1489 1489 struct fuse_conn *fc = get_fuse_conn(inode); 1490 1490 struct fuse_inode *fi = get_fuse_inode(inode); 1491 1491 struct fuse_file *ff = file->private_data; ··· 1543 1543 const struct file_lock *fl, int opcode, pid_t pid, 1544 1544 int flock) 1545 1545 { 1546 - struct inode *inode = file->f_path.dentry->d_inode; 1546 + struct inode *inode = file_inode(file); 1547 1547 struct fuse_conn *fc = get_fuse_conn(inode); 1548 1548 struct fuse_file *ff = file->private_data; 1549 1549 struct fuse_lk_in *arg = &req->misc.lk_in; ··· 1565 1565 1566 1566 static int fuse_getlk(struct file *file, struct file_lock *fl) 1567 1567 { 1568 - struct inode *inode = file->f_path.dentry->d_inode; 1568 + struct inode *inode = file_inode(file); 1569 1569 struct fuse_conn *fc = get_fuse_conn(inode); 1570 1570 struct fuse_req *req; 1571 1571 struct fuse_lk_out outarg; ··· 1590 1590 1591 1591 static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) 1592 1592 { 1593 - struct inode *inode = file->f_path.dentry->d_inode; 1593 + struct inode *inode = file_inode(file); 1594 1594 struct fuse_conn *fc = get_fuse_conn(inode); 1595 1595 struct fuse_req *req; 1596 1596 int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; ··· 1622 1622 1623 1623 static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) 1624 1624 { 1625 - struct inode *inode = file->f_path.dentry->d_inode; 1625 + struct inode *inode = file_inode(file); 1626 1626 struct fuse_conn *fc = get_fuse_conn(inode); 1627 1627 int err; 1628 1628 ··· 1645 1645 1646 1646 static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) 1647 1647 { 1648 - struct inode *inode = file->f_path.dentry->d_inode; 1648 + struct inode *inode = file_inode(file); 1649 1649 struct fuse_conn *fc = get_fuse_conn(inode); 1650 1650 int err; 1651 1651 ··· 1702 1702 static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence) 1703 1703 { 1704 1704 loff_t retval; 1705 - struct inode *inode = file->f_path.dentry->d_inode; 1705 + struct inode *inode = file_inode(file); 1706 1706 1707 1707 /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */ 1708 1708 if (whence == SEEK_CUR || whence == SEEK_SET) ··· 2079 2079 long fuse_ioctl_common(struct file *file, unsigned int cmd, 2080 2080 unsigned long arg, unsigned int flags) 2081 2081 { 2082 - struct inode *inode = file->f_dentry->d_inode; 2082 + struct inode *inode = file_inode(file); 2083 2083 struct fuse_conn *fc = get_fuse_conn(inode); 2084 2084 2085 2085 if (!fuse_allow_current_process(fc))
+1 -1
fs/internal.h
··· 69 69 /* 70 70 * fs_struct.c 71 71 */ 72 - extern void chroot_fs_refs(struct path *, struct path *); 72 + extern void chroot_fs_refs(const struct path *, const struct path *); 73 73 74 74 /* 75 75 * file_table.c
+2 -2
fs/namei.c
··· 451 451 * 452 452 * Given a path increment the reference count to the dentry and the vfsmount. 453 453 */ 454 - void path_get(struct path *path) 454 + void path_get(const struct path *path) 455 455 { 456 456 mntget(path->mnt); 457 457 dget(path->dentry); ··· 464 464 * 465 465 * Given a path decrement the reference count to the dentry and the vfsmount. 466 466 */ 467 - void path_put(struct path *path) 467 + void path_put(const struct path *path) 468 468 { 469 469 dput(path->dentry); 470 470 mntput(path->mnt);
+2 -1
fs/open.c
··· 704 704 f->f_mode = FMODE_PATH; 705 705 706 706 path_get(&f->f_path); 707 - inode = file_inode(f); 707 + inode = f->f_inode = f->f_path.dentry->d_inode; 708 708 if (f->f_mode & FMODE_WRITE) { 709 709 error = __get_file_write_access(inode, f->f_path.mnt); 710 710 if (error) ··· 767 767 path_put(&f->f_path); 768 768 f->f_path.mnt = NULL; 769 769 f->f_path.dentry = NULL; 770 + f->f_inode = NULL; 770 771 return error; 771 772 } 772 773
+1 -1
fs/seq_file.c
··· 339 339 /** 340 340 * seq_release - free the structures associated with sequential file. 341 341 * @file: file in question 342 - * @inode: file->f_path.dentry->d_inode 342 + * @inode: its inode 343 343 * 344 344 * Frees the structures associated with sequential file; can be used 345 345 * as ->f_op->release() if you don't have private data to destroy.
+2 -1
include/linux/fs.h
··· 769 769 } f_u; 770 770 struct path f_path; 771 771 #define f_dentry f_path.dentry 772 + struct inode *f_inode; /* cached value */ 772 773 const struct file_operations *f_op; 773 774 774 775 /* ··· 2218 2217 2219 2218 static inline struct inode *file_inode(struct file *f) 2220 2219 { 2221 - return f->f_path.dentry->d_inode; 2220 + return f->f_inode; 2222 2221 } 2223 2222 2224 2223 /*
+2 -2
include/linux/fs_struct.h
··· 17 17 extern struct kmem_cache *fs_cachep; 18 18 19 19 extern void exit_fs(struct task_struct *); 20 - extern void set_fs_root(struct fs_struct *, struct path *); 21 - extern void set_fs_pwd(struct fs_struct *, struct path *); 20 + extern void set_fs_root(struct fs_struct *, const struct path *); 21 + extern void set_fs_pwd(struct fs_struct *, const struct path *); 22 22 extern struct fs_struct *copy_fs_struct(struct fs_struct *); 23 23 extern void free_fs_struct(struct fs_struct *); 24 24 extern int unshare_fs_struct(void);
+2 -2
include/linux/path.h
··· 9 9 struct dentry *dentry; 10 10 }; 11 11 12 - extern void path_get(struct path *); 13 - extern void path_put(struct path *); 12 + extern void path_get(const struct path *); 13 + extern void path_put(const struct path *); 14 14 15 15 static inline int path_equal(const struct path *path1, const struct path *path2) 16 16 {
+1 -1
include/net/9p/client.h
··· 192 192 void *rdir; 193 193 194 194 struct list_head flist; 195 - struct list_head dlist; /* list of all fids attached to a dentry */ 195 + struct hlist_node dlist; /* list of all fids attached to a dentry */ 196 196 }; 197 197 198 198 /**
+1 -1
kernel/futex.c
··· 226 226 * Returns a negative error code or 0 227 227 * The key words are stored in *key on success. 228 228 * 229 - * For shared mappings, it's (page->index, vma->vm_file->f_path.dentry->d_inode, 229 + * For shared mappings, it's (page->index, file_inode(vma->vm_file), 230 230 * offset_within_page). For private mappings, it's (uaddr, current->mm). 231 231 * We can usually work out the index without swapping in the page. 232 232 *
+2 -3
mm/shmem.c
··· 2932 2932 inode->i_size = size; 2933 2933 clear_nlink(inode); /* It is unlinked */ 2934 2934 #ifndef CONFIG_MMU 2935 - error = ramfs_nommu_expand_for_mapping(inode, size); 2936 - res = ERR_PTR(error); 2937 - if (error) 2935 + res = ERR_PTR(ramfs_nommu_expand_for_mapping(inode, size)); 2936 + if (IS_ERR(res)) 2938 2937 goto put_dentry; 2939 2938 #endif 2940 2939
-9
security/selinux/hooks.c
··· 3135 3135 3136 3136 switch (cmd) { 3137 3137 case F_SETFL: 3138 - if (!file->f_path.dentry || !file->f_path.dentry->d_inode) { 3139 - err = -EINVAL; 3140 - break; 3141 - } 3142 - 3143 3138 if ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) { 3144 3139 err = file_has_perm(cred, file, FILE__WRITE); 3145 3140 break; ··· 3157 3162 case F_SETLK64: 3158 3163 case F_SETLKW64: 3159 3164 #endif 3160 - if (!file->f_path.dentry || !file->f_path.dentry->d_inode) { 3161 - err = -EINVAL; 3162 - break; 3163 - } 3164 3165 err = file_has_perm(cred, file, FILE__LOCK); 3165 3166 break; 3166 3167 }