cache the value of file_inode() in struct file
Note that this thing does *not* contribute to inode refcount; it's pinned down by dentry. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
3c14ba2074
commit
70fd6c8517
|
@ -1844,10 +1844,11 @@ static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi)
|
||||||
return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
|
return is_set_ckpt_flags(sbi->ckpt, CP_ERROR_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Implementation of file_inode added to include/linux/fs.h
|
||||||
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_path.dentry->d_inode;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
static inline bool is_dot_dotdot(const struct qstr *str)
|
static inline bool is_dot_dotdot(const struct qstr *str)
|
||||||
{
|
{
|
||||||
|
|
|
@ -172,6 +172,7 @@ struct file *alloc_file(struct path *path, fmode_t mode,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -254,6 +255,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);
|
||||||
|
|
|
@ -673,6 +673,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
||||||
f->f_mode = FMODE_PATH;
|
f->f_mode = FMODE_PATH;
|
||||||
|
|
||||||
inode = dentry->d_inode;
|
inode = dentry->d_inode;
|
||||||
|
f->f_inode = dentry->d_inode;
|
||||||
if (f->f_mode & FMODE_WRITE) {
|
if (f->f_mode & FMODE_WRITE) {
|
||||||
error = __get_file_write_access(inode, mnt);
|
error = __get_file_write_access(inode, mnt);
|
||||||
if (error)
|
if (error)
|
||||||
|
@ -748,6 +749,7 @@ cleanup_all:
|
||||||
}
|
}
|
||||||
f->f_path.dentry = NULL;
|
f->f_path.dentry = NULL;
|
||||||
f->f_path.mnt = NULL;
|
f->f_path.mnt = NULL;
|
||||||
|
f->f_inode = NULL;
|
||||||
cleanup_file:
|
cleanup_file:
|
||||||
put_filp(f);
|
put_filp(f);
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
|
|
|
@ -574,17 +574,6 @@ out_unlocked:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
|
|
||||||
/* EMPTY */
|
|
||||||
#else /* LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0) */
|
|
||||||
static inline struct inode *file_inode(const struct file *f)
|
|
||||||
{
|
|
||||||
return f->f_dentry->d_inode;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
|
||||||
static inline int __is_sb_dirty(struct super_block *sb)
|
static inline int __is_sb_dirty(struct super_block *sb)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1029,6 +1029,7 @@ struct file {
|
||||||
struct path f_path;
|
struct path f_path;
|
||||||
#define f_dentry f_path.dentry
|
#define f_dentry f_path.dentry
|
||||||
#define f_vfsmnt f_path.mnt
|
#define f_vfsmnt f_path.mnt
|
||||||
|
struct inode *f_inode; /* cached value */
|
||||||
const struct file_operations *f_op;
|
const struct file_operations *f_op;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2304,6 +2305,12 @@ static inline bool execute_ok(struct inode *inode)
|
||||||
return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
|
return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct inode *file_inode(struct file *f)
|
||||||
|
{
|
||||||
|
/* return f->f_path.dentry->d_inode; / can also use this */
|
||||||
|
return f->f_inode;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get_write_access() gets write permission for a file.
|
* get_write_access() gets write permission for a file.
|
||||||
* put_write_access() releases this write permission.
|
* put_write_access() releases this write permission.
|
||||||
|
|
Loading…
Reference in New Issue