Commit 56a79b7b authored by Linus Torvalds's avatar Linus Torvalds

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

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

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

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

(In the meantime, the hlist traversal macros have changed, so this
required a semantic conflict fixup for the newly hlistified fid->dlist)
parents 1c82315a dcf787f3
...@@ -171,12 +171,10 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -171,12 +171,10 @@ static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t offset) unsigned long nr_segs, loff_t offset)
{ {
int rc; int rc;
struct super_block *sb; struct super_block *sb = file_inode(iocb->ki_filp)->i_sb;
struct hypfs_sb_info *fs_info; struct hypfs_sb_info *fs_info = sb->s_fs_info;
size_t count = iov_length(iov, nr_segs); size_t count = iov_length(iov, nr_segs);
sb = iocb->ki_filp->f_path.dentry->d_inode->i_sb;
fs_info = sb->s_fs_info;
/* /*
* Currently we only allow one update per second for two reasons: * Currently we only allow one update per second for two reasons:
* 1. diag 204 is VERY expensive * 1. diag 204 is VERY expensive
......
...@@ -71,7 +71,7 @@ static ssize_t msr_read(struct file *file, char __user *buf, ...@@ -71,7 +71,7 @@ static ssize_t msr_read(struct file *file, char __user *buf,
u32 __user *tmp = (u32 __user *) buf; u32 __user *tmp = (u32 __user *) buf;
u32 data[2]; u32 data[2];
u32 reg = *ppos; u32 reg = *ppos;
int cpu = iminor(file->f_path.dentry->d_inode); int cpu = iminor(file_inode(file));
int err = 0; int err = 0;
ssize_t bytes = 0; ssize_t bytes = 0;
...@@ -99,7 +99,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf, ...@@ -99,7 +99,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
const u32 __user *tmp = (const u32 __user *)buf; const u32 __user *tmp = (const u32 __user *)buf;
u32 data[2]; u32 data[2];
u32 reg = *ppos; u32 reg = *ppos;
int cpu = iminor(file->f_path.dentry->d_inode); int cpu = iminor(file_inode(file));
int err = 0; int err = 0;
ssize_t bytes = 0; ssize_t bytes = 0;
...@@ -125,7 +125,7 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) ...@@ -125,7 +125,7 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
{ {
u32 __user *uregs = (u32 __user *)arg; u32 __user *uregs = (u32 __user *)arg;
u32 regs[8]; u32 regs[8];
int cpu = iminor(file->f_path.dentry->d_inode); int cpu = iminor(file_inode(file));
int err; int err;
switch (ioc) { switch (ioc) {
...@@ -171,13 +171,12 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg) ...@@ -171,13 +171,12 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)
static int msr_open(struct inode *inode, struct file *file) static int msr_open(struct inode *inode, struct file *file)
{ {
unsigned int cpu; unsigned int cpu = iminor(file_inode(file));
struct cpuinfo_x86 *c; struct cpuinfo_x86 *c;
if (!capable(CAP_SYS_RAWIO)) if (!capable(CAP_SYS_RAWIO))
return -EPERM; return -EPERM;
cpu = iminor(file->f_path.dentry->d_inode);
if (cpu >= nr_cpu_ids || !cpu_online(cpu)) if (cpu >= nr_cpu_ids || !cpu_online(cpu))
return -ENXIO; /* No such CPU */ return -ENXIO; /* No such CPU */
......
...@@ -580,7 +580,7 @@ static int do_devinfo_ioctl(struct comedi_device *dev, ...@@ -580,7 +580,7 @@ static int do_devinfo_ioctl(struct comedi_device *dev,
struct comedi_devinfo __user *arg, struct comedi_devinfo __user *arg,
struct file *file) struct file *file)
{ {
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file_inode(file));
struct comedi_file_info *info = comedi_file_info_from_minor(minor); struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_subdevice *s; struct comedi_subdevice *s;
struct comedi_devinfo devinfo; struct comedi_devinfo devinfo;
...@@ -1615,7 +1615,7 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg, ...@@ -1615,7 +1615,7 @@ static int do_poll_ioctl(struct comedi_device *dev, unsigned int arg,
static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd, static long comedi_unlocked_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file_inode(file));
struct comedi_file_info *info = comedi_file_info_from_minor(minor); struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_device *dev = comedi_dev_from_file_info(info); struct comedi_device *dev = comedi_dev_from_file_info(info);
int rc; int rc;
...@@ -1743,7 +1743,7 @@ static struct vm_operations_struct comedi_vm_ops = { ...@@ -1743,7 +1743,7 @@ static struct vm_operations_struct comedi_vm_ops = {
static int comedi_mmap(struct file *file, struct vm_area_struct *vma) static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
{ {
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file_inode(file));
struct comedi_file_info *info = comedi_file_info_from_minor(minor); struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_device *dev = comedi_dev_from_file_info(info); struct comedi_device *dev = comedi_dev_from_file_info(info);
struct comedi_subdevice *s; struct comedi_subdevice *s;
...@@ -1823,7 +1823,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1823,7 +1823,7 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
static unsigned int comedi_poll(struct file *file, poll_table *wait) static unsigned int comedi_poll(struct file *file, poll_table *wait)
{ {
unsigned int mask = 0; unsigned int mask = 0;
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file_inode(file));
struct comedi_file_info *info = comedi_file_info_from_minor(minor); struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_device *dev = comedi_dev_from_file_info(info); struct comedi_device *dev = comedi_dev_from_file_info(info);
struct comedi_subdevice *s; struct comedi_subdevice *s;
...@@ -1869,7 +1869,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf, ...@@ -1869,7 +1869,7 @@ static ssize_t comedi_write(struct file *file, const char __user *buf,
struct comedi_async *async; struct comedi_async *async;
int n, m, count = 0, retval = 0; int n, m, count = 0, retval = 0;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file_inode(file));
struct comedi_file_info *info = comedi_file_info_from_minor(minor); struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_device *dev = comedi_dev_from_file_info(info); struct comedi_device *dev = comedi_dev_from_file_info(info);
...@@ -1964,7 +1964,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes, ...@@ -1964,7 +1964,7 @@ static ssize_t comedi_read(struct file *file, char __user *buf, size_t nbytes,
struct comedi_async *async; struct comedi_async *async;
int n, m, count = 0, retval = 0; int n, m, count = 0, retval = 0;
DECLARE_WAITQUEUE(wait, current); DECLARE_WAITQUEUE(wait, current);
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file_inode(file));
struct comedi_file_info *info = comedi_file_info_from_minor(minor); struct comedi_file_info *info = comedi_file_info_from_minor(minor);
struct comedi_device *dev = comedi_dev_from_file_info(info); struct comedi_device *dev = comedi_dev_from_file_info(info);
...@@ -2133,7 +2133,7 @@ static int comedi_open(struct inode *inode, struct file *file) ...@@ -2133,7 +2133,7 @@ static int comedi_open(struct inode *inode, struct file *file)
static int comedi_fasync(int fd, struct file *file, int on) static int comedi_fasync(int fd, struct file *file, int on)
{ {
const unsigned minor = iminor(file->f_dentry->d_inode); const unsigned minor = iminor(file_inode(file));
struct comedi_device *dev = comedi_dev_from_minor(minor); struct comedi_device *dev = comedi_dev_from_minor(minor);
if (!dev) if (!dev)
......
...@@ -960,11 +960,10 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count, ...@@ -960,11 +960,10 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos) loff_t *ppos)
{ {
int i; int i;
struct inode *inode = file->f_path.dentry->d_inode;
struct tty_struct *tty = file_tty(file); struct tty_struct *tty = file_tty(file);
struct tty_ldisc *ld; struct tty_ldisc *ld;
if (tty_paranoia_check(tty, inode, "tty_read")) if (tty_paranoia_check(tty, file_inode(file), "tty_read"))
return -EIO; return -EIO;
if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags))) if (!tty || (test_bit(TTY_IO_ERROR, &tty->flags)))
return -EIO; return -EIO;
...@@ -1132,12 +1131,11 @@ void tty_write_message(struct tty_struct *tty, char *msg) ...@@ -1132,12 +1131,11 @@ void tty_write_message(struct tty_struct *tty, char *msg)
static ssize_t tty_write(struct file *file, const char __user *buf, static ssize_t tty_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct inode *inode = file->f_path.dentry->d_inode;
struct tty_struct *tty = file_tty(file); struct tty_struct *tty = file_tty(file);
struct tty_ldisc *ld; struct tty_ldisc *ld;
ssize_t ret; ssize_t ret;
if (tty_paranoia_check(tty, inode, "tty_write")) if (tty_paranoia_check(tty, file_inode(file), "tty_write"))
return -EIO; return -EIO;
if (!tty || !tty->ops->write || if (!tty || !tty->ops->write ||
(test_bit(TTY_IO_ERROR, &tty->flags))) (test_bit(TTY_IO_ERROR, &tty->flags)))
...@@ -2047,7 +2045,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait) ...@@ -2047,7 +2045,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait)
struct tty_ldisc *ld; struct tty_ldisc *ld;
int ret = 0; int ret = 0;
if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_poll")) if (tty_paranoia_check(tty, file_inode(filp), "tty_poll"))
return 0; return 0;
ld = tty_ldisc_ref_wait(tty); ld = tty_ldisc_ref_wait(tty);
...@@ -2063,7 +2061,7 @@ static int __tty_fasync(int fd, struct file *filp, int on) ...@@ -2063,7 +2061,7 @@ static int __tty_fasync(int fd, struct file *filp, int on)
unsigned long flags; unsigned long flags;
int retval = 0; int retval = 0;
if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync")) if (tty_paranoia_check(tty, file_inode(filp), "tty_fasync"))
goto out; goto out;
retval = fasync_helper(fd, filp, on, &tty->fasync); 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,9 +2635,8 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
void __user *p = (void __user *)arg; void __user *p = (void __user *)arg;
int retval; int retval;
struct tty_ldisc *ld; struct tty_ldisc *ld;
struct inode *inode = file->f_dentry->d_inode;
if (tty_paranoia_check(tty, inode, "tty_ioctl")) if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl"))
return -EINVAL; return -EINVAL;
real_tty = tty_pair_get_tty(tty); real_tty = tty_pair_get_tty(tty);
...@@ -2780,12 +2777,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -2780,12 +2777,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
static long tty_compat_ioctl(struct file *file, unsigned int cmd, static long tty_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
struct inode *inode = file->f_dentry->d_inode;
struct tty_struct *tty = file_tty(file); struct tty_struct *tty = file_tty(file);
struct tty_ldisc *ld; struct tty_ldisc *ld;
int retval = -ENOIOCTLCMD; int retval = -ENOIOCTLCMD;
if (tty_paranoia_check(tty, inode, "tty_ioctl")) if (tty_paranoia_check(tty, file_inode(file), "tty_ioctl"))
return -EINVAL; return -EINVAL;
if (tty->ops->compat_ioctl) { if (tty->ops->compat_ioctl) {
......
...@@ -41,29 +41,16 @@ ...@@ -41,29 +41,16 @@
* *
*/ */
int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid)
{ {
struct v9fs_dentry *dent; hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
}
p9_debug(P9_DEBUG_VFS, "fid %d dentry %s\n",
fid->fid, dentry->d_name.name);
dent = dentry->d_fsdata;
if (!dent) {
dent = kmalloc(sizeof(struct v9fs_dentry), GFP_KERNEL);
if (!dent)
return -ENOMEM;
spin_lock_init(&dent->lock);
INIT_LIST_HEAD(&dent->fidlist);
dentry->d_fsdata = dent;
}
spin_lock(&dent->lock);
list_add(&fid->dlist, &dent->fidlist);
spin_unlock(&dent->lock);
return 0; void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
{
spin_lock(&dentry->d_lock);
__add_fid(dentry, fid);
spin_unlock(&dentry->d_lock);
} }
/** /**
...@@ -76,23 +63,23 @@ int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid) ...@@ -76,23 +63,23 @@ int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any) static struct p9_fid *v9fs_fid_find(struct dentry *dentry, kuid_t uid, int any)
{ {
struct v9fs_dentry *dent;
struct p9_fid *fid, *ret; struct p9_fid *fid, *ret;
p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n", p9_debug(P9_DEBUG_VFS, " dentry: %s (%p) uid %d any %d\n",
dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid), dentry->d_name.name, dentry, from_kuid(&init_user_ns, uid),
any); any);
dent = (struct v9fs_dentry *) dentry->d_fsdata;
ret = NULL; ret = NULL;
if (dent) { /* we'll recheck under lock if there's anything to look in */
spin_lock(&dent->lock); if (dentry->d_fsdata) {
list_for_each_entry(fid, &dent->fidlist, dlist) { struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;
spin_lock(&dentry->d_lock);
hlist_for_each_entry(fid, h, dlist) {
if (any || uid_eq(fid->uid, uid)) { if (any || uid_eq(fid->uid, uid)) {
ret = fid; ret = fid;
break; break;
} }
} }
spin_unlock(&dent->lock); spin_unlock(&dentry->d_lock);
} }
return ret; return ret;
...@@ -215,8 +202,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, ...@@ -215,8 +202,17 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
} }
kfree(wnames); kfree(wnames);
fid_out: fid_out:
if (!IS_ERR(fid)) if (!IS_ERR(fid)) {
v9fs_fid_add(dentry, fid); spin_lock(&dentry->d_lock);
if (d_unhashed(dentry)) {
spin_unlock(&dentry->d_lock);
p9_client_clunk(fid);
fid = ERR_PTR(-ENOENT);
} else {
__add_fid(dentry, fid);
spin_unlock(&dentry->d_lock);
}
}
err_out: err_out:
up_read(&v9ses->rename_sem); up_read(&v9ses->rename_sem);
return fid; return fid;
......
...@@ -23,28 +23,8 @@ ...@@ -23,28 +23,8 @@
#define FS_9P_FID_H #define FS_9P_FID_H
#include <linux/list.h> #include <linux/list.h>
/**
* struct v9fs_dentry - 9p private data stored in dentry d_fsdata
* @lock: protects the fidlist
* @fidlist: list of FIDs currently associated with this dentry
*
* This structure defines the 9p private data associated with
* a particular dentry. In particular, this private data is used
* to lookup which 9P FID handle should be used for a particular VFS
* operation. FID handles are associated with dentries instead of
* inodes in order to more closely map functionality to the Plan 9
* expected behavior for FID reclaimation and tracking.
*
* See Also: Mapping FIDs to Linux VFS model in
* Design and Implementation of the Linux 9P File System documentation
*/
struct v9fs_dentry {
spinlock_t lock; /* protect fidlist */
struct list_head fidlist;
};
struct p9_fid *v9fs_fid_lookup(struct dentry *dentry); struct p9_fid *v9fs_fid_lookup(struct dentry *dentry);
struct p9_fid *v9fs_fid_clone(struct dentry *dentry); struct p9_fid *v9fs_fid_clone(struct dentry *dentry);
int v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid); void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid);
struct p9_fid *v9fs_writeback_fid(struct dentry *dentry); struct p9_fid *v9fs_writeback_fid(struct dentry *dentry);
#endif #endif
...@@ -83,21 +83,12 @@ static int v9fs_cached_dentry_delete(const struct dentry *dentry) ...@@ -83,21 +83,12 @@ static int v9fs_cached_dentry_delete(const struct dentry *dentry)
static void v9fs_dentry_release(struct dentry *dentry) static void v9fs_dentry_release(struct dentry *dentry)
{ {
struct v9fs_dentry *dent; struct hlist_node *p, *n;
struct p9_fid *temp, *current_fid;
p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n", p9_debug(P9_DEBUG_VFS, " dentry: %s (%p)\n",
dentry->d_name.name, dentry); dentry->d_name.name, dentry);
dent = dentry->d_fsdata; hlist_for_each_safe(p, n, (struct hlist_head *)&dentry->d_fsdata)
if (dent) { p9_client_clunk(hlist_entry(p, struct p9_fid, dlist));
list_for_each_entry_safe(current_fid, temp, &dent->fidlist, dentry->d_fsdata = NULL;
dlist) {
p9_client_clunk(current_fid);
}
kfree(dent);
dentry->d_fsdata = NULL;
}
} }
static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags) 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, ...@@ -692,9 +692,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
"inode creation failed %d\n", err); "inode creation failed %d\n", err);
goto error; goto error;
} }
err = v9fs_fid_add(dentry, fid); v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
} }
return ofid; return ofid;
...@@ -790,7 +788,6 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -790,7 +788,6 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
struct p9_fid *dfid, *fid; struct p9_fid *dfid, *fid;
struct inode *inode; struct inode *inode;
char *name; char *name;
int result = 0;
p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n", p9_debug(P9_DEBUG_VFS, "dir: %p dentry: (%s) %p flags: %x\n",
dir, dentry->d_name.name, dentry, flags); dir, dentry->d_name.name, dentry, flags);
...@@ -808,13 +805,11 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -808,13 +805,11 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
name = (char *) dentry->d_name.name; name = (char *) dentry->d_name.name;
fid = p9_client_walk(dfid, 1, &name, 1); fid = p9_client_walk(dfid, 1, &name, 1);
if (IS_ERR(fid)) { if (IS_ERR(fid)) {
result = PTR_ERR(fid); if (fid == ERR_PTR(-ENOENT)) {
if (result == -ENOENT) { d_add(dentry, NULL);
inode = NULL; return NULL;
goto inst_out;
} }
return ERR_CAST(fid);
return ERR_PTR(result);
} }
/* /*
* Make sure we don't use a wrong inode due to parallel * 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,14 +821,9 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
else else
inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb);
if (IS_ERR(inode)) { if (IS_ERR(inode)) {
result = PTR_ERR(inode); p9_client_clunk(fid);
inode = NULL; return ERR_CAST(inode);
goto error;
} }
result = v9fs_fid_add(dentry, fid);
if (result < 0)
goto error_iput;
inst_out:
/* /*
* If we had a rename on the server and a parallel lookup * If we had a rename on the server and a parallel lookup
* for the new name, then make sure we instantiate with * for the new name, then make sure we instantiate with
...@@ -842,15 +832,13 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, ...@@ -842,15 +832,13 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
* k/b. * k/b.
*/ */
res = d_materialise_unique(dentry, inode); res = d_materialise_unique(dentry, inode);
if (!IS_ERR(res)) if (!res)
return res; v9fs_fid_add(dentry, fid);
result = PTR_ERR(res); else if (!IS_ERR(res))
error_iput: v9fs_fid_add(res, fid);
iput(inode); else
error: p9_client_clunk(fid);
p9_client_clunk(fid); return res;
return ERR_PTR(result);
} }
static int static int
......
...@@ -333,9 +333,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, ...@@ -333,9 +333,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
/* Now set the ACL based on the default value */ /* Now set the ACL based on the default value */
v9fs_set_create_acl(inode, fid, dacl, pacl); v9fs_set_create_acl(inode, fid, dacl, pacl);
err = v9fs_fid_add(dentry, fid); v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
v9inode = V9FS_I(inode); v9inode = V9FS_I(inode);
...@@ -453,12 +451,11 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, ...@@ -453,12 +451,11 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir,
err); err);
goto error; goto error;
} }
err = v9fs_fid_add(dentry, fid); v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
v9fs_set_create_acl(inode, fid, dacl, pacl); v9fs_set_create_acl(inode, fid, dacl, pacl);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
fid = NULL; fid = NULL;
err = 0;
} else { } else {
/* /*
* Not in cached mode. No need to populate * Not in cached mode. No need to populate
...@@ -747,11 +744,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry, ...@@ -747,11 +744,10 @@ v9fs_vfs_symlink_dotl(struct inode *dir, struct dentry *dentry,
err); err);
goto error; goto error;
} }
err = v9fs_fid_add(dentry, fid); v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
fid = NULL; fid = NULL;
err = 0;
} else { } else {
/* Not in cached mode. No need to populate inode with stat */ /* Not in cached mode. No need to populate inode with stat */
inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); 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,11 +896,10 @@ v9fs_vfs_mknod_dotl(struct inode *dir, struct dentry *dentry, umode_t omode,
goto error; goto error;
} }
v9fs_set_create_acl(inode, fid, dacl, pacl); v9fs_set_create_acl(inode, fid, dacl, pacl);
err = v9fs_fid_add(dentry, fid); v9fs_fid_add(dentry, fid);
if (err < 0)
goto error;
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
fid = NULL; fid = NULL;
err = 0;
} else { } else {
/* /*
* Not in cached mode. No need to populate inode with stat. * Not in cached mode. No need to populate inode with stat.
......
...@@ -1606,7 +1606,7 @@ static int ext4_free_hole_blocks(handle_t *handle, struct inode *inode, ...@@ -1606,7 +1606,7 @@ static int ext4_free_hole_blocks(handle_t *handle, struct inode *inode,
int ext4_ind_punch_hole(struct file *file, loff_t offset, loff_t length) int ext4_ind_punch_hole(struct file *file, loff_t offset, loff_t length)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
ext4_lblk_t first_block, stop_block; ext4_lblk_t first_block, stop_block;
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
......
...@@ -29,7 +29,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma, ...@@ -29,7 +29,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
struct vm_fault *vmf) struct vm_fault *vmf)
{ {
struct page *page = vmf->page; struct page *page = vmf->page;
struct inode *inode = vma->vm_file->f_path.dentry->d_inode; struct inode *inode = file_inode(vma->vm_file);
struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
block_t old_blk_addr; block_t old_blk_addr;
struct dnode_of_data dn; struct dnode_of_data dn;
...@@ -544,7 +544,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset, ...@@ -544,7 +544,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
static long f2fs_fallocate(struct file *file, int mode, static long f2fs_fallocate(struct file *file, int mode,
loff_t offset, loff_t len) loff_t offset, loff_t len)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
long ret; long ret;
if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE)) 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,7 +577,7 @@ static inline __u32 f2fs_mask_flags(umode_t mode, __u32 flags)
long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{ {
struct inode *inode = filp->f_dentry->d_inode; struct inode *inode = file_inode(filp);
struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode);
unsigned int flags; unsigned int flags;
int ret; int ret;
......
...@@ -176,6 +176,7 @@ struct file *alloc_file(struct path *path, fmode_t mode, ...@@ -176,6 +176,7 @@ struct file *alloc_file(struct path *path, fmode_t mode,
return file; return file;
file->f_path = *path; file->f_path = *path;
file->f_inode = path->dentry->d_inode;
file->f_mapping = path->dentry->d_inode->i_mapping; file->f_mapping = path->dentry->d_inode->i_mapping;
file->f_mode = mode; file->f_mode = mode;
file->f_op = fop; file->f_op = fop;
...@@ -258,6 +259,7 @@ static void __fput(struct file *file) ...@@ -258,6 +259,7 @@ static void __fput(struct file *file)
drop_file_write_access(file); drop_file_write_access(file);
file->f_path.dentry = NULL; file->f_path.dentry = NULL;
file->f_path.mnt = NULL; file->f_path.mnt = NULL;
file->f_inode = NULL;
file_free(file); file_free(file);
dput(dentry); dput(dentry);
mntput(mnt); mntput(mnt);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values. * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
* It can block. * It can block.
*/ */
void set_fs_root(struct fs_struct *fs, struct path *path) void set_fs_root(struct fs_struct *fs, const struct path *path)
{ {
struct path old_root; struct path old_root;
...@@ -29,7 +29,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path) ...@@ -29,7 +29,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
* Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values. * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
* It can block. * It can block.
*/ */
void set_fs_pwd(struct fs_struct *fs, struct path *path) void set_fs_pwd(struct fs_struct *fs, const struct path *path)
{ {
struct path old_pwd; struct path old_pwd;
...@@ -53,7 +53,7 @@ static inline int replace_path(struct path *p, const struct path *old, const str ...@@ -53,7 +53,7 @@ static inline int replace_path(struct path *p, const struct path *old, const str
return 1; return 1;
} }
void chroot_fs_refs(struct path *old_root, struct path *new_root) void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
{ {
struct task_struct *g, *p; struct task_struct *g, *p;
struct fs_struct *fs; struct fs_struct *fs;
......
...@@ -532,7 +532,7 @@ void fuse_request_send_background_locked(struct fuse_conn *fc, ...@@ -532,7 +532,7 @@ void fuse_request_send_background_locked(struct fuse_conn *fc,
void fuse_force_forget(struct file *file, u64 nodeid) void fuse_force_forget(struct file *file, u64 nodeid)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_req *req; struct fuse_req *req;
struct fuse_forget_in inarg; struct fuse_forget_in inarg;
......
...@@ -355,7 +355,7 @@ static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index) ...@@ -355,7 +355,7 @@ static int fuse_wait_on_page_writeback(struct inode *inode, pgoff_t index)
static int fuse_flush(struct file *file, fl_owner_t id) static int fuse_flush(struct file *file, fl_owner_t id)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_file *ff = file->private_data; struct fuse_file *ff = file->private_data;
struct fuse_req *req; struct fuse_req *req;
...@@ -1215,7 +1215,7 @@ static ssize_t __fuse_direct_read(struct file *file, const struct iovec *iov, ...@@ -1215,7 +1215,7 @@ static ssize_t __fuse_direct_read(struct file *file, const struct iovec *iov,
unsigned long nr_segs, loff_t *ppos) unsigned long nr_segs, loff_t *ppos)
{ {
ssize_t res; ssize_t res;
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
if (is_bad_inode(inode)) if (is_bad_inode(inode))
return -EIO; return -EIO;
...@@ -1238,7 +1238,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf, ...@@ -1238,7 +1238,7 @@ static ssize_t fuse_direct_read(struct file *file, char __user *buf,
static ssize_t __fuse_direct_write(struct file *file, const struct iovec *iov, static ssize_t __fuse_direct_write(struct file *file, const struct iovec *iov,
unsigned long nr_segs, loff_t *ppos) unsigned long nr_segs, loff_t *ppos)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
size_t count = iov_length(iov, nr_segs); size_t count = iov_length(iov, nr_segs);
ssize_t res; ssize_t res;
...@@ -1258,7 +1258,7 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf, ...@@ -1258,7 +1258,7 @@ static ssize_t fuse_direct_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count }; struct iovec iov = { .iov_base = (void __user *)buf, .iov_len = count };
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
ssize_t res; ssize_t res;
if (is_bad_inode(inode)) if (is_bad_inode(inode))
...@@ -1485,7 +1485,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = { ...@@ -1485,7 +1485,7 @@ static const struct vm_operations_struct fuse_file_vm_ops = {
static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma) static int fuse_file_mmap(struct file *file, struct vm_area_struct *vma)
{ {
if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) { if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) {
struct inode *inode = file->f_dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode); struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_file *ff = file->private_data; struct fuse_file *ff = file->private_data;
...@@ -1543,7 +1543,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file, ...@@ -1543,7 +1543,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file,
const struct file_lock *fl, int opcode, pid_t pid, const struct file_lock *fl, int opcode, pid_t pid,
int flock) int flock)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_file *ff = file->private_data; struct fuse_file *ff = file->private_data;
struct fuse_lk_in *arg = &req->misc.lk_in; 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,7 +1565,7 @@ static void fuse_lk_fill(struct fuse_req *req, struct file *file,
static int fuse_getlk(struct file *file, struct file_lock *fl) static int fuse_getlk(struct file *file, struct file_lock *fl)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_req *req; struct fuse_req *req;
struct fuse_lk_out outarg; struct fuse_lk_out outarg;
...@@ -1590,7 +1590,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl) ...@@ -1590,7 +1590,7 @@ static int fuse_getlk(struct file *file, struct file_lock *fl)
static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_req *req; struct fuse_req *req;
int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; 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,7 +1622,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
int err; int err;
...@@ -1645,7 +1645,7 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) ...@@ -1645,7 +1645,7 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
int err; int err;
...@@ -1702,7 +1702,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block) ...@@ -1702,7 +1702,7 @@ static sector_t fuse_bmap(struct address_space *mapping, sector_t block)
static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence) static loff_t fuse_file_llseek(struct file *file, loff_t offset, int whence)
{ {
loff_t retval; loff_t retval;
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file_inode(file);
/* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */ /* No i_mutex protection necessary for SEEK_CUR and SEEK_SET */
if (whence == SEEK_CUR || whence == SEEK_SET) if (whence == SEEK_CUR || whence == SEEK_SET)
...@@ -2079,7 +2079,7 @@ EXPORT_SYMBOL_GPL(fuse_do_ioctl); ...@@ -2079,7 +2079,7 @@ EXPORT_SYMBOL_GPL(fuse_do_ioctl);
long fuse_ioctl_common(struct file *file, unsigned int cmd, long fuse_ioctl_common(struct file *file, unsigned int cmd,
unsigned long arg, unsigned int flags) unsigned long arg, unsigned int flags)
{ {
struct inode *inode = file->f_dentry->d_inode; struct inode *inode = file_inode(file);
struct fuse_conn *fc = get_fuse_conn(inode); struct fuse_conn *fc = get_fuse_conn(inode);
if (!fuse_allow_current_process(fc)) if (!fuse_allow_current_process(fc))
......
...@@ -69,7 +69,7 @@ extern void __mnt_drop_write_file(struct file *); ...@@ -69,7 +69,7 @@ extern void __mnt_drop_write_file(struct file *);
/* /*
* fs_struct.c * fs_struct.c
*/ */
extern void chroot_fs_refs(struct path *, struct path *); extern void chroot_fs_refs(const struct path *, const struct path *);
/* /*
* file_table.c * file_table.c
......
...@@ -451,7 +451,7 @@ int inode_permission(struct inode *inode, int mask) ...@@ -451,7 +451,7 @@ int inode_permission(struct inode *inode, int mask)
* *
* Given a path increment the reference count to the dentry and the vfsmount. * Given a path increment the reference count to the dentry and the vfsmount.
*/ */
void path_get(struct path *path) void path_get(const struct path *path)
{ {
mntget(path->mnt); mntget(path->mnt);
dget(path->dentry); dget(path->dentry);
...@@ -464,7 +464,7 @@ EXPORT_SYMBOL(path_get); ...@@ -464,7 +464,7 @@ EXPORT_SYMBOL(path_get);
* *
* Given a path decrement the reference count to the dentry and the vfsmount. * Given a path decrement the reference count to the dentry and the vfsmount.
*/ */
void path_put(struct path *path) void path_put(const struct path *path)
{ {
dput(path->dentry); dput(path->dentry);
mntput(path->mnt); mntput(path->mnt);
......
...@@ -704,7 +704,7 @@ static int do_dentry_open(struct file *f, ...@@ -704,7 +704,7 @@ static int do_dentry_open(struct file *f,
f->f_mode = FMODE_PATH; f->f_mode = FMODE_PATH;
path_get(&f->f_path); path_get(&f->f_path);
inode = file_inode(f); inode = f->f_inode = f->f_path.dentry->d_inode;
if (f->f_mode & FMODE_WRITE) { if (f->f_mode & FMODE_WRITE) {
error = __get_file_write_access(inode, f->f_path.mnt); error = __get_file_write_access(inode, f->f_path.mnt);
if (error) if (error)
...@@ -767,6 +767,7 @@ static int do_dentry_open(struct file *f, ...@@ -767,6 +767,7 @@ static int do_dentry_open(struct file *f,
path_put(&f->f_path); path_put(&f->f_path);
f->f_path.mnt = NULL; f->f_path.mnt = NULL;
f->f_path.dentry = NULL; f->f_path.dentry = NULL;
f->f_inode = NULL;
return error; return error;
} }
......
...@@ -339,7 +339,7 @@ EXPORT_SYMBOL(seq_lseek); ...@@ -339,7 +339,7 @@ EXPORT_SYMBOL(seq_lseek);
/** /**
* seq_release - free the structures associated with sequential file. * seq_release - free the structures associated with sequential file.
* @file: file in question * @file: file in question
* @inode: file->f_path.dentry->d_inode * @inode: its inode
* *
* Frees the structures associated with sequential file; can be used * Frees the structures associated with sequential file; can be used
* as ->f_op->release() if you don't have private data to destroy. * as ->f_op->release() if you don't have private data to destroy.
......
...@@ -769,6 +769,7 @@ struct file { ...@@ -769,6 +769,7 @@ struct file {
} f_u; } f_u;
struct path f_path; struct path f_path;
#define f_dentry f_path.dentry #define f_dentry f_path.dentry
struct inode *f_inode; /* cached value */
const struct file_operations *f_op; const struct file_operations *f_op;
/* /*
...@@ -2217,7 +2218,7 @@ static inline bool execute_ok(struct inode *inode) ...@@ -2217,7 +2218,7 @@ static inline bool execute_ok(struct inode *inode)
static inline struct inode *file_inode(struct file *f) static inline struct inode *file_inode(struct file *f)
{ {
return f->f_path.dentry->d_inode; return f->f_inode;
} }
/* /*
......
...@@ -17,8 +17,8 @@ struct fs_struct { ...@@ -17,8 +17,8 @@ struct fs_struct {
extern struct kmem_cache *fs_cachep; extern struct kmem_cache *fs_cachep;
extern void exit_fs(struct task_struct *); extern void exit_fs(struct task_struct *);
extern void set_fs_root(struct fs_struct *, struct path *); extern void set_fs_root(struct fs_struct *, const struct path *);
extern void set_fs_pwd(struct fs_struct *, struct path *); extern void set_fs_pwd(struct fs_struct *, const struct path *);
extern struct fs_struct *copy_fs_struct(struct fs_struct *); extern struct fs_struct *copy_fs_struct(struct fs_struct *);
extern void free_fs_struct(struct fs_struct *); extern void free_fs_struct(struct fs_struct *);
extern int unshare_fs_struct(void); extern int unshare_fs_struct(void);
......
...@@ -9,8 +9,8 @@ struct path { ...@@ -9,8 +9,8 @@ struct path {
struct dentry *dentry; struct dentry *dentry;
}; };
extern void path_get(struct path *); extern void path_get(const struct path *);
extern void path_put(struct path *); extern void path_put(const struct path *);
static inline int path_equal(const struct path *path1, const struct path *path2) static inline int path_equal(const struct path *path1, const struct path *path2)
{ {
......
...@@ -192,7 +192,7 @@ struct p9_fid { ...@@ -192,7 +192,7 @@ struct p9_fid {
void *rdir; void *rdir;
struct list_head flist; struct list_head flist;
struct list_head dlist; /* list of all fids attached to a dentry */ struct hlist_node dlist; /* list of all fids attached to a dentry */
}; };
/** /**
......
...@@ -226,7 +226,7 @@ static void drop_futex_key_refs(union futex_key *key) ...@@ -226,7 +226,7 @@ static void drop_futex_key_refs(union futex_key *key)
* Returns a negative error code or 0 * Returns a negative error code or 0
* The key words are stored in *key on success. * The key words are stored in *key on success.
* *
* For shared mappings, it's (page->index, vma->vm_file->f_path.dentry->d_inode, * For shared mappings, it's (page->index, file_inode(vma->vm_file),
* offset_within_page). For private mappings, it's (uaddr, current->mm). * offset_within_page). For private mappings, it's (uaddr, current->mm).
* We can usually work out the index without swapping in the page. * We can usually work out the index without swapping in the page.
* *
......
...@@ -2932,9 +2932,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags ...@@ -2932,9 +2932,8 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags
inode->i_size = size; inode->i_size = size;
clear_nlink(inode); /* It is unlinked */ clear_nlink(inode); /* It is unlinked */
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
error = ramfs_nommu_expand_for_mapping(inode, size); res = ERR_PTR(ramfs_nommu_expand_for_mapping(inode, size));
res = ERR_PTR(error); if (IS_ERR(res))
if (error)
goto put_dentry; goto put_dentry;
#endif #endif
......
...@@ -3135,11 +3135,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, ...@@ -3135,11 +3135,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
switch (cmd) { switch (cmd) {
case F_SETFL: case F_SETFL:
if (!file->f_path.dentry || !file->f_path.dentry->d_inode) {
err = -EINVAL;
break;
}
if ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) { if ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) {
err = file_has_perm(cred, file, FILE__WRITE); err = file_has_perm(cred, file, FILE__WRITE);
break; break;
...@@ -3162,10 +3157,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, ...@@ -3162,10 +3157,6 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
case F_SETLK64: case F_SETLK64:
case F_SETLKW64: case F_SETLKW64:
#endif #endif
if (!file->f_path.dentry || !file->f_path.dentry->d_inode) {
err = -EINVAL;
break;
}
err = file_has_perm(cred, file, FILE__LOCK); err = file_has_perm(cred, file, FILE__LOCK);
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment