]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/open.c
[PATCH] r/o bind mounts: debugging for missed calls
[linux-2.6-omap-h63xx.git] / fs / open.c
index e58382d57e721cf3f381c7c49edb03d547d75135..b70e7666bb2c3f725a761b268b2370e5c151ba63 100644 (file)
--- a/fs/open.c
+++ b/fs/open.c
@@ -806,6 +806,8 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
                error = __get_file_write_access(inode, mnt);
                if (error)
                        goto cleanup_file;
+               if (!special_file(inode->i_mode))
+                       file_take_write(f);
        }
 
        f->f_mapping = inode->i_mapping;
@@ -847,8 +849,16 @@ cleanup_all:
        fops_put(f->f_op);
        if (f->f_mode & FMODE_WRITE) {
                put_write_access(inode);
-               if (!special_file(inode->i_mode))
+               if (!special_file(inode->i_mode)) {
+                       /*
+                        * We don't consider this a real
+                        * mnt_want/drop_write() pair
+                        * because it all happenend right
+                        * here, so just reset the state.
+                        */
+                       file_reset_write(f);
                        mnt_drop_write(mnt);
+               }
        }
        file_kill(f);
        f->f_path.dentry = NULL;