mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
vfs: split __dentry_open()
Split __dentry_open() into two functions: do_dentry_open() - does most of the actual work, doesn't put file on failure open_check_o_direct() - after a successful open, checks direct_IO method This will allow i_op->atomic_open to do just the file initialization and leave the direct_IO checking to the VFS. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
5f5daac12a
commit
90ad1a8ecb
@ -100,6 +100,7 @@ extern struct file *do_file_open_root(struct dentry *, struct vfsmount *,
|
|||||||
|
|
||||||
extern long do_handle_open(int mountdirfd,
|
extern long do_handle_open(int mountdirfd,
|
||||||
struct file_handle __user *ufh, int open_flag);
|
struct file_handle __user *ufh, int open_flag);
|
||||||
|
extern int open_check_o_direct(struct file *f);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* inode.c
|
* inode.c
|
||||||
|
47
fs/open.c
47
fs/open.c
@ -654,10 +654,23 @@ static inline int __get_file_write_access(struct inode *inode,
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
int open_check_o_direct(struct file *f)
|
||||||
struct file *f,
|
{
|
||||||
int (*open)(struct inode *, struct file *),
|
/* NB: we're sure to have correct a_ops only after f_op->open */
|
||||||
const struct cred *cred)
|
if (f->f_flags & O_DIRECT) {
|
||||||
|
if (!f->f_mapping->a_ops ||
|
||||||
|
((!f->f_mapping->a_ops->direct_IO) &&
|
||||||
|
(!f->f_mapping->a_ops->get_xip_mem))) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct file *do_dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
||||||
|
struct file *f,
|
||||||
|
int (*open)(struct inode *, struct file *),
|
||||||
|
const struct cred *cred)
|
||||||
{
|
{
|
||||||
static const struct file_operations empty_fops = {};
|
static const struct file_operations empty_fops = {};
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
@ -713,16 +726,6 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
|||||||
|
|
||||||
file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
|
file_ra_state_init(&f->f_ra, f->f_mapping->host->i_mapping);
|
||||||
|
|
||||||
/* NB: we're sure to have correct a_ops only after f_op->open */
|
|
||||||
if (f->f_flags & O_DIRECT) {
|
|
||||||
if (!f->f_mapping->a_ops ||
|
|
||||||
((!f->f_mapping->a_ops->direct_IO) &&
|
|
||||||
(!f->f_mapping->a_ops->get_xip_mem))) {
|
|
||||||
fput(f);
|
|
||||||
f = ERR_PTR(-EINVAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
|
|
||||||
cleanup_all:
|
cleanup_all:
|
||||||
@ -750,6 +753,22 @@ cleanup_file:
|
|||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
|
||||||
|
struct file *f,
|
||||||
|
int (*open)(struct inode *, struct file *),
|
||||||
|
const struct cred *cred)
|
||||||
|
{
|
||||||
|
struct file *res = do_dentry_open(dentry, mnt, f, open, cred);
|
||||||
|
if (!IS_ERR(res)) {
|
||||||
|
int error = open_check_o_direct(f);
|
||||||
|
if (error) {
|
||||||
|
fput(res);
|
||||||
|
res = ERR_PTR(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* lookup_instantiate_filp - instantiates the open intent filp
|
* lookup_instantiate_filp - instantiates the open intent filp
|
||||||
* @nd: pointer to nameidata
|
* @nd: pointer to nameidata
|
||||||
|
Loading…
x
Reference in New Issue
Block a user