Commit 7d0be429 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] O_DIRECT open check

Updated forward-port of Aodrea's O_DIRECT open() checks.  If the user
asked for O_DIRECT and the inode has no mapping or no a_ops then fail
the open up-front.
parent e177ea28
......@@ -245,10 +245,9 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
}
if (arg & O_DIRECT) {
if (inode->i_mapping && inode->i_mapping->a_ops) {
if (!inode->i_mapping->a_ops->direct_IO)
if (!inode->i_mapping || !inode->i_mapping->a_ops ||
!inode->i_mapping->a_ops->direct_IO)
return -EINVAL;
}
/*
* alloc_kiovec() can sleep and we are only serialized by
......
......@@ -665,10 +665,11 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
/* NB: we're sure to have correct a_ops only after f_op->open */
if (f->f_flags & O_DIRECT) {
error = -EINVAL;
if (inode->i_mapping && inode->i_mapping->a_ops)
if (!inode->i_mapping->a_ops->direct_IO)
if (!inode->i_mapping || !inode->i_mapping->a_ops ||
!inode->i_mapping->a_ops->direct_IO) {
error = -EINVAL;
goto cleanup_all;
}
}
return f;
......
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