config: tegra3: enable /dev mount with ACL
[linux-2.6.git] / mm / shmem.c
index 3a5be0f..fba53ca 100644 (file)
@@ -332,10 +332,14 @@ repeat:
                if (unlikely(!page))
                        continue;
                if (radix_tree_exception(page)) {
-                       if (radix_tree_exceptional_entry(page))
-                               goto export;
-                       /* radix_tree_deref_retry(page) */
-                       goto restart;
+                       if (radix_tree_deref_retry(page))
+                               goto restart;
+                       /*
+                        * Otherwise, we must be storing a swap entry
+                        * here as an exceptional entry: so return it
+                        * without attempting to raise page count.
+                        */
+                       goto export;
                }
                if (!page_cache_get_speculative(page))
                        goto repeat;
@@ -357,42 +361,6 @@ export:
 }
 
 /*
- * Lockless lookup of swap entry in radix tree, avoiding refcount on pages.
- */
-static pgoff_t shmem_find_swap(struct address_space *mapping, void *radswap)
-{
-       void  **slots[PAGEVEC_SIZE];
-       pgoff_t indices[PAGEVEC_SIZE];
-       unsigned int nr_found;
-
-restart:
-       nr_found = 1;
-       indices[0] = -1;
-       while (nr_found) {
-               pgoff_t index = indices[nr_found - 1] + 1;
-               unsigned int i;
-
-               rcu_read_lock();
-               nr_found = radix_tree_gang_lookup_slot(&mapping->page_tree,
-                                       slots, indices, index, PAGEVEC_SIZE);
-               for (i = 0; i < nr_found; i++) {
-                       void *item = radix_tree_deref_slot(slots[i]);
-                       if (radix_tree_deref_retry(item)) {
-                               rcu_read_unlock();
-                               goto restart;
-                       }
-                       if (item == radswap) {
-                               rcu_read_unlock();
-                               return indices[i];
-                       }
-               }
-               rcu_read_unlock();
-               cond_resched();
-       }
-       return -1;
-}
-
-/*
  * Remove swap entry from radix tree, free the swap and its page cache.
  */
 static int shmem_free_swap(struct address_space *mapping,
@@ -612,7 +580,7 @@ static int shmem_unuse_inode(struct shmem_inode_info *info,
        int error;
 
        radswap = swp_to_radix_entry(swap);
-       index = shmem_find_swap(mapping, radswap);
+       index = radix_tree_locate_item(&mapping->page_tree, radswap);
        if (index == -1)
                return 0;
 
@@ -2552,6 +2520,15 @@ put_memory:
 }
 EXPORT_SYMBOL_GPL(shmem_file_setup);
 
+void shmem_set_file(struct vm_area_struct *vma, struct file *file)
+{
+       if (vma->vm_file)
+               fput(vma->vm_file);
+       vma->vm_file = file;
+       vma->vm_ops = &shmem_vm_ops;
+       vma->vm_flags |= VM_CAN_NONLINEAR;
+}
+
 /**
  * shmem_zero_setup - setup a shared anonymous mapping
  * @vma: the vma to be mmapped is prepared by do_mmap_pgoff
@@ -2565,11 +2542,7 @@ int shmem_zero_setup(struct vm_area_struct *vma)
        if (IS_ERR(file))
                return PTR_ERR(file);
 
-       if (vma->vm_file)
-               fput(vma->vm_file);
-       vma->vm_file = file;
-       vma->vm_ops = &shmem_vm_ops;
-       vma->vm_flags |= VM_CAN_NONLINEAR;
+       shmem_set_file(vma, file);
        return 0;
 }