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)
Unified · Split
| @@ -171,12 +171,10 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, · 170 unmodified lines | ||
| 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 |
| @@ -71,7 +71,7 @@ static ssize_t msr_read(struct file *file, char __user *buf, · 70 unmodified lines | ||
| 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,7 +99,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf, · 21 unmodified lines | ||
| 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,7 +125,7 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) · 19 unmodified lines | ||
| 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,13 +171,12 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) · 39 unmodified lines | ||
| 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 | |
| @@ -580,7 +580,7 @@ static int do_devinfo_ioctl(struct comedi_device *dev, · 579 unmodified lines | ||
| 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,7 +1615,7 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, · 1028 unmodified lines | ||
| 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,7 +1743,7 @@ static struct vm_operations_struct comedi_vm_ops = { · 121 unmodified lines | ||
| 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,7 +1823,7 @@ done: · 73 unmodified lines | ||
| 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,7 +1869,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, · 39 unmodified lines | ||
| 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,7 +1964,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, · 88 unmodified lines | ||
| 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,7 +2133,7 @@ ok: · 162 unmodified lines | ||
| 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) |
| @@ -960,11 +960,10 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count, · 959 unmodified lines | ||
| 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; |
| @@ -1132,12 +1131,11 @@ void tty_write_message(struct tty_struct *tty, char *msg) · 161 unmodified lines | ||
| 1132 | 1131 | static ssize_t tty_write(struct file *file, const char __user *buf, |
| 1133 | 1132 | size_t count, loff_t *ppos) |
| 1134 | 1133 | { |
| 1135 | − struct inode *inode = file->f_path.dentry->d_inode; | |
| 1136 | 1134 | struct tty_struct *tty = file_tty(file); |
| 1137 | 1135 | struct tty_ldisc *ld; |
| 1138 | 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 | 1139 | return -EIO; |
| 1142 | 1140 | if (!tty || !tty->ops->write || |
| 1143 | 1141 | (test_bit(TTY_IO_ERROR, &tty->flags))) |
| @@ -2047,7 +2045,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait) · 903 unmodified lines | ||
| 2047 | 2045 | struct tty_ldisc *ld; |
| 2048 | 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 | 2049 | return 0; |
| 2052 | 2050 | |
| 2053 | 2051 | ld = tty_ldisc_ref_wait(tty); |
| @@ -2063,7 +2061,7 @@ static int __tty_fasync(int fd, struct file *filp, int on) · 9 unmodified lines | ||
| 2063 | 2061 | unsigned long flags; |
| 2064 | 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 | 2065 | goto out; |
| 2068 | 2066 | |
| 2069 | 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) · 567 unmodified lines | ||
| 2637 | 2635 | void __user *p = (void __user *)arg; |
| 2638 | 2636 | int retval; |
| 2639 | 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 | 2640 | return -EINVAL; |
| 2644 | 2641 | |
| 2645 | 2642 | real_tty = tty_pair_get_tty(tty); |
| @@ -2780,12 +2777,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 134 unmodified lines | ||
| 2780 | 2777 | static long tty_compat_ioctl(struct file *file, unsigned int cmd, |
| 2781 | 2778 | unsigned long arg) |
| 2782 | 2779 | { |
| 2783 | − struct inode *inode = file->f_dentry->d_inode; | |
| 2784 | 2780 | struct tty_struct *tty = file_tty(file); |
| 2785 | 2781 | struct tty_ldisc *ld; |
| 2786 | 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 | 2785 | return -EINVAL; |
| 2790 | 2786 | |
| 2791 | 2787 | if (tty->ops->compat_ioctl) { |
| @@ -41,29 +41,16 @@ · 40 unmodified lines | ||
| 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; | |
| 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); | |
| 46 | + hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata); | |
| 47 | +} | |
| 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) · 6 unmodified lines | ||
| 76 | 63 | |
| 77 | 64 | static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) |
| 78 | 65 | { |
| 79 | − struct v9fs_dentry *dent; | |
| 80 | 66 | struct p9_fid *fid, *ret; |
| 81 | 67 | |
| 82 | 68 | p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", |
| 83 | 69 | dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), |
| 84 | 70 | any); |
| 85 | − dent = (struct v9fs_dentry *) dentry->d_fsdata; | |
| 86 | 71 | ret = NULL; |
| 87 | − if (dent) { | |
| 88 | − spin_lock(&dent->lock); | |
| 89 | − list_for_each_entry(fid, &dent->fidlist, dlist) { | |
| 72 | + /* we'll recheck under lock if there's anything to look in */ | |
| 73 | + if (dentry->d_fsdata) { | |
| 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 | 77 | if (any || uid_eq(fid->uid, uid)) { |
| 91 | 78 | ret = fid; |
| 92 | 79 | break; |
| 93 | 80 | } |
| 94 | 81 | } |
| 95 | − spin_unlock(&dent->lock); | |
| 82 | + spin_unlock(&dentry->d_lock); | |
| 96 | 83 | } |
| 97 | 84 | |
| 98 | 85 | return ret; |
| @@ -215,8 +202,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, · 116 unmodified lines | ||
| 215 | 202 | } |
| 216 | 203 | kfree(wnames); |
| 217 | 204 | fid_out: |
| 218 | − if (!IS_ERR(fid)) | |
| 219 | − v9fs_fid_add(dentry, fid); | |
| 205 | + if (!IS_ERR(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 | 216 | err_out: |
| 221 | 217 | up_read(&v9ses->rename_sem); |
| 222 | 218 | return fid; |
| @@ -23,28 +23,8 @@ · 22 unmodified lines | ||
| 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 |
| @@ -83,21 +83,12 @@ static int v9fs_cached_dentry_delete(const struct dentry *dentry) · 82 unmodified lines | ||
| 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) |
| @@ -692,9 +692,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, · 691 unmodified lines | ||
| 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; |
| @@ -790,7 +788,6 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, · 89 unmodified lines | ||
| 790 | 788 | struct p9_fid *dfid, *fid; |
| 791 | 789 | struct inode *inode; |
| 792 | 790 | char *name; |
| 793 | − int result = 0; | |
| 794 | 791 | |
| 795 | 792 | p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n", |
| 796 | 793 | dir, dentry->d_name.name, dentry, flags); |
| @@ -808,13 +805,11 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, · 11 unmodified lines | ||
| 808 | 805 | name = (char *) dentry->d_name.name; |
| 809 | 806 | fid = p9_client_walk(dfid, 1, &name, 1); |
| 810 | 807 | if (IS_ERR(fid)) { |
| 811 | − result = PTR_ERR(fid); | |
| 812 | − if (result == -ENOENT) { | |
| 813 | − inode = NULL; | |
| 814 | − goto inst_out; | |
| 808 | + if (fid == ERR_PTR(-ENOENT)) { | |
| 809 | + d_add(dentry, NULL); | |
| 810 | + return NULL; | |
| 815 | 811 | } |
| 816 | − | |
| 817 | − return ERR_PTR(result); | |
| 812 | + return ERR_CAST(fid); | |
| 818 | 813 | } |
| 819 | 814 | /* |
| 820 | 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, · 5 unmodified lines | ||
| 826 | 821 | else |
| 827 | 822 | inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); |
| 828 | 823 | if (IS_ERR(inode)) { |
| 829 | − result = PTR_ERR(inode); | |
| 830 | − inode = NULL; | |
| 831 | − goto error; | |
| 824 | + p9_client_clunk(fid); | |
| 825 | + return ERR_CAST(inode); | |
| 832 | 826 | } |
| 833 | − result = v9fs_fid_add(dentry, fid); | |
| 834 | − if (result < 0) | |
| 835 | − goto error_iput; | |
| 836 | −inst_out: | |
| 837 | 827 | /* |
| 838 | 828 | * If we had a rename on the server and a parallel lookup |
| 839 | 829 | * for the new name, then make sure we instantiate with |
| @@ -842,15 +832,13 @@ inst_out: · 2 unmodified lines | ||
| 842 | 832 | * k/b. |
| 843 | 833 | */ |
| 844 | 834 | res = d_materialise_unique(dentry, inode); |
| 845 | − if (!IS_ERR(res)) | |
| 846 | − return res; | |
| 847 | − result = PTR_ERR(res); | |
| 848 | −error_iput: | |
| 849 | − iput(inode); | |
| 850 | −error: | |
| 851 | − p9_client_clunk(fid); | |
| 852 | − | |
| 853 | − return ERR_PTR(result); | |
| 835 | + if (!res) | |
| 836 | + v9fs_fid_add(dentry, fid); | |
| 837 | + else if (!IS_ERR(res)) | |
| 838 | + v9fs_fid_add(res, fid); | |
| 839 | + else | |
| 840 | + p9_client_clunk(fid); | |
| 841 | + return res; | |
| 854 | 842 | } |
| 855 | 843 | |
| 856 | 844 | static int |
| @@ -333,9 +333,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, · 332 unmodified lines | ||
| 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); |
| @@ -453,12 +451,11 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, · 111 unmodified lines | ||
| 453 | 451 | err); |
| 454 | 452 | goto error; |
| 455 | 453 | } |
| 456 | − err = v9fs_fid_add(dentry, fid); | |
| 457 | − if (err < 0) | |
| 458 | − goto error; | |
| 454 | + v9fs_fid_add(dentry, fid); | |
| 459 | 455 | v9fs_set_create_acl(inode, fid, dacl, pacl); |
| 460 | 456 | d_instantiate(dentry, inode); |
| 461 | 457 | fid = NULL; |
| 458 | + err = 0; | |
| 462 | 459 | } else { |
| 463 | 460 | /* |
| 464 | 461 | * Not in cached mode. No need to populate |
| @@ -747,11 +744,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry, · 282 unmodified lines | ||
| 747 | 744 | err); |
| 748 | 745 | goto error; |
| 749 | 746 | } |
| 750 | − err = v9fs_fid_add(dentry, fid); | |
| 751 | − if (err < 0) | |
| 752 | − goto error; | |
| 747 | + v9fs_fid_add(dentry, fid); | |
| 753 | 748 | d_instantiate(dentry, inode); |
| 754 | 749 | fid = NULL; |
| 750 | + err = 0; | |
| 755 | 751 | } else { |
| 756 | 752 | /* Not in cached mode. No need to populate inode with stat */ |
| 757 | 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, · 142 unmodified lines | ||
| 900 | 896 | goto error; |
| 901 | 897 | } |
| 902 | 898 | v9fs_set_create_acl(inode, fid, dacl, pacl); |
| 903 | − err = v9fs_fid_add(dentry, fid); | |
| 904 | − if (err < 0) | |
| 905 | − goto error; | |
| 899 | + v9fs_fid_add(dentry, fid); | |
| 906 | 900 | d_instantiate(dentry, inode); |
| 907 | 901 | fid = NULL; |
| 902 | + err = 0; | |
| 908 | 903 | } else { |
| 909 | 904 | /* |
| 910 | 905 | * Not in cached mode. No need to populate inode with stat. |
| @@ -1606,7 +1606,7 @@ err: · 1605 unmodified lines | ||
| 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; |
| @@ -29,7 +29,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma, · 28 unmodified lines | ||
| 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,7 +544,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset, · 508 unmodified lines | ||
| 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,7 +577,7 @@ static inline __u32 f2fs_mask_flags(umode_t mode, __u32 flags) · 26 unmodified lines | ||
| 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; |
| @@ -176,6 +176,7 @@ struct file *alloc_file(struct path *path, fmode_t mode, · 175 unmodified lines | ||
| 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; |
| @@ -258,6 +259,7 @@ static void __fput(struct file *file) · 76 unmodified lines | ||
| 258 | 259 | drop_file_write_access(file); |
| 259 | 260 | file->f_path.dentry = NULL; |
| 260 | 261 | file->f_path.mnt = NULL; |
| 262 | + file->f_inode = NULL; | |
| 261 | 263 | file_free(file); |
| 262 | 264 | dput(dentry); |
| 263 | 265 | mntput(mnt); |
| @@ -10,7 +10,7 @@ · 9 unmodified lines | ||
| 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,7 +29,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path) · 12 unmodified lines | ||
| 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,7 +53,7 @@ static inline int replace_path(struct path *p, const struct path *old, const str · 17 unmodified lines | ||
| 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; |
| @@ -532,7 +532,7 @@ void fuse_request_send_background_locked(struct fuse_conn *fc, · 531 unmodified lines | ||
| 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; |
| @@ -355,7 +355,7 @@ static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index) · 354 unmodified lines | ||
| 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,7 +1215,7 @@ static ssize_t __fuse_direct_read(struct file *file, const struct iovec *iov, · 853 unmodified lines | ||
| 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,7 +1238,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf, · 16 unmodified lines | ||
| 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,7 +1258,7 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf, · 13 unmodified lines | ||
| 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,7 +1485,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = { · 220 unmodified lines | ||
| 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,7 +1543,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file, · 51 unmodified lines | ||
| 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,7 +1565,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file, · 15 unmodified lines | ||
| 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,7 +1590,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl) · 18 unmodified lines | ||
| 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,7 +1622,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) · 25 unmodified lines | ||
| 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,7 +1645,7 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) · 16 unmodified lines | ||
| 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,7 +1702,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) · 50 unmodified lines | ||
| 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,7 +2079,7 @@ EXPORT_SYMBOL_GPL(fuse_do_ioctl); · 370 unmodified lines | ||
| 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)) |
| @@ -69,7 +69,7 @@ extern void __mnt_drop_write_file(struct file *); · 68 unmodified lines | ||
| 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 |
| @@ -451,7 +451,7 @@ int inode_permission(struct inode *inode, int mask) · 450 unmodified lines | ||
| 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,7 +464,7 @@ EXPORT_SYMBOL(path_get); · 6 unmodified lines | ||
| 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); |
| @@ -704,7 +704,7 @@ static int do_dentry_open(struct file *f, · 703 unmodified lines | ||
| 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,6 +767,7 @@ cleanup_file: · 56 unmodified lines | ||
| 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 | |
| @@ -339,7 +339,7 @@ EXPORT_SYMBOL(seq_lseek); · 338 unmodified lines | ||
| 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. |
| @@ -769,6 +769,7 @@ struct file { · 768 unmodified lines | ||
| 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 | /* |
| @@ -2217,7 +2218,7 @@ static inline bool execute_ok(struct inode *inode) · 1442 unmodified lines | ||
| 2217 | 2218 | |
| 2218 | 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 | /* |
| @@ -17,8 +17,8 @@ struct fs_struct { · 16 unmodified lines | ||
| 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); |
| @@ -9,8 +9,8 @@ struct path { · 8 unmodified lines | ||
| 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 | { |
| @@ -192,7 +192,7 @@ struct p9_fid { · 191 unmodified lines | ||
| 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 | /** |
| @@ -226,7 +226,7 @@ static void drop_futex_key_refs(union futex_key *key) · 225 unmodified lines | ||
| 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 | * |
| @@ -2932,9 +2932,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags · 2931 unmodified lines | ||
| 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 | |
| @@ -3135,11 +3135,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, · 3134 unmodified lines | ||
| 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; |
| @@ -3162,10 +3157,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, · 16 unmodified lines | ||
| 3162 | 3157 | case F_SETLK64: |
| 3163 | 3158 | case F_SETLKW64: |
| 3164 | 3159 | #endif |
| 3165 | − if (!file->f_path.dentry || !file->f_path.dentry->d_inode) { | |
| 3166 | − err = -EINVAL; | |
| 3167 | − break; | |
| 3168 | − } | |
| 3169 | 3160 | err = file_has_perm(cred, file, FILE__LOCK); |
| 3170 | 3161 | break; |
| 3171 | 3162 | } |