diff options
| -rw-r--r-- | arch/s390/hypfs/inode.c | 6 | ||||
| -rw-r--r-- | arch/x86/kernel/msr.c | 9 | ||||
| -rw-r--r-- | drivers/staging/comedi/comedi_fops.c | 14 | ||||
| -rw-r--r-- | drivers/tty/tty_io.c | 16 | ||||
| -rw-r--r-- | fs/9p/fid.c | 54 | ||||
| -rw-r--r-- | fs/9p/fid.h | 22 | ||||
| -rw-r--r-- | fs/9p/vfs_dentry.c | 17 | ||||
| -rw-r--r-- | fs/9p/vfs_inode.c | 40 | ||||
| -rw-r--r-- | fs/9p/vfs_inode_dotl.c | 19 | ||||
| -rw-r--r-- | fs/ext4/indirect.c | 2 | ||||
| -rw-r--r-- | fs/f2fs/file.c | 6 | ||||
| -rw-r--r-- | fs/file_table.c | 2 | ||||
| -rw-r--r-- | fs/fs_struct.c | 6 | ||||
| -rw-r--r-- | fs/fuse/dev.c | 2 | ||||
| -rw-r--r-- | fs/fuse/file.c | 24 | ||||
| -rw-r--r-- | fs/internal.h | 2 | ||||
| -rw-r--r-- | fs/namei.c | 4 | ||||
| -rw-r--r-- | fs/open.c | 3 | ||||
| -rw-r--r-- | fs/seq_file.c | 2 | ||||
| -rw-r--r-- | include/linux/fs.h | 3 | ||||
| -rw-r--r-- | include/linux/fs_struct.h | 4 | ||||
| -rw-r--r-- | include/linux/path.h | 4 | ||||
| -rw-r--r-- | include/net/9p/client.h | 2 | ||||
| -rw-r--r-- | kernel/futex.c | 2 | ||||
| -rw-r--r-- | mm/shmem.c | 5 | ||||
| -rw-r--r-- | security/selinux/hooks.c | 9 |
26 files changed, 108 insertions, 171 deletions
diff --git a/arch/s390/hypfs/inode.c b/arch/s390/hypfs/inode.c index 280ded8b79ba..8538015ed4a0 100644 --- a/arch/s390/hypfs/inode.c +++ b/arch/s390/hypfs/inode.c | |||
| @@ -171,12 +171,10 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, | |||
| 171 | unsigned long nr_segs, loff_t offset) | 171 | unsigned long nr_segs, loff_t offset) |
| 172 | { | 172 | { |
| 173 | int rc; | 173 | int rc; |
| 174 | struct super_block *sb; | 174 | struct super_block *sb = file_inode(iocb->ki_filp)->i_sb; |
| 175 | struct hypfs_sb_info *fs_info; | 175 | struct hypfs_sb_info *fs_info = sb->s_fs_info; |
| 176 | size_t count = iov_length(iov, nr_segs); | 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 | * Currently we only allow one update per second for two reasons: | 179 | * Currently we only allow one update per second for two reasons: |
| 182 | * 1. diag 204 is VERY expensive | 180 | * 1. diag 204 is VERY expensive |
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 4929502c1372..ce130493b802 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c | |||
| @@ -71,7 +71,7 @@ static ssize_t msr_read(struct file *file, char __user *buf, | |||
| 71 | u32 __user *tmp = (u32 __user *) buf; | 71 | u32 __user *tmp = (u32 __user *) buf; |
| 72 | u32 data[2]; | 72 | u32 data[2]; |
| 73 | u32 reg = *ppos; | 73 | u32 reg = *ppos; |
| 74 | int cpu = iminor(file->f_path.dentry->d_inode); | 74 | int cpu = iminor(file_inode(file)); |
| 75 | int err = 0; | 75 | int err = 0; |
| 76 | ssize_t bytes = 0; | 76 | ssize_t bytes = 0; |
| 77 | 77 | ||
| @@ -99,7 +99,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf, | |||
| 99 | const u32 __user *tmp = (const u32 __user *)buf; | 99 | const u32 __user *tmp = (const u32 __user *)buf; |
| 100 | u32 data[2]; | 100 | u32 data[2]; |
| 101 | u32 reg = *ppos; | 101 | u32 reg = *ppos; |
| 102 | int cpu = iminor(file->f_path.dentry->d_inode); | 102 | int cpu = iminor(file_inode(file)); |
| 103 | int err = 0; | 103 | int err = 0; |
| 104 | ssize_t bytes = 0; | 104 | ssize_t bytes = 0; |
| 105 | 105 | ||
| @@ -125,7 +125,7 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) | |||
| 125 | { | 125 | { |
| 126 | u32 __user *uregs = (u32 __user *)arg; | 126 | u32 __user *uregs = (u32 __user *)arg; |
| 127 | u32 regs[8]; | 127 | u32 regs[8]; |
| 128 | int cpu = iminor(file->f_path.dentry->d_inode); | 128 | int cpu = iminor(file_inode(file)); |
| 129 | int err; | 129 | int err; |
| 130 | 130 | ||
| 131 | switch (ioc) { | 131 | switch (ioc) { |
| @@ -171,13 +171,12 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) | |||
| 171 | 171 | ||
| 172 | static int msr_open(struct inode *inode, struct file *file) | 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 | struct cpuinfo_x86 *c; | 175 | struct cpuinfo_x86 *c; |
| 176 | 176 | ||
| 177 | if (!capable(CAP_SYS_RAWIO)) | 177 | if (!capable(CAP_SYS_RAWIO)) |
| 178 | return -EPERM; | 178 | return -EPERM; |
| 179 | 179 | ||
| 180 | cpu = iminor(file->f_path.dentry->d_inode); | ||
| 181 | if (cpu >= nr_cpu_ids || !cpu_online(cpu)) | 180 | if (cpu >= nr_cpu_ids || !cpu_online(cpu)) |
| 182 | return -ENXIO; /* No such CPU */ | 181 | return -ENXIO; /* No such CPU */ |
| 183 | 182 | ||
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 195d56d8a1ee..e336b281b847 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c | |||
| @@ -580,7 +580,7 @@ static int do_devinfo_ioctl(struct comedi_device *dev, | |||
| 580 | struct comedi_devinfo __user *arg, | 580 | struct comedi_devinfo __user *arg, |
| 581 | struct file *file) | 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 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); | 584 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); |
| 585 | struct comedi_subdevice *s; | 585 | struct comedi_subdevice *s; |
| 586 | struct comedi_devinfo devinfo; | 586 | struct comedi_devinfo devinfo; |
| @@ -1615,7 +1615,7 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, | |||
| 1615 | static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, | 1615 | static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, |
| 1616 | unsigned long arg) | 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 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); | 1619 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); |
| 1620 | struct comedi_device *dev = comedi_dev_from_file_info(info); | 1620 | struct comedi_device *dev = comedi_dev_from_file_info(info); |
| 1621 | int rc; | 1621 | int rc; |
| @@ -1743,7 +1743,7 @@ static struct vm_operations_struct comedi_vm_ops = { | |||
| 1743 | 1743 | ||
| 1744 | static int comedi_mmap(struct file *file, struct vm_area_struct *vma) | 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 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); | 1747 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); |
| 1748 | struct comedi_device *dev = comedi_dev_from_file_info(info); | 1748 | struct comedi_device *dev = comedi_dev_from_file_info(info); |
| 1749 | struct comedi_subdevice *s; | 1749 | struct comedi_subdevice *s; |
| @@ -1823,7 +1823,7 @@ done: | |||
| 1823 | static unsigned int comedi_poll(struct file *file, poll_table *wait) | 1823 | static unsigned int comedi_poll(struct file *file, poll_table *wait) |
| 1824 | { | 1824 | { |
| 1825 | unsigned int mask = 0; | 1825 | unsigned int mask = 0; |
| 1826 | const unsigned minor = iminor(file->f_dentry->d_inode); | 1826 | const unsigned minor = iminor(file_inode(file)); |
| 1827 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); | 1827 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); |
| 1828 | struct comedi_device *dev = comedi_dev_from_file_info(info); | 1828 | struct comedi_device *dev = comedi_dev_from_file_info(info); |
| 1829 | struct comedi_subdevice *s; | 1829 | struct comedi_subdevice *s; |
| @@ -1869,7 +1869,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, | |||
| 1869 | struct comedi_async *async; | 1869 | struct comedi_async *async; |
| 1870 | int n, m, count = 0, retval = 0; | 1870 | int n, m, count = 0, retval = 0; |
| 1871 | DECLARE_WAITQUEUE(wait, current); | 1871 | DECLARE_WAITQUEUE(wait, current); |
| 1872 | const unsigned minor = iminor(file->f_dentry->d_inode); | 1872 | const unsigned minor = iminor(file_inode(file)); |
| 1873 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); | 1873 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); |
| 1874 | struct comedi_device *dev = comedi_dev_from_file_info(info); | 1874 | struct comedi_device *dev = comedi_dev_from_file_info(info); |
| 1875 | 1875 | ||
| @@ -1964,7 +1964,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, | |||
| 1964 | struct comedi_async *async; | 1964 | struct comedi_async *async; |
| 1965 | int n, m, count = 0, retval = 0; | 1965 | int n, m, count = 0, retval = 0; |
| 1966 | DECLARE_WAITQUEUE(wait, current); | 1966 | DECLARE_WAITQUEUE(wait, current); |
| 1967 | const unsigned minor = iminor(file->f_dentry->d_inode); | 1967 | const unsigned minor = iminor(file_inode(file)); |
| 1968 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); | 1968 | struct comedi_file_info *info = comedi_file_info_from_minor(minor); |
| 1969 | struct comedi_device *dev = comedi_dev_from_file_info(info); | 1969 | struct comedi_device *dev = comedi_dev_from_file_info(info); |
| 1970 | 1970 | ||
| @@ -2133,7 +2133,7 @@ ok: | |||
| 2133 | 2133 | ||
| 2134 | static int comedi_fasync(int fd, struct file *file, int on) | 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 | struct comedi_device *dev = comedi_dev_from_minor(minor); | 2137 | struct comedi_device *dev = comedi_dev_from_minor(minor); |
| 2138 | 2138 | ||
| 2139 | if (!dev) | 2139 | if (!dev) |
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index fd473639ab70..05400acbc456 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
| @@ -960,11 +960,10 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count, | |||
| 960 | loff_t *ppos) | 960 | loff_t *ppos) |
| 961 | { | 961 | { |
| 962 | int i; | 962 | int i; |
| 963 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 964 | struct tty_struct *tty = file_tty(file); | 963 | struct tty_struct *tty = file_tty(file); |
| 965 | struct tty_ldisc *ld; | 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 | return -EIO; | 967 | return -EIO; |
| 969 | if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags))) | 968 | if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags))) |
| 970 | return -EIO; | 969 | return -EIO; |
| @@ -1132,12 +1131,11 @@ void tty_write_message(struct tty_struct *tty, char *msg) | |||
| 1132 | static ssize_t tty_write(struct file *file, const char __user *buf, | 1131 | static ssize_t tty_write(struct file *file, const char __user *buf, |
| 1133 | size_t count, loff_t *ppos) | 1132 | size_t count, loff_t *ppos) |
| 1134 | { | 1133 | { |
| 1135 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 1136 | struct tty_struct *tty = file_tty(file); | 1134 | struct tty_struct *tty = file_tty(file); |
| 1137 | struct tty_ldisc *ld; | 1135 | struct tty_ldisc *ld; |
| 1138 | ssize_t ret; | 1136 | ssize_t ret; |
| 1139 | 1137 | ||
| 1140 | if (tty_paranoia_check(tty, inode, "tty_write")) | 1138 | if (tty_paranoia_check(tty, file_inode(file), "tty_write")) |
| 1141 | return -EIO; | 1139 | return -EIO; |
| 1142 | if (!tty || !tty->ops->write || | 1140 | if (!tty || !tty->ops->write || |
| 1143 | (test_bit(TTY_IO_ERROR, &tty->flags))) | 1141 | (test_bit(TTY_IO_ERROR, &tty->flags))) |
| @@ -2047,7 +2045,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait) | |||
| 2047 | struct tty_ldisc *ld; | 2045 | struct tty_ldisc *ld; |
| 2048 | int ret = 0; | 2046 | int ret = 0; |
| 2049 | 2047 | ||
| 2050 | if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_poll")) | 2048 | if (tty_paranoia_check(tty, file_inode(filp), "tty_poll")) |
| 2051 | return 0; | 2049 | return 0; |
| 2052 | 2050 | ||
| 2053 | ld = tty_ldisc_ref_wait(tty); | 2051 | ld = tty_ldisc_ref_wait(tty); |
| @@ -2063,7 +2061,7 @@ static int __tty_fasync(int fd, struct file *filp, int on) | |||
| 2063 | unsigned long flags; | 2061 | unsigned long flags; |
| 2064 | int retval = 0; | 2062 | int retval = 0; |
| 2065 | 2063 | ||
| 2066 | if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync")) | 2064 | if (tty_paranoia_check(tty, file_inode(filp), "tty_fasync")) |
| 2067 | goto out; | 2065 | goto out; |
| 2068 | 2066 | ||
| 2069 | retval = fasync_helper(fd, filp, on, &tty->fasync); | 2067 | retval = fasync_helper(fd, filp, on, &tty->fasync); |
| @@ -2637,9 +2635,8 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 2637 | void __user *p = (void __user *)arg; | 2635 | void __user *p = (void __user *)arg; |
| 2638 | int retval; | 2636 | int retval; |
| 2639 | struct tty_ldisc *ld; | 2637 | struct tty_ldisc *ld; |
| 2640 | struct inode *inode = file->f_dentry->d_inode; | ||
| 2641 | 2638 | ||
| 2642 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | 2639 | if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) |
| 2643 | return -EINVAL; | 2640 | return -EINVAL; |
| 2644 | 2641 | ||
| 2645 | real_tty = tty_pair_get_tty(tty); | 2642 | real_tty = tty_pair_get_tty(tty); |
| @@ -2780,12 +2777,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 2780 | static long tty_compat_ioctl(struct file *file, unsigned int cmd, | 2777 | static long tty_compat_ioctl(struct file *file, unsigned int cmd, |
| 2781 | unsigned long arg) | 2778 | unsigned long arg) |
| 2782 | { | 2779 | { |
| 2783 | struct inode *inode = file->f_dentry->d_inode; | ||
| 2784 | struct tty_struct *tty = file_tty(file); | 2780 | struct tty_struct *tty = file_tty(file); |
| 2785 | struct tty_ldisc *ld; | 2781 | struct tty_ldisc *ld; |
| 2786 | int retval = -ENOIOCTLCMD; | 2782 | int retval = -ENOIOCTLCMD; |
| 2787 | 2783 | ||
| 2788 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | 2784 | if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl")) |
| 2789 | return -EINVAL; | 2785 | return -EINVAL; |
| 2790 | 2786 | ||
| 2791 | if (tty->ops->compat_ioctl) { | 2787 | if (tty->ops->compat_ioctl) { |
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index afd4724b2d92..d51ec9fafcc8 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
| @@ -41,29 +41,16 @@ | |||
| 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 | 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 | 48 | ||
| 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 | /** |
| @@ -76,23 +63,23 @@ int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) | |||
| 76 | 63 | ||
| 77 | static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) | 64 | static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) |
| 78 | { | 65 | { |
| 79 | struct v9fs_dentry *dent; | ||
| 80 | struct p9_fid *fid, *ret; | 66 | struct p9_fid *fid, *ret; |
| 81 | 67 | ||
| 82 | p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", | 68 | p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", |
| 83 | dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), | 69 | dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), |
| 84 | any); | 70 | any); |
| 85 | dent = (struct v9fs_dentry *) dentry->d_fsdata; | ||
| 86 | ret = NULL; | 71 | ret = NULL; |
| 87 | if (dent) { | 72 | /* we'll recheck under lock if there's anything to look in */ |
| 88 | spin_lock(&dent->lock); | 73 | if (dentry->d_fsdata) { |
| 89 | list_for_each_entry(fid, &dent->fidlist, dlist) { | 74 | struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata; |
| 75 | spin_lock(&dentry->d_lock); | ||
| 76 | hlist_for_each_entry(fid, h, dlist) { | ||
| 90 | if (any || uid_eq(fid->uid, uid)) { | 77 | if (any || uid_eq(fid->uid, uid)) { |
| 91 | ret = fid; | 78 | ret = fid; |
| 92 | break; | 79 | break; |
| 93 | } | 80 | } |
| 94 | } | 81 | } |
| 95 | spin_unlock(&dent->lock); | 82 | spin_unlock(&dentry->d_lock); |
| 96 | } | 83 | } |
| 97 | 84 | ||
| 98 | return ret; | 85 | return ret; |
| @@ -215,8 +202,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, | |||
| 215 | } | 202 | } |
| 216 | kfree(wnames); | 203 | kfree(wnames); |
| 217 | fid_out: | 204 | fid_out: |
| 218 | if (!IS_ERR(fid)) | 205 | if (!IS_ERR(fid)) { |
| 219 | v9fs_fid_add(dentry, fid); | 206 | spin_lock(&dentry->d_lock); |
| 207 | if (d_unhashed(dentry)) { | ||
| 208 | spin_unlock(&dentry->d_lock); | ||
| 209 | p9_client_clunk(fid); | ||
| 210 | fid = ERR_PTR(-ENOENT); | ||
| 211 | } else { | ||
| 212 | __add_fid(dentry, fid); | ||
| 213 | spin_unlock(&dentry->d_lock); | ||
| 214 | } | ||
| 215 | } | ||
| 220 | err_out: | 216 | err_out: |
| 221 | up_read(&v9ses->rename_sem); | 217 | up_read(&v9ses->rename_sem); |
| 222 | return fid; | 218 | return fid; |
diff --git a/fs/9p/fid.h b/fs/9p/fid.h index bb0b6e7f58fc..2b6787fcb626 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h | |||
| @@ -23,28 +23,8 @@ | |||
| 23 | #define FS_9P_FID_H | 23 | #define FS_9P_FID_H |
| 24 | #include <linux/list.h> | 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 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); | 26 | struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); |
| 47 | struct p9_fid *v9fs_fid_clone(struct dentry *dentry); | 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 | struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); | 29 | struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); |
| 50 | #endif | 30 | #endif |
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c index 9ad68628522c..f039b104a98e 100644 --- a/fs/9p/vfs_dentry.c +++ b/fs/9p/vfs_dentry.c | |||
| @@ -83,21 +83,12 @@ static int v9fs_cached_dentry_delete(const struct dentry *dentry) | |||
| 83 | 83 | ||
| 84 | static void v9fs_dentry_release(struct dentry *dentry) | 84 | static void v9fs_dentry_release(struct dentry *dentry) |
| 85 | { | 85 | { |
| 86 | struct v9fs_dentry *dent; | 86 | struct hlist_node *p, *n; |
| 87 | struct p9_fid *temp, *current_fid; | ||
| 88 | |||
| 89 | p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n", | 87 | p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n", |
| 90 | dentry->d_name.name, dentry); | 88 | dentry->d_name.name, dentry); |
| 91 | dent = dentry->d_fsdata; | 89 | hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata) |
| 92 | if (dent) { | 90 | p9_client_clunk(hlist_entry(p, struct p9_fid, dlist)); |
| 93 | list_for_each_entry_safe(current_fid, temp, &dent->fidlist, | 91 | dentry->d_fsdata = NULL; |
| 94 | dlist) { | ||
| 95 | p9_client_clunk(current_fid); | ||
| 96 | } | ||
| 97 | |||
| 98 | kfree(dent); | ||
| 99 | dentry->d_fsdata = NULL; | ||
| 100 | } | ||
| 101 | } | 92 | } |
| 102 | 93 | ||
| 103 | static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags) | 94 | static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags) |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index b5340c829de1..d86edc8d3fd0 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
| @@ -692,9 +692,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, | |||
| 692 | "inode creation failed %d\n", err); | 692 | "inode creation failed %d\n", err); |
| 693 | goto error; | 693 | goto error; |
| 694 | } | 694 | } |
| 695 | err = v9fs_fid_add(dentry, fid); | 695 | v9fs_fid_add(dentry, fid); |
| 696 | if (err < 0) | ||
| 697 | goto error; | ||
| 698 | d_instantiate(dentry, inode); | 696 | d_instantiate(dentry, inode); |
| 699 | } | 697 | } |
| 700 | return ofid; | 698 | return ofid; |
| @@ -790,7 +788,6 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
| 790 | struct p9_fid *dfid, *fid; | 788 | struct p9_fid *dfid, *fid; |
| 791 | struct inode *inode; | 789 | struct inode *inode; |
| 792 | char *name; | 790 | char *name; |
| 793 | int result = 0; | ||
| 794 | 791 | ||
| 795 | p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n", | 792 | p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n", |
| 796 | dir, dentry->d_name.name, dentry, flags); | 793 | dir, dentry->d_name.name, dentry, flags); |
| @@ -808,13 +805,11 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
| 808 | name = (char *) dentry->d_name.name; | 805 | name = (char *) dentry->d_name.name; |
| 809 | fid = p9_client_walk(dfid, 1, &name, 1); | 806 | fid = p9_client_walk(dfid, 1, &name, 1); |
| 810 | if (IS_ERR(fid)) { | 807 | if (IS_ERR(fid)) { |
| 811 | result = PTR_ERR(fid); | 808 | if (fid == ERR_PTR(-ENOENT)) { |
| 812 | if (result == -ENOENT) { | 809 | d_add(dentry, NULL); |
| 813 | inode = NULL; | 810 | return NULL; |
| 814 | goto inst_out; | ||
| 815 | } | 811 | } |
| 816 | 812 | return ERR_CAST(fid); | |
| 817 | return ERR_PTR(result); | ||
| 818 | } | 813 | } |
| 819 | /* | 814 | /* |
| 820 | * Make sure we don't use a wrong inode due to parallel | 815 | * Make sure we don't use a wrong inode due to parallel |
| @@ -826,14 +821,9 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
| 826 | else | 821 | else |
| 827 | inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); | 822 | inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); |
| 828 | if (IS_ERR(inode)) { | 823 | if (IS_ERR(inode)) { |
| 829 | result = PTR_ERR(inode); | 824 | p9_client_clunk(fid); |
| 830 | inode = NULL; | 825 | return ERR_CAST(inode); |
| 831 | goto error; | ||
| 832 | } | 826 | } |
| 833 | result = v9fs_fid_add(dentry, fid); | ||
| 834 | if (result < 0) | ||
| 835 | goto error_iput; | ||
| 836 | inst_out: | ||
| 837 | /* | 827 | /* |
| 838 | * If we had a rename on the server and a parallel lookup | 828 | * If we had a rename on the server and a parallel lookup |
| 839 | * for the new name, then make sure we instantiate with | 829 | * for the new name, then make sure we instantiate with |
| @@ -842,15 +832,13 @@ inst_out: | |||
| 842 | * k/b. | 832 | * k/b. |
| 843 | */ | 833 | */ |
| 844 | res = d_materialise_unique(dentry, inode); | 834 | res = d_materialise_unique(dentry, inode); |
| 845 | if (!IS_ERR(res)) | 835 | if (!res) |
| 846 | return res; | 836 | v9fs_fid_add(dentry, fid); |
| 847 | result = PTR_ERR(res); | 837 | else if (!IS_ERR(res)) |
| 848 | error_iput: | 838 | v9fs_fid_add(res, fid); |
| 849 | iput(inode); | 839 | else |
| 850 | error: | 840 | p9_client_clunk(fid); |
| 851 | p9_client_clunk(fid); | 841 | return res; |
| 852 | |||
| 853 | return ERR_PTR(result); | ||
| 854 | } | 842 | } |
| 855 | 843 | ||
| 856 | static int | 844 | static int |
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 61e4fa70a6fa..53687bbf2296 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c | |||
| @@ -333,9 +333,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, | |||
| 333 | /* Now set the ACL based on the default value */ | 333 | /* Now set the ACL based on the default value */ |
| 334 | v9fs_set_create_acl(inode, fid, dacl, pacl); | 334 | v9fs_set_create_acl(inode, fid, dacl, pacl); |
| 335 | 335 | ||
| 336 | err = v9fs_fid_add(dentry, fid); | 336 | v9fs_fid_add(dentry, fid); |
| 337 | if (err < 0) | ||
| 338 | goto error; | ||
| 339 | d_instantiate(dentry, inode); | 337 | d_instantiate(dentry, inode); |
| 340 | 338 | ||
| 341 | v9inode = V9FS_I(inode); | 339 | v9inode = V9FS_I(inode); |
| @@ -453,12 +451,11 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, | |||
| 453 | err); | 451 | err); |
| 454 | goto error; | 452 | goto error; |
| 455 | } | 453 | } |
| 456 | err = v9fs_fid_add(dentry, fid); | 454 | v9fs_fid_add(dentry, fid); |
| 457 | if (err < 0) | ||
| 458 | goto error; | ||
| 459 | v9fs_set_create_acl(inode, fid, dacl, pacl); | 455 | v9fs_set_create_acl(inode, fid, dacl, pacl); |
| 460 | d_instantiate(dentry, inode); | 456 | d_instantiate(dentry, inode); |
| 461 | fid = NULL; | 457 | fid = NULL; |
| 458 | err = 0; | ||
| 462 | } else { | 459 | } else { |
| 463 | /* | 460 | /* |
| 464 | * Not in cached mode. No need to populate | 461 | * Not in cached mode. No need to populate |
| @@ -747,11 +744,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry, | |||
| 747 | err); | 744 | err); |
| 748 | goto error; | 745 | goto error; |
| 749 | } | 746 | } |
| 750 | err = v9fs_fid_add(dentry, fid); | 747 | v9fs_fid_add(dentry, fid); |
| 751 | if (err < 0) | ||
| 752 | goto error; | ||
| 753 | d_instantiate(dentry, inode); | 748 | d_instantiate(dentry, inode); |
| 754 | fid = NULL; | 749 | fid = NULL; |
| 750 | err = 0; | ||
| 755 | } else { | 751 | } else { |
| 756 | /* Not in cached mode. No need to populate inode with stat */ | 752 | /* Not in cached mode. No need to populate inode with stat */ |
| 757 | inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); | 753 | inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); |
| @@ -900,11 +896,10 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode, | |||
| 900 | goto error; | 896 | goto error; |
| 901 | } | 897 | } |
| 902 | v9fs_set_create_acl(inode, fid, dacl, pacl); | 898 | v9fs_set_create_acl(inode, fid, dacl, pacl); |
| 903 | err = v9fs_fid_add(dentry, fid); | 899 | v9fs_fid_add(dentry, fid); |
| 904 | if (err < 0) | ||
| 905 | goto error; | ||
| 906 | d_instantiate(dentry, inode); | 900 | d_instantiate(dentry, inode); |
| 907 | fid = NULL; | 901 | fid = NULL; |
| 902 | err = 0; | ||
| 908 | } else { | 903 | } else { |
| 909 | /* | 904 | /* |
| 910 | * Not in cached mode. No need to populate inode with stat. | 905 | * Not in cached mode. No need to populate inode with stat. |
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c index c541ab8b64dd..b505a145a593 100644 --- a/fs/ext4/indirect.c +++ b/fs/ext4/indirect.c | |||
| @@ -1606,7 +1606,7 @@ err: | |||
| 1606 | 1606 | ||
| 1607 | int ext4_ind_punch_hole(struct file *file, loff_t offset, loff_t length) | 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 | struct super_block *sb = inode->i_sb; | 1610 | struct super_block *sb = inode->i_sb; |
| 1611 | ext4_lblk_t first_block, stop_block; | 1611 | ext4_lblk_t first_block, stop_block; |
| 1612 | struct address_space *mapping = inode->i_mapping; | 1612 | struct address_space *mapping = inode->i_mapping; |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index b7a053d4c6d3..958a46da19ae 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
| @@ -29,7 +29,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma, | |||
| 29 | struct vm_fault *vmf) | 29 | struct vm_fault *vmf) |
| 30 | { | 30 | { |
| 31 | struct page *page = vmf->page; | 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 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); | 33 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); |
| 34 | block_t old_blk_addr; | 34 | block_t old_blk_addr; |
| 35 | struct dnode_of_data dn; | 35 | struct dnode_of_data dn; |
| @@ -544,7 +544,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset, | |||
| 544 | static long f2fs_fallocate(struct file *file, int mode, | 544 | static long f2fs_fallocate(struct file *file, int mode, |
| 545 | loff_t offset, loff_t len) | 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 | long ret; | 548 | long ret; |
| 549 | 549 | ||
| 550 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) | 550 | if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) |
| @@ -577,7 +577,7 @@ static inline __u32 f2fs_mask_flags(umode_t mode, __u32 flags) | |||
| 577 | 577 | ||
| 578 | long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | 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 | struct f2fs_inode_info *fi = F2FS_I(inode); | 581 | struct f2fs_inode_info *fi = F2FS_I(inode); |
| 582 | unsigned int flags; | 582 | unsigned int flags; |
| 583 | int ret; | 583 | int ret; |
diff --git a/fs/file_table.c b/fs/file_table.c index aa07d3684a2e..cd4d87a82951 100644 --- a/fs/file_table.c +++ b/fs/file_table.c | |||
| @@ -176,6 +176,7 @@ struct file *alloc_file(struct path *path, fmode_t mode, | |||
| 176 | return file; | 176 | return file; |
| 177 | 177 | ||
| 178 | file->f_path = *path; | 178 | file->f_path = *path; |
| 179 | file->f_inode = path->dentry->d_inode; | ||
| 179 | file->f_mapping = path->dentry->d_inode->i_mapping; | 180 | file->f_mapping = path->dentry->d_inode->i_mapping; |
| 180 | file->f_mode = mode; | 181 | file->f_mode = mode; |
| 181 | file->f_op = fop; | 182 | file->f_op = fop; |
| @@ -258,6 +259,7 @@ static void __fput(struct file *file) | |||
| 258 | drop_file_write_access(file); | 259 | drop_file_write_access(file); |
| 259 | file->f_path.dentry = NULL; | 260 | file->f_path.dentry = NULL; |
| 260 | file->f_path.mnt = NULL; | 261 | file->f_path.mnt = NULL; |
| 262 | file->f_inode = NULL; | ||
| 261 | file_free(file); | 263 | file_free(file); |
| 262 | dput(dentry); | 264 | dput(dentry); |
| 263 | mntput(mnt); | 265 | mntput(mnt); |
diff --git a/fs/fs_struct.c b/fs/fs_struct.c index fe6ca583bbc0..d8ac61d0c932 100644 --- a/fs/fs_struct.c +++ b/fs/fs_struct.c | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. | 10 | * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. |
| 11 | * It can block. | 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 | struct path old_root; | 15 | struct path old_root; |
| 16 | 16 | ||
| @@ -29,7 +29,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path) | |||
| 29 | * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. | 29 | * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. |
| 30 | * It can block. | 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 | struct path old_pwd; | 34 | struct path old_pwd; |
| 35 | 35 | ||
| @@ -53,7 +53,7 @@ static inline int replace_path(struct path *p, const struct path *old, const str | |||
| 53 | return 1; | 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 | struct task_struct *g, *p; | 58 | struct task_struct *g, *p; |
| 59 | struct fs_struct *fs; | 59 | struct fs_struct *fs; |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index e9bdec0b16d9..11dfa0c3fb46 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
| @@ -532,7 +532,7 @@ void fuse_request_send_background_locked(struct fuse_conn *fc, | |||
| 532 | 532 | ||
| 533 | void fuse_force_forget(struct file *file, u64 nodeid) | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 536 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 537 | struct fuse_req *req; | 537 | struct fuse_req *req; |
| 538 | struct fuse_forget_in inarg; | 538 | struct fuse_forget_in inarg; |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index c8071768b950..34b80ba95bad 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
| @@ -355,7 +355,7 @@ static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index) | |||
| 355 | 355 | ||
| 356 | static int fuse_flush(struct file *file, fl_owner_t id) | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 359 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 360 | struct fuse_file *ff = file->private_data; | 360 | struct fuse_file *ff = file->private_data; |
| 361 | struct fuse_req *req; | 361 | struct fuse_req *req; |
| @@ -1215,7 +1215,7 @@ static ssize_t __fuse_direct_read(struct file *file, const struct iovec *iov, | |||
| 1215 | unsigned long nr_segs, loff_t *ppos) | 1215 | unsigned long nr_segs, loff_t *ppos) |
| 1216 | { | 1216 | { |
| 1217 | ssize_t res; | 1217 | ssize_t res; |
| 1218 | struct inode *inode = file->f_path.dentry->d_inode; | 1218 | struct inode *inode = file_inode(file); |
| 1219 | 1219 | ||
| 1220 | if (is_bad_inode(inode)) | 1220 | if (is_bad_inode(inode)) |
| 1221 | return -EIO; | 1221 | return -EIO; |
| @@ -1238,7 +1238,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf, | |||
| 1238 | static ssize_t __fuse_direct_write(struct file *file, const struct iovec *iov, | 1238 | static ssize_t __fuse_direct_write(struct file *file, const struct iovec *iov, |
| 1239 | unsigned long nr_segs, loff_t *ppos) | 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 | size_t count = iov_length(iov, nr_segs); | 1242 | size_t count = iov_length(iov, nr_segs); |
| 1243 | ssize_t res; | 1243 | ssize_t res; |
| 1244 | 1244 | ||
| @@ -1258,7 +1258,7 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf, | |||
| 1258 | size_t count, loff_t *ppos) | 1258 | size_t count, loff_t *ppos) |
| 1259 | { | 1259 | { |
| 1260 | struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count }; | 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 | ssize_t res; | 1262 | ssize_t res; |
| 1263 | 1263 | ||
| 1264 | if (is_bad_inode(inode)) | 1264 | if (is_bad_inode(inode)) |
| @@ -1485,7 +1485,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = { | |||
| 1485 | static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) | 1485 | static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) |
| 1486 | { | 1486 | { |
| 1487 | if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) { | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 1489 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 1490 | struct fuse_inode *fi = get_fuse_inode(inode); | 1490 | struct fuse_inode *fi = get_fuse_inode(inode); |
| 1491 | struct fuse_file *ff = file->private_data; | 1491 | struct fuse_file *ff = file->private_data; |
| @@ -1543,7 +1543,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file, | |||
| 1543 | const struct file_lock *fl, int opcode, pid_t pid, | 1543 | const struct file_lock *fl, int opcode, pid_t pid, |
| 1544 | int flock) | 1544 | int flock) |
| 1545 | { | 1545 | { |
| 1546 | struct inode *inode = file->f_path.dentry->d_inode; | 1546 | struct inode *inode = file_inode(file); |
| 1547 | struct fuse_conn *fc = get_fuse_conn(inode); | 1547 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 1548 | struct fuse_file *ff = file->private_data; | 1548 | struct fuse_file *ff = file->private_data; |
| 1549 | struct fuse_lk_in *arg = &req->misc.lk_in; | 1549 | struct fuse_lk_in *arg = &req->misc.lk_in; |
| @@ -1565,7 +1565,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file, | |||
| 1565 | 1565 | ||
| 1566 | static int fuse_getlk(struct file *file, struct file_lock *fl) | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 1569 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 1570 | struct fuse_req *req; | 1570 | struct fuse_req *req; |
| 1571 | struct fuse_lk_out outarg; | 1571 | struct fuse_lk_out outarg; |
| @@ -1590,7 +1590,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl) | |||
| 1590 | 1590 | ||
| 1591 | static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 1594 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 1595 | struct fuse_req *req; | 1595 | struct fuse_req *req; |
| 1596 | int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; | 1596 | int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; |
| @@ -1622,7 +1622,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) | |||
| 1622 | 1622 | ||
| 1623 | static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 1626 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 1627 | int err; | 1627 | int err; |
| 1628 | 1628 | ||
| @@ -1645,7 +1645,7 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) | |||
| 1645 | 1645 | ||
| 1646 | static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 1649 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 1650 | int err; | 1650 | int err; |
| 1651 | 1651 | ||
| @@ -1702,7 +1702,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) | |||
| 1702 | static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence) | 1702 | static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence) |
| 1703 | { | 1703 | { |
| 1704 | loff_t retval; | 1704 | loff_t retval; |
| 1705 | struct inode *inode = file->f_path.dentry->d_inode; | 1705 | struct inode *inode = file_inode(file); |
| 1706 | 1706 | ||
| 1707 | /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */ | 1707 | /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */ |
| 1708 | if (whence == SEEK_CUR || whence == SEEK_SET) | 1708 | if (whence == SEEK_CUR || whence == SEEK_SET) |
| @@ -2079,7 +2079,7 @@ EXPORT_SYMBOL_GPL(fuse_do_ioctl); | |||
| 2079 | long fuse_ioctl_common(struct file *file, unsigned int cmd, | 2079 | long fuse_ioctl_common(struct file *file, unsigned int cmd, |
| 2080 | unsigned long arg, unsigned int flags) | 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 | struct fuse_conn *fc = get_fuse_conn(inode); | 2083 | struct fuse_conn *fc = get_fuse_conn(inode); |
| 2084 | 2084 | ||
| 2085 | if (!fuse_allow_current_process(fc)) | 2085 | if (!fuse_allow_current_process(fc)) |
diff --git a/fs/internal.h b/fs/internal.h index 2f6af7f645eb..507141fceb99 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
| @@ -69,7 +69,7 @@ extern void __mnt_drop_write_file(struct file *); | |||
| 69 | /* | 69 | /* |
| 70 | * fs_struct.c | 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 | * file_table.c | 75 | * file_table.c |
diff --git a/fs/namei.c b/fs/namei.c index dc984fee5532..961bc1268366 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
| @@ -451,7 +451,7 @@ int inode_permission(struct inode *inode, int mask) | |||
| 451 | * | 451 | * |
| 452 | * Given a path increment the reference count to the dentry and the vfsmount. | 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 | mntget(path->mnt); | 456 | mntget(path->mnt); |
| 457 | dget(path->dentry); | 457 | dget(path->dentry); |
| @@ -464,7 +464,7 @@ EXPORT_SYMBOL(path_get); | |||
| 464 | * | 464 | * |
| 465 | * Given a path decrement the reference count to the dentry and the vfsmount. | 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 | dput(path->dentry); | 469 | dput(path->dentry); |
| 470 | mntput(path->mnt); | 470 | mntput(path->mnt); |
| @@ -704,7 +704,7 @@ static int do_dentry_open(struct file *f, | |||
| 704 | f->f_mode = FMODE_PATH; | 704 | f->f_mode = FMODE_PATH; |
| 705 | 705 | ||
| 706 | path_get(&f->f_path); | 706 | path_get(&f->f_path); |
| 707 | inode = file_inode(f); | 707 | inode = f->f_inode = f->f_path.dentry->d_inode; |
| 708 | if (f->f_mode & FMODE_WRITE) { | 708 | if (f->f_mode & FMODE_WRITE) { |
| 709 | error = __get_file_write_access(inode, f->f_path.mnt); | 709 | error = __get_file_write_access(inode, f->f_path.mnt); |
| 710 | if (error) | 710 | if (error) |
| @@ -767,6 +767,7 @@ cleanup_file: | |||
| 767 | path_put(&f->f_path); | 767 | path_put(&f->f_path); |
| 768 | f->f_path.mnt = NULL; | 768 | f->f_path.mnt = NULL; |
| 769 | f->f_path.dentry = NULL; | 769 | f->f_path.dentry = NULL; |
| 770 | f->f_inode = NULL; | ||
| 770 | return error; | 771 | return error; |
| 771 | } | 772 | } |
| 772 | 773 | ||
diff --git a/fs/seq_file.c b/fs/seq_file.c index 15c6304bab71..38bb59f3f2ad 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c | |||
| @@ -339,7 +339,7 @@ EXPORT_SYMBOL(seq_lseek); | |||
| 339 | /** | 339 | /** |
| 340 | * seq_release - free the structures associated with sequential file. | 340 | * seq_release - free the structures associated with sequential file. |
| 341 | * @file: file in question | 341 | * @file: file in question |
| 342 | * @inode: file->f_path.dentry->d_inode | 342 | * @inode: its inode |
| 343 | * | 343 | * |
| 344 | * Frees the structures associated with sequential file; can be used | 344 | * Frees the structures associated with sequential file; can be used |
| 345 | * as ->f_op->release() if you don't have private data to destroy. | 345 | * as ->f_op->release() if you don't have private data to destroy. |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 4e686a099465..74a907b8b950 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
| @@ -769,6 +769,7 @@ struct file { | |||
| 769 | } f_u; | 769 | } f_u; |
| 770 | struct path f_path; | 770 | struct path f_path; |
| 771 | #define f_dentry f_path.dentry | 771 | #define f_dentry f_path.dentry |
| 772 | struct inode *f_inode; /* cached value */ | ||
| 772 | const struct file_operations *f_op; | 773 | const struct file_operations *f_op; |
| 773 | 774 | ||
| 774 | /* | 775 | /* |
| @@ -2217,7 +2218,7 @@ static inline bool execute_ok(struct inode *inode) | |||
| 2217 | 2218 | ||
| 2218 | static inline struct inode *file_inode(struct file *f) | 2219 | static inline struct inode *file_inode(struct file *f) |
| 2219 | { | 2220 | { |
| 2220 | return f->f_path.dentry->d_inode; | 2221 | return f->f_inode; |
| 2221 | } | 2222 | } |
| 2222 | 2223 | ||
| 2223 | /* | 2224 | /* |
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h index d0ae3a84bcfb..729eded4b24f 100644 --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h | |||
| @@ -17,8 +17,8 @@ struct fs_struct { | |||
| 17 | extern struct kmem_cache *fs_cachep; | 17 | extern struct kmem_cache *fs_cachep; |
| 18 | 18 | ||
| 19 | extern void exit_fs(struct task_struct *); | 19 | extern void exit_fs(struct task_struct *); |
| 20 | extern void set_fs_root(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 *, struct path *); | 21 | extern void set_fs_pwd(struct fs_struct *, const struct path *); |
| 22 | extern struct fs_struct *copy_fs_struct(struct fs_struct *); | 22 | extern struct fs_struct *copy_fs_struct(struct fs_struct *); |
| 23 | extern void free_fs_struct(struct fs_struct *); | 23 | extern void free_fs_struct(struct fs_struct *); |
| 24 | extern int unshare_fs_struct(void); | 24 | extern int unshare_fs_struct(void); |
diff --git a/include/linux/path.h b/include/linux/path.h index edc98dec6266..d1372186f431 100644 --- a/include/linux/path.h +++ b/include/linux/path.h | |||
| @@ -9,8 +9,8 @@ struct path { | |||
| 9 | struct dentry *dentry; | 9 | struct dentry *dentry; |
| 10 | }; | 10 | }; |
| 11 | 11 | ||
| 12 | extern void path_get(struct path *); | 12 | extern void path_get(const struct path *); |
| 13 | extern void path_put(struct path *); | 13 | extern void path_put(const struct path *); |
| 14 | 14 | ||
| 15 | static inline int path_equal(const struct path *path1, const struct path *path2) | 15 | static inline int path_equal(const struct path *path1, const struct path *path2) |
| 16 | { | 16 | { |
diff --git a/include/net/9p/client.h b/include/net/9p/client.h index 5ff70f433e87..4c7c01a73911 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h | |||
| @@ -192,7 +192,7 @@ struct p9_fid { | |||
| 192 | void *rdir; | 192 | void *rdir; |
| 193 | 193 | ||
| 194 | struct list_head flist; | 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 | /** |
diff --git a/kernel/futex.c b/kernel/futex.c index fbc07a29ec53..f0090a993dab 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
| @@ -226,7 +226,7 @@ static void drop_futex_key_refs(union futex_key *key) | |||
| 226 | * Returns a negative error code or 0 | 226 | * Returns a negative error code or 0 |
| 227 | * The key words are stored in *key on success. | 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 | * offset_within_page). For private mappings, it's (uaddr, current->mm). | 230 | * offset_within_page). For private mappings, it's (uaddr, current->mm). |
| 231 | * We can usually work out the index without swapping in the page. | 231 | * We can usually work out the index without swapping in the page. |
| 232 | * | 232 | * |
diff --git a/mm/shmem.c b/mm/shmem.c index ed2befb4952e..1c44af71fcf5 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
| @@ -2932,9 +2932,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
| 2932 | inode->i_size = size; | 2932 | inode->i_size = size; |
| 2933 | clear_nlink(inode); /* It is unlinked */ | 2933 | clear_nlink(inode); /* It is unlinked */ |
| 2934 | #ifndef CONFIG_MMU | 2934 | #ifndef CONFIG_MMU |
| 2935 | error = ramfs_nommu_expand_for_mapping(inode, size); | 2935 | res = ERR_PTR(ramfs_nommu_expand_for_mapping(inode, size)); |
| 2936 | res = ERR_PTR(error); | 2936 | if (IS_ERR(res)) |
| 2937 | if (error) | ||
| 2938 | goto put_dentry; | 2937 | goto put_dentry; |
| 2939 | #endif | 2938 | #endif |
| 2940 | 2939 | ||
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 84b591711eec..2fa28c88900c 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
| @@ -3135,11 +3135,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, | |||
| 3135 | 3135 | ||
| 3136 | switch (cmd) { | 3136 | switch (cmd) { |
| 3137 | case F_SETFL: | 3137 | case F_SETFL: |
| 3138 | if (!file->f_path.dentry || !file->f_path.dentry->d_inode) { | ||
| 3139 | err = -EINVAL; | ||
| 3140 | break; | ||
| 3141 | } | ||
| 3142 | |||
| 3143 | if ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) { | 3138 | if ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) { |
| 3144 | err = file_has_perm(cred, file, FILE__WRITE); | 3139 | err = file_has_perm(cred, file, FILE__WRITE); |
| 3145 | break; | 3140 | break; |
| @@ -3162,10 +3157,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, | |||
| 3162 | case F_SETLK64: | 3157 | case F_SETLK64: |
| 3163 | case F_SETLKW64: | 3158 | case F_SETLKW64: |
| 3164 | #endif | 3159 | #endif |
| 3165 | if (!file->f_path.dentry || !file->f_path.dentry->d_inode) { | ||
| 3166 | err = -EINVAL; | ||
| 3167 | break; | ||
| 3168 | } | ||
| 3169 | err = file_has_perm(cred, file, FILE__LOCK); | 3160 | err = file_has_perm(cred, file, FILE__LOCK); |
| 3170 | break; | 3161 | break; |
| 3171 | } | 3162 | } |
