summaryrefslogtreecommitdiffstats
path: root/fs/dax.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-05-12 18:29:19 +0200
committerRoss Zwisler <ross.zwisler@linux.intel.com>2016-05-19 15:27:49 -0600
commitbc2466e4257369d0ebee2b6265070d323343fa72 (patch)
treedc3c050e1b7bde8f0c93b1eb0764750f10331fed /fs/dax.c
parentac401cc782429cc8560ce4840b1405d603740917 (diff)
downloadlinux-bc2466e4257369d0ebee2b6265070d323343fa72.tar.gz
linux-bc2466e4257369d0ebee2b6265070d323343fa72.tar.bz2
linux-bc2466e4257369d0ebee2b6265070d323343fa72.zip
dax: Use radix tree entry lock to protect cow faults
When doing cow faults, we cannot directly fill in PTE as we do for other faults as we rely on generic code to do proper accounting of the cowed page. We also have no page to lock to protect against races with truncate as other faults have and we need the protection to extend until the moment generic code inserts cowed page into PTE thus at that point we have no protection of fs-specific i_mmap_sem. So far we relied on using i_mmap_lock for the protection however that is completely special to cow faults. To make fault locking more uniform use DAX entry lock instead. Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Diffstat (limited to 'fs/dax.c')
-rw-r--r--fs/dax.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fs/dax.c b/fs/dax.c
index f43c3d806fb6..be74635e05a6 100644
--- 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)) {