]>
Commit | Line | Data |
---|---|---|
dde97f1d GKH |
1 | From bc4866b6e0b44f8ea0df22a16e5927714beb4983 Mon Sep 17 00:00:00 2001 |
2 | From: Trond Myklebust <Trond.Myklebust@netapp.com> | |
3 | Date: Mon, 4 Oct 2010 17:59:08 -0400 | |
4 | Subject: NFS: Don't SIGBUS if nfs_vm_page_mkwrite races with a cache invalidation | |
5 | ||
6 | From: Trond Myklebust <Trond.Myklebust@netapp.com> | |
7 | ||
8 | commit bc4866b6e0b44f8ea0df22a16e5927714beb4983 upstream. | |
9 | ||
10 | In the case where we lock the page, and then find out that the page has | |
11 | been thrown out of the page cache, we should just return VM_FAULT_NOPAGE. | |
12 | This is what block_page_mkwrite() does in these situations. | |
13 | ||
14 | Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> | |
15 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
16 | ||
17 | --- | |
18 | fs/nfs/file.c | 17 ++++++++--------- | |
19 | 1 file changed, 8 insertions(+), 9 deletions(-) | |
20 | ||
21 | --- a/fs/nfs/file.c | |
22 | +++ b/fs/nfs/file.c | |
23 | @@ -551,7 +551,7 @@ static int nfs_vm_page_mkwrite(struct vm | |
24 | struct file *filp = vma->vm_file; | |
25 | struct dentry *dentry = filp->f_path.dentry; | |
26 | unsigned pagelen; | |
27 | - int ret = -EINVAL; | |
28 | + int ret = VM_FAULT_NOPAGE; | |
29 | struct address_space *mapping; | |
30 | ||
31 | dfprintk(PAGECACHE, "NFS: vm_page_mkwrite(%s/%s(%ld), offset %lld)\n", | |
32 | @@ -567,21 +567,20 @@ static int nfs_vm_page_mkwrite(struct vm | |
33 | if (mapping != dentry->d_inode->i_mapping) | |
34 | goto out_unlock; | |
35 | ||
36 | - ret = 0; | |
37 | pagelen = nfs_page_length(page); | |
38 | if (pagelen == 0) | |
39 | goto out_unlock; | |
40 | ||
41 | - ret = nfs_flush_incompatible(filp, page); | |
42 | - if (ret != 0) | |
43 | - goto out_unlock; | |
44 | + ret = VM_FAULT_LOCKED; | |
45 | + if (nfs_flush_incompatible(filp, page) == 0 && | |
46 | + nfs_updatepage(filp, page, 0, pagelen) == 0) | |
47 | + goto out; | |
48 | ||
49 | - ret = nfs_updatepage(filp, page, 0, pagelen); | |
50 | + ret = VM_FAULT_SIGBUS; | |
51 | out_unlock: | |
52 | - if (!ret) | |
53 | - return VM_FAULT_LOCKED; | |
54 | unlock_page(page); | |
55 | - return VM_FAULT_SIGBUS; | |
56 | +out: | |
57 | + return ret; | |
58 | } | |
59 | ||
60 | static const struct vm_operations_struct nfs_file_vm_ops = { |