mm: mmap_region: kill correct_wcount/inode, use allow_write_access()
[pandora-kernel.git] / mm / mmap.c
index 76cabd2..f04b71c 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1205,11 +1205,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
 {
        struct mm_struct *mm = current->mm;
        struct vm_area_struct *vma, *prev;
 {
        struct mm_struct *mm = current->mm;
        struct vm_area_struct *vma, *prev;
-       int correct_wcount = 0;
        int error;
        struct rb_node **rb_link, *rb_parent;
        unsigned long charged = 0;
        int error;
        struct rb_node **rb_link, *rb_parent;
        unsigned long charged = 0;
-       struct inode *inode =  file ? file->f_path.dentry->d_inode : NULL;
 
        /* Clear old maps */
        error = -ENOMEM;
 
        /* Clear old maps */
        error = -ENOMEM;
@@ -1280,7 +1278,6 @@ munmap_back:
                        error = deny_write_access(file);
                        if (error)
                                goto free_vma;
                        error = deny_write_access(file);
                        if (error)
                                goto free_vma;
-                       correct_wcount = 1;
                }
                vma->vm_file = get_file(file);
                error = file->f_op->mmap(file, vma);
                }
                vma->vm_file = get_file(file);
                error = file->f_op->mmap(file, vma);
@@ -1319,11 +1316,10 @@ munmap_back:
        }
 
        vma_link(mm, vma, prev, rb_link, rb_parent);
        }
 
        vma_link(mm, vma, prev, rb_link, rb_parent);
-       file = vma->vm_file;
-
        /* Once vma denies write, undo our temporary denial count */
        /* Once vma denies write, undo our temporary denial count */
-       if (correct_wcount)
-               atomic_inc(&inode->i_writecount);
+       if (vm_flags & VM_DENYWRITE)
+               allow_write_access(file);
+       file = vma->vm_file;
 out:
        perf_event_mmap(vma);
 
 out:
        perf_event_mmap(vma);
 
@@ -1337,8 +1333,8 @@ out:
        return addr;
 
 unmap_and_free_vma:
        return addr;
 
 unmap_and_free_vma:
-       if (correct_wcount)
-               atomic_inc(&inode->i_writecount);
+       if (vm_flags & VM_DENYWRITE)
+               allow_write_access(file);
        vma->vm_file = NULL;
        fput(file);
 
        vma->vm_file = NULL;
        fput(file);