diff options
author | Nick Piggin <npiggin@suse.de> | 2007-07-19 04:46:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 13:04:41 -0400 |
commit | 54cb8821de07f2ffcd28c380ce9b93d5784b40d7 (patch) | |
tree | 1de676534963d96af42863b20191bc9f80060dea /fs/gfs2/ops_vm.c | |
parent | d00806b183152af6d24f46f0c33f14162ca1262a (diff) |
mm: merge populate and nopage into fault (fixes nonlinear)
Nonlinear mappings are (AFAIKS) simply a virtual memory concept that encodes
the virtual address -> file offset differently from linear mappings.
->populate is a layering violation because the filesystem/pagecache code
should need to know anything about the virtual memory mapping. The hitch here
is that the ->nopage handler didn't pass down enough information (ie. pgoff).
But it is more logical to pass pgoff rather than have the ->nopage function
calculate it itself anyway (because that's a similar layering violation).
Having the populate handler install the pte itself is likewise a nasty thing
to be doing.
This patch introduces a new fault handler that replaces ->nopage and
->populate and (later) ->nopfn. Most of the old mechanism is still in place
so there is a lot of duplication and nice cleanups that can be removed if
everyone switches over.
The rationale for doing this in the first place is that nonlinear mappings are
subject to the pagefault vs invalidate/truncate race too, and it seemed stupid
to duplicate the synchronisation logic rather than just consolidate the two.
After this patch, MAP_NONBLOCK no longer sets up ptes for pages present in
pagecache. Seems like a fringe functionality anyway.
NOPAGE_REFAULT is removed. This should be implemented with ->fault, and no
users have hit mainline yet.
[akpm@linux-foundation.org: cleanup]
[randy.dunlap@oracle.com: doc. fixes for readahead]
[akpm@linux-foundation.org: build fix]
Signed-off-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Mark Fasheh <mark.fasheh@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/gfs2/ops_vm.c')
-rw-r--r-- | fs/gfs2/ops_vm.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/fs/gfs2/ops_vm.c b/fs/gfs2/ops_vm.c index d5a98cbfebdc..e9fe6eb74e75 100644 --- a/fs/gfs2/ops_vm.c +++ b/fs/gfs2/ops_vm.c | |||
@@ -27,13 +27,13 @@ | |||
27 | #include "trans.h" | 27 | #include "trans.h" |
28 | #include "util.h" | 28 | #include "util.h" |
29 | 29 | ||
30 | static struct page *gfs2_private_nopage(struct vm_area_struct *area, | 30 | static struct page *gfs2_private_fault(struct vm_area_struct *vma, |
31 | unsigned long address, int *type) | 31 | struct fault_data *fdata) |
32 | { | 32 | { |
33 | struct gfs2_inode *ip = GFS2_I(area->vm_file->f_mapping->host); | 33 | struct gfs2_inode *ip = GFS2_I(vma->vm_file->f_mapping->host); |
34 | 34 | ||
35 | set_bit(GIF_PAGED, &ip->i_flags); | 35 | set_bit(GIF_PAGED, &ip->i_flags); |
36 | return filemap_nopage(area, address, type); | 36 | return filemap_fault(vma, fdata); |
37 | } | 37 | } |
38 | 38 | ||
39 | static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) | 39 | static int alloc_page_backing(struct gfs2_inode *ip, struct page *page) |
@@ -104,16 +104,14 @@ out: | |||
104 | return error; | 104 | return error; |
105 | } | 105 | } |
106 | 106 | ||
107 | static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area, | 107 | static struct page *gfs2_sharewrite_fault(struct vm_area_struct *vma, |
108 | unsigned long address, int *type) | 108 | struct fault_data *fdata) |
109 | { | 109 | { |
110 | struct file *file = area->vm_file; | 110 | struct file *file = vma->vm_file; |
111 | struct gfs2_file *gf = file->private_data; | 111 | struct gfs2_file *gf = file->private_data; |
112 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); | 112 | struct gfs2_inode *ip = GFS2_I(file->f_mapping->host); |
113 | struct gfs2_holder i_gh; | 113 | struct gfs2_holder i_gh; |
114 | struct page *result = NULL; | 114 | struct page *result = NULL; |
115 | unsigned long index = ((address - area->vm_start) >> PAGE_CACHE_SHIFT) + | ||
116 | area->vm_pgoff; | ||
117 | int alloc_required; | 115 | int alloc_required; |
118 | int error; | 116 | int error; |
119 | 117 | ||
@@ -124,23 +122,27 @@ static struct page *gfs2_sharewrite_nopage(struct vm_area_struct *area, | |||
124 | set_bit(GIF_PAGED, &ip->i_flags); | 122 | set_bit(GIF_PAGED, &ip->i_flags); |
125 | set_bit(GIF_SW_PAGED, &ip->i_flags); | 123 | set_bit(GIF_SW_PAGED, &ip->i_flags); |
126 | 124 | ||
127 | error = gfs2_write_alloc_required(ip, (u64)index << PAGE_CACHE_SHIFT, | 125 | error = gfs2_write_alloc_required(ip, |
128 | PAGE_CACHE_SIZE, &alloc_required); | 126 | (u64)fdata->pgoff << PAGE_CACHE_SHIFT, |
129 | if (error) | 127 | PAGE_CACHE_SIZE, &alloc_required); |
128 | if (error) { | ||
129 | fdata->type = VM_FAULT_OOM; /* XXX: are these right? */ | ||
130 | goto out; | 130 | goto out; |
131 | } | ||
131 | 132 | ||
132 | set_bit(GFF_EXLOCK, &gf->f_flags); | 133 | set_bit(GFF_EXLOCK, &gf->f_flags); |
133 | result = filemap_nopage(area, address, type); | 134 | result = filemap_fault(vma, fdata); |
134 | clear_bit(GFF_EXLOCK, &gf->f_flags); | 135 | clear_bit(GFF_EXLOCK, &gf->f_flags); |
135 | if (!result || result == NOPAGE_OOM) | 136 | if (!result) |
136 | goto out; | 137 | goto out; |
137 | 138 | ||
138 | if (alloc_required) { | 139 | if (alloc_required) { |
139 | error = alloc_page_backing(ip, result); | 140 | error = alloc_page_backing(ip, result); |
140 | if (error) { | 141 | if (error) { |
141 | if (area->vm_flags & VM_CAN_INVALIDATE) | 142 | if (vma->vm_flags & VM_CAN_INVALIDATE) |
142 | unlock_page(result); | 143 | unlock_page(result); |
143 | page_cache_release(result); | 144 | page_cache_release(result); |
145 | fdata->type = VM_FAULT_OOM; | ||
144 | result = NULL; | 146 | result = NULL; |
145 | goto out; | 147 | goto out; |
146 | } | 148 | } |
@@ -154,10 +156,10 @@ out: | |||
154 | } | 156 | } |
155 | 157 | ||
156 | struct vm_operations_struct gfs2_vm_ops_private = { | 158 | struct vm_operations_struct gfs2_vm_ops_private = { |
157 | .nopage = gfs2_private_nopage, | 159 | .fault = gfs2_private_fault, |
158 | }; | 160 | }; |
159 | 161 | ||
160 | struct vm_operations_struct gfs2_vm_ops_sharewrite = { | 162 | struct vm_operations_struct gfs2_vm_ops_sharewrite = { |
161 | .nopage = gfs2_sharewrite_nopage, | 163 | .fault = gfs2_sharewrite_fault, |
162 | }; | 164 | }; |
163 | 165 | ||