summaryrefslogtreecommitdiff
path: root/kernel/relay.c
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2008-02-06 01:37:34 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 10:41:07 -0800
commita1e096129bff79ae551592539bef19bfb5c9efa1 (patch)
treea9a2058040b8fcae937f2bfb97fbb50a0a5c103c /kernel/relay.c
parentf2df3f65d0b4337cfb5b19eab3ee28b177427c49 (diff)
downloadlwn-a1e096129bff79ae551592539bef19bfb5c9efa1.tar.gz
lwn-a1e096129bff79ae551592539bef19bfb5c9efa1.zip
relay: nopage
Convert relay from nopage to fault. Remove redundant vma range checks. Switch from OOM to SIGBUS if the resource is not available. Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: Tom Zanussi <zanussi@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/relay.c')
-rw-r--r--kernel/relay.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/kernel/relay.c b/kernel/relay.c
index 7c0373322f18..d080b9d161a7 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -37,37 +37,31 @@ static void relay_file_mmap_close(struct vm_area_struct *vma)
}
/*
- * nopage() vm_op implementation for relay file mapping.
+ * fault() vm_op implementation for relay file mapping.
*/
-static struct page *relay_buf_nopage(struct vm_area_struct *vma,
- unsigned long address,
- int *type)
+static int relay_buf_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct page *page;
struct rchan_buf *buf = vma->vm_private_data;
- unsigned long offset = address - vma->vm_start;
+ pgoff_t pgoff = vmf->pgoff;
- if (address > vma->vm_end)
- return NOPAGE_SIGBUS; /* Disallow mremap */
if (!buf)
- return NOPAGE_OOM;
+ return VM_FAULT_OOM;
- page = vmalloc_to_page(buf->start + offset);
+ page = vmalloc_to_page(buf->start + (pgoff << PAGE_SHIFT));
if (!page)
- return NOPAGE_OOM;
+ return VM_FAULT_SIGBUS;
get_page(page);
+ vmf->page = page;
- if (type)
- *type = VM_FAULT_MINOR;
-
- return page;
+ return 0;
}
/*
* vm_ops for relay file mappings.
*/
static struct vm_operations_struct relay_file_mmap_ops = {
- .nopage = relay_buf_nopage,
+ .fault = relay_buf_fault,
.close = relay_file_mmap_close,
};