This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / mm / fremap.c
index dc64dd9..e9282de 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/swapops.h>
 #include <linux/rmap.h>
 #include <linux/module.h>
+#include <linux/vs_memory.h>
 
 #include <asm/mmu_context.h>
 #include <asm/cacheflush.h>
@@ -38,7 +39,8 @@ static inline void zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
                                        set_page_dirty(page);
                                page_remove_rmap(page);
                                page_cache_release(page);
-                               mm->rss--;
+                               // mm->rss--;
+                               vx_rsspages_dec(mm);
                        }
                }
        } else {
@@ -55,8 +57,6 @@ static inline void zap_pte(struct mm_struct *mm, struct vm_area_struct *vma,
 int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
                unsigned long addr, struct page *page, pgprot_t prot)
 {
-       struct inode *inode;
-       pgoff_t size;
        int err = -ENOMEM;
        pte_t *pte;
        pgd_t *pgd;
@@ -66,6 +66,9 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
        pgd = pgd_offset(mm, addr);
        spin_lock(&mm->page_table_lock);
 
+       if (!vx_rsspages_avail(mm, 1))
+               goto err_unlock;
+
        pmd = pmd_alloc(mm, pgd, addr);
        if (!pmd)
                goto err_unlock;
@@ -74,19 +77,10 @@ int install_page(struct mm_struct *mm, struct vm_area_struct *vma,
        if (!pte)
                goto err_unlock;
 
-       /*
-        * This page may have been truncated. Tell the
-        * caller about it.
-        */
-       err = -EINVAL;
-       inode = vma->vm_file->f_mapping->host;
-       size = (i_size_read(inode) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
-       if (!page->mapping || page->index >= size)
-               goto err_unlock;
-
        zap_pte(mm, vma, addr, pte);
 
-       mm->rss++;
+       // mm->rss++;
+       vx_rsspages_inc(mm);
        flush_icache_page(vma, page);
        set_pte(pte, mk_pte(page, prot));
        page_add_file_rmap(page);
@@ -200,8 +194,7 @@ asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size,
         * or VM_LOCKED, but VM_LOCKED could be revoked later on).
         */
        if (vma && (vma->vm_flags & VM_SHARED) &&
-               (!vma->vm_private_data ||
-                       (vma->vm_flags & (VM_NONLINEAR|VM_RESERVED))) &&
+               (!vma->vm_private_data || (vma->vm_flags & VM_RESERVED)) &&
                vma->vm_ops && vma->vm_ops->populate &&
                        end > start && start >= vma->vm_start &&
                                end <= vma->vm_end) {