aboutsummaryrefslogtreecommitdiffstats
path: root/fs/open.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/open.c')
-rw-r--r--fs/open.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/open.c b/fs/open.c
index e58382d57e72..b70e7666bb2c 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -806,6 +806,8 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
806 error = __get_file_write_access(inode, mnt); 806 error = __get_file_write_access(inode, mnt);
807 if (error) 807 if (error)
808 goto cleanup_file; 808 goto cleanup_file;
809 if (!special_file(inode->i_mode))
810 file_take_write(f);
809 } 811 }
810 812
811 f->f_mapping = inode->i_mapping; 813 f->f_mapping = inode->i_mapping;
@@ -847,8 +849,16 @@ cleanup_all:
847 fops_put(f->f_op); 849 fops_put(f->f_op);
848 if (f->f_mode & FMODE_WRITE) { 850 if (f->f_mode & FMODE_WRITE) {
849 put_write_access(inode); 851 put_write_access(inode);
850 if (!special_file(inode->i_mode)) 852 if (!special_file(inode->i_mode)) {
853 /*
854 * We don't consider this a real
855 * mnt_want/drop_write() pair
856 * because it all happenend right
857 * here, so just reset the state.
858 */
859 file_reset_write(f);
851 mnt_drop_write(mnt); 860 mnt_drop_write(mnt);
861 }
852 } 862 }
853 file_kill(f); 863 file_kill(f);
854 f->f_path.dentry = NULL; 864 f->f_path.dentry = NULL;