Commit 69527c55 authored by Al Viro's avatar Al Viro

now we can fold open_check_o_direct() into do_dentry_open()

These checks are better off in do_dentry_open(); the reason we couldn't
put them there used to be that callers couldn't tell what kind of cleanup
would do_dentry_open() failure call for.  Now that we have FMODE_OPENED,
cleanup is the same in all cases - it's simply fput().  So let's fold
that into do_dentry_open(), as Christoph's patch tried to.
Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 7c1c01ec
...@@ -125,7 +125,6 @@ int do_fchmodat(int dfd, const char __user *filename, umode_t mode); ...@@ -125,7 +125,6 @@ int do_fchmodat(int dfd, const char __user *filename, umode_t mode);
int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group, int do_fchownat(int dfd, const char __user *filename, uid_t user, gid_t group,
int flag); int flag);
extern int open_check_o_direct(struct file *f);
extern int vfs_open(const struct path *, struct file *); extern int vfs_open(const struct path *, struct file *);
/* /*
......
...@@ -3401,8 +3401,6 @@ static int do_last(struct nameidata *nd, ...@@ -3401,8 +3401,6 @@ static int do_last(struct nameidata *nd,
goto out; goto out;
*opened |= FILE_OPENED; *opened |= FILE_OPENED;
opened: opened:
error = open_check_o_direct(file);
if (!error)
error = ima_file_check(file, op->acc_mode, *opened); error = ima_file_check(file, op->acc_mode, *opened);
if (!error && will_truncate) if (!error && will_truncate)
error = handle_truncate(file); error = handle_truncate(file);
...@@ -3479,9 +3477,6 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags, ...@@ -3479,9 +3477,6 @@ static int do_tmpfile(struct nameidata *nd, unsigned flags,
goto out2; goto out2;
file->f_path.mnt = path.mnt; file->f_path.mnt = path.mnt;
error = finish_open(file, child, NULL, opened); error = finish_open(file, child, NULL, opened);
if (error)
goto out2;
error = open_check_o_direct(file);
out2: out2:
mnt_drop_write(path.mnt); mnt_drop_write(path.mnt);
out: out:
......
...@@ -724,16 +724,6 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) ...@@ -724,16 +724,6 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group)
return ksys_fchown(fd, user, group); return ksys_fchown(fd, user, group);
} }
int open_check_o_direct(struct file *f)
{
/* 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)
return -EINVAL;
}
return 0;
}
static int do_dentry_open(struct file *f, static int do_dentry_open(struct file *f,
struct inode *inode, struct inode *inode,
int (*open)(struct inode *, struct file *)) int (*open)(struct inode *, struct file *))
...@@ -808,6 +798,11 @@ static int do_dentry_open(struct file *f, ...@@ -808,6 +798,11 @@ static int do_dentry_open(struct file *f,
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)
return -EINVAL;
}
return 0; return 0;
cleanup_all: cleanup_all:
...@@ -921,8 +916,6 @@ struct file *dentry_open(const struct path *path, int flags, ...@@ -921,8 +916,6 @@ struct file *dentry_open(const struct path *path, int flags,
f = alloc_empty_file(flags, cred); f = alloc_empty_file(flags, cred);
if (!IS_ERR(f)) { if (!IS_ERR(f)) {
error = vfs_open(path, f); error = vfs_open(path, f);
if (!error)
error = open_check_o_direct(f);
if (error) { if (error) {
fput(f); fput(f);
f = ERR_PTR(error); f = ERR_PTR(error);
......
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