Commit bc4866b6 authored by Trond Myklebust's avatar Trond Myklebust

NFS: Don't SIGBUS if nfs_vm_page_mkwrite races with a cache invalidation

In the case where we lock the page, and then find out that the page has
been thrown out of the page cache, we should just return VM_FAULT_NOPAGE.
This is what block_page_mkwrite() does in these situations.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
Cc: stable@kernel.org
parent 955a857e
...@@ -551,7 +551,7 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -551,7 +551,7 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
struct file *filp = vma->vm_file; struct file *filp = vma->vm_file;
struct dentry *dentry = filp->f_path.dentry; struct dentry *dentry = filp->f_path.dentry;
unsigned pagelen; unsigned pagelen;
int ret = -EINVAL; int ret = VM_FAULT_NOPAGE;
struct address_space *mapping; struct address_space *mapping;
dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n", dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n",
...@@ -567,21 +567,20 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) ...@@ -567,21 +567,20 @@ static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
if (mapping != dentry->d_inode->i_mapping) if (mapping != dentry->d_inode->i_mapping)
goto out_unlock; goto out_unlock;
ret = 0;
pagelen = nfs_page_length(page); pagelen = nfs_page_length(page);
if (pagelen == 0) if (pagelen == 0)
goto out_unlock; goto out_unlock;
ret = nfs_flush_incompatible(filp, page); ret = VM_FAULT_LOCKED;
if (ret != 0) if (nfs_flush_incompatible(filp, page) == 0 &&
goto out_unlock; nfs_updatepage(filp, page, 0, pagelen) == 0)
goto out;
ret = nfs_updatepage(filp, page, 0, pagelen); ret = VM_FAULT_SIGBUS;
out_unlock: out_unlock:
if (!ret)
return VM_FAULT_LOCKED;
unlock_page(page); unlock_page(page);
return VM_FAULT_SIGBUS; out:
return ret;
} }
static const struct vm_operations_struct nfs_file_vm_ops = { static const struct vm_operations_struct nfs_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