Commit 1c211088 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix the setting of file->f_ra on block-special files

We need to set file->f_ra _after_ calling blkdev_open(), when inode->i_mapping
points at the right thing.  And we need to get it from
inode->i_mapping->host->i_mapping too, which represents the underlying device.

Also, don't test for null file->f_mapping in the O_DIRECT checks.
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
parent 59a6ce4f
...@@ -790,7 +790,6 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) ...@@ -790,7 +790,6 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
} }
f->f_mapping = inode->i_mapping; f->f_mapping = inode->i_mapping;
file_ra_state_init(&f->f_ra, f->f_mapping);
f->f_dentry = dentry; f->f_dentry = dentry;
f->f_vfsmnt = mnt; f->f_vfsmnt = mnt;
f->f_pos = 0; f->f_pos = 0;
...@@ -804,10 +803,11 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags) ...@@ -804,10 +803,11 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
} }
f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); f->f_flags &= ~(O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC);
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 */ /* NB: we're sure to have correct a_ops only after f_op->open */
if (f->f_flags & O_DIRECT) { if (f->f_flags & O_DIRECT) {
if (!f->f_mapping || !f->f_mapping->a_ops || if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO) {
!f->f_mapping->a_ops->direct_IO) {
fput(f); fput(f);
f = ERR_PTR(-EINVAL); f = ERR_PTR(-EINVAL);
} }
......
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