dax: New fault locking
[sfrench/cifs-2.6.git] / mm / truncate.c
index b00272810871e1e62cc9eca33a06b15b3576a8c7..4064f8f53daa73aaca001747cbded8d9b451d7f7 100644 (file)
@@ -34,40 +34,38 @@ static void clear_exceptional_entry(struct address_space *mapping,
        if (shmem_mapping(mapping))
                return;
 
-       spin_lock_irq(&mapping->tree_lock);
-
        if (dax_mapping(mapping)) {
-               if (radix_tree_delete_item(&mapping->page_tree, index, entry))
-                       mapping->nrexceptional--;
-       } else {
-               /*
-                * Regular page slots are stabilized by the page lock even
-                * without the tree itself locked.  These unlocked entries
-                * need verification under the tree lock.
-                */
-               if (!__radix_tree_lookup(&mapping->page_tree, index, &node,
-                                       &slot))
-                       goto unlock;
-               if (*slot != entry)
-                       goto unlock;
-               radix_tree_replace_slot(slot, NULL);
-               mapping->nrexceptional--;
-               if (!node)
-                       goto unlock;
-               workingset_node_shadows_dec(node);
-               /*
-                * Don't track node without shadow entries.
-                *
-                * Avoid acquiring the list_lru lock if already untracked.
-                * The list_empty() test is safe as node->private_list is
-                * protected by mapping->tree_lock.
-                */
-               if (!workingset_node_shadows(node) &&
-                   !list_empty(&node->private_list))
-                       list_lru_del(&workingset_shadow_nodes,
-                                       &node->private_list);
-               __radix_tree_delete_node(&mapping->page_tree, node);
+               dax_delete_mapping_entry(mapping, index);
+               return;
        }
+       spin_lock_irq(&mapping->tree_lock);
+       /*
+        * Regular page slots are stabilized by the page lock even
+        * without the tree itself locked.  These unlocked entries
+        * need verification under the tree lock.
+        */
+       if (!__radix_tree_lookup(&mapping->page_tree, index, &node,
+                               &slot))
+               goto unlock;
+       if (*slot != entry)
+               goto unlock;
+       radix_tree_replace_slot(slot, NULL);
+       mapping->nrexceptional--;
+       if (!node)
+               goto unlock;
+       workingset_node_shadows_dec(node);
+       /*
+        * Don't track node without shadow entries.
+        *
+        * Avoid acquiring the list_lru lock if already untracked.
+        * The list_empty() test is safe as node->private_list is
+        * protected by mapping->tree_lock.
+        */
+       if (!workingset_node_shadows(node) &&
+           !list_empty(&node->private_list))
+               list_lru_del(&workingset_shadow_nodes,
+                               &node->private_list);
+       __radix_tree_delete_node(&mapping->page_tree, node);
 unlock:
        spin_unlock_irq(&mapping->tree_lock);
 }