dax: Use radix tree entry lock to protect cow faults
[sfrench/cifs-2.6.git] / fs / dax.c
index f43c3d806fb6e61ab11269fe5145787412af90d0..be74635e05a6b8362559734708a23b1f2a4399e7 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -478,7 +478,7 @@ void dax_wake_mapping_entry_waiter(struct address_space *mapping,
        }
 }
 
-static void unlock_mapping_entry(struct address_space *mapping, pgoff_t index)
+void dax_unlock_mapping_entry(struct address_space *mapping, pgoff_t index)
 {
        void *ret, **slot;
 
@@ -501,7 +501,7 @@ static void put_locked_mapping_entry(struct address_space *mapping,
                unlock_page(entry);
                put_page(entry);
        } else {
-               unlock_mapping_entry(mapping, index);
+               dax_unlock_mapping_entry(mapping, index);
        }
 }
 
@@ -884,12 +884,10 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf,
                        goto unlock_entry;
                if (!radix_tree_exceptional_entry(entry)) {
                        vmf->page = entry;
-               } else {
-                       unlock_mapping_entry(mapping, vmf->pgoff);
-                       i_mmap_lock_read(mapping);
-                       vmf->page = NULL;
+                       return VM_FAULT_LOCKED;
                }
-               return VM_FAULT_LOCKED;
+               vmf->entry = entry;
+               return VM_FAULT_DAX_LOCKED;
        }
 
        if (!buffer_mapped(&bh)) {