Commit cca24370 authored by Miklos Szeredi's avatar Miklos Szeredi
Browse files

fuse: lock page in mkwrite



Lock the page in fuse_page_mkwrite() to protect against a race with
fuse_writepage() where the page is redirtied before the actual writeback
begins.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
parent 385b1268
...@@ -1618,14 +1618,17 @@ static void fuse_vma_close(struct vm_area_struct *vma) ...@@ -1618,14 +1618,17 @@ static void fuse_vma_close(struct vm_area_struct *vma)
static int fuse_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) static int fuse_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
{ {
struct page *page = vmf->page; struct page *page = vmf->page;
/* struct inode *inode = file_inode(vma->vm_file);
* Don't use page->mapping as it may become NULL from a
* concurrent truncate. file_update_time(vma->vm_file);
*/ lock_page(page);
struct inode *inode = vma->vm_file->f_mapping->host; if (page->mapping != inode->i_mapping) {
unlock_page(page);
return VM_FAULT_NOPAGE;
}
fuse_wait_on_page_writeback(inode, page->index); fuse_wait_on_page_writeback(inode, page->index);
return 0; return VM_FAULT_LOCKED;
} }
static const struct vm_operations_struct fuse_file_vm_ops = { static const struct vm_operations_struct fuse_file_vm_ops = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment