]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - mm/rmap.c
h63xx: tsc2101 alsa sound support
[linux-2.6-omap-h63xx.git] / mm / rmap.c
index df2c41c2a9a2c1ac4d46b67c424a0001122a57ea..67f0e20b101ffbba34a8a3568374e14ab1a2bee8 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -212,25 +212,33 @@ out:
  * through real pte's pointing to valid pages and then releasing
  * the page from the swap cache.
  *
- * Must hold page lock on page.
+ * Must hold page lock on page and mmap_sem of one vma that contains
+ * the page.
  */
 void remove_from_swap(struct page *page)
 {
        struct anon_vma *anon_vma;
        struct vm_area_struct *vma;
+       unsigned long mapping;
 
-       if (!PageAnon(page) || !PageSwapCache(page))
+       if (!PageSwapCache(page))
                return;
 
-       anon_vma = page_lock_anon_vma(page);
-       if (!anon_vma)
+       mapping = (unsigned long)page->mapping;
+
+       if (!mapping || (mapping & PAGE_MAPPING_ANON) == 0)
                return;
 
+       /*
+        * We hold the mmap_sem lock. So no need to call page_lock_anon_vma.
+        */
+       anon_vma = (struct anon_vma *) (mapping - PAGE_MAPPING_ANON);
+       spin_lock(&anon_vma->lock);
+
        list_for_each_entry(vma, &anon_vma->head, anon_vma_node)
                remove_vma_swap(vma, page);
 
        spin_unlock(&anon_vma->lock);
-
        delete_from_swap_cache(page);
 }
 EXPORT_SYMBOL(remove_from_swap);
@@ -529,9 +537,6 @@ void page_add_new_anon_rmap(struct page *page,
  */
 void page_add_file_rmap(struct page *page)
 {
-       BUG_ON(PageAnon(page));
-       BUG_ON(!pfn_valid(page_to_pfn(page)));
-
        if (atomic_inc_and_test(&page->_mapcount))
                __inc_page_state(nr_mapped);
 }