mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
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 <[email protected]> Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Ross Zwisler <[email protected]>
This commit is contained in:
parent
ac401cc782
commit
bc2466e425
4 changed files with 37 additions and 27 deletions
12
fs/dax.c
12
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)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue