]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] Fix the setting of file->f_ra on block-special files
authorAndrew Morton <akpm@osdl.org>
Thu, 27 May 2004 00:35:42 +0000 (17:35 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 27 May 2004 00:35:42 +0000 (17:35 -0700)
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: Andrew Morton <akpm@osdl.org>
fs/open.c

index 447d323c4c04c00365cdeab72164571c19d42f59..854c5de744dbad3f735976b6594bba1705133bc6 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -790,7 +790,6 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
        }
 
        f->f_mapping = inode->i_mapping;
-       file_ra_state_init(&f->f_ra, f->f_mapping);
        f->f_dentry = dentry;
        f->f_vfsmnt = mnt;
        f->f_pos = 0;
@@ -804,12 +803,13 @@ struct file *dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
        }
        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 */
        if (f->f_flags & O_DIRECT) {
-               if (!f->f_mapping || !f->f_mapping->a_ops ||
-                       !f->f_mapping->a_ops->direct_IO) {
-                               fput(f);
-                               f = ERR_PTR(-EINVAL);
+               if (!f->f_mapping->a_ops || !f->f_mapping->a_ops->direct_IO) {
+                       fput(f);
+                       f = ERR_PTR(-EINVAL);
                }
        }