]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - mm/fremap.c
[PATCH] autofs4: need to invalidate children on tree mount expire
[linux-2.6-omap-h63xx.git] / mm / fremap.c
index 007cbad9331e208f37713148707843aeae105079..21b7d0cbc98c6eed4c859cebc825ee2c3d715ee1 100644 (file)
@@ -27,24 +27,20 @@ static int zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
        struct page *page = NULL;
 
        if (pte_present(pte)) {
-               unsigned long pfn = pte_pfn(pte);
-               flush_cache_page(vma, addr, pfn);
+               flush_cache_page(vma, addr, pte_pfn(pte));
                pte = ptep_clear_flush(vma, addr, ptep);
-               if (unlikely(!pfn_valid(pfn))) {
-                       print_bad_pte(vma, pte, addr);
-                       goto out;
+               page = vm_normal_page(vma, addr, pte);
+               if (page) {
+                       if (pte_dirty(pte))
+                               set_page_dirty(page);
+                       page_remove_rmap(page);
+                       page_cache_release(page);
                }
-               page = pfn_to_page(pfn);
-               if (pte_dirty(pte))
-                       set_page_dirty(page);
-               page_remove_rmap(page);
-               page_cache_release(page);
        } else {
                if (!pte_file(pte))
                        free_swap_and_cache(pte_to_swp_entry(pte));
                pte_clear(mm, addr, ptep);
        }
-out:
        return !!page;
 }
 
@@ -59,22 +55,10 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
        pgoff_t size;
        int err = -ENOMEM;
        pte_t *pte;
-       pmd_t *pmd;
-       pud_t *pud;
-       pgd_t *pgd;
        pte_t pte_val;
        spinlock_t *ptl;
 
-       BUG_ON(vma->vm_flags & VM_UNPAGED);
-
-       pgd = pgd_offset(mm, addr);
-       pud = pud_alloc(mm, pgd, addr);
-       if (!pud)
-               goto out;
-       pmd = pmd_alloc(mm, pud, addr);
-       if (!pmd)
-               goto out;
-       pte = pte_alloc_map_lock(mm, pmd, addr, &ptl);
+       pte = get_locked_pte(mm, addr, &ptl);
        if (!pte)
                goto out;
 
@@ -99,6 +83,7 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
        page_add_file_rmap(page);
        pte_val = *pte;
        update_mmu_cache(vma, addr, pte_val);
+       lazy_mmu_prot_update(pte_val);
        err = 0;
 unlock:
        pte_unmap_unlock(pte, ptl);
@@ -116,22 +101,10 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
 {
        int err = -ENOMEM;
        pte_t *pte;
-       pmd_t *pmd;
-       pud_t *pud;
-       pgd_t *pgd;
        pte_t pte_val;
        spinlock_t *ptl;
 
-       BUG_ON(vma->vm_flags & VM_UNPAGED);
-
-       pgd = pgd_offset(mm, addr);
-       pud = pud_alloc(mm, pgd, addr);
-       if (!pud)
-               goto out;
-       pmd = pmd_alloc(mm, pud, addr);
-       if (!pmd)
-               goto out;
-       pte = pte_alloc_map_lock(mm, pmd, addr, &ptl);
+       pte = get_locked_pte(mm, addr, &ptl);
        if (!pte)
                goto out;
 
@@ -142,7 +115,13 @@ int install_file_pte(struct mm_struct *mm, struct vm_area_struct *vma,
 
        set_pte_at(mm, addr, pte, pgoff_to_pte(pgoff));
        pte_val = *pte;
-       update_mmu_cache(vma, addr, pte_val);
+       /*
+        * We don't need to run update_mmu_cache() here because the "file pte"
+        * being installed by install_file_pte() is not a real pte - it's a
+        * non-present entry (like a swap entry), noting what file offset should
+        * be mapped there when there's a fault (in a non-linear vma where
+        * that's not obvious).
+        */
        pte_unmap_unlock(pte, ptl);
        err = 0;
 out: