Commit a1e09612 authored by Nick Piggin's avatar Nick Piggin Committed by Linus Torvalds

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: default avatarNick Piggin <npiggin@suse.de>
Cc: Tom Zanussi <zanussi@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f2df3f65
...@@ -37,37 +37,31 @@ static void relay_file_mmap_close(struct vm_area_struct *vma) ...@@ -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, static int relay_buf_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
unsigned long address,
int *type)
{ {
struct page *page; struct page *page;
struct rchan_buf *buf = vma->vm_private_data; 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) 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) if (!page)
return NOPAGE_OOM; return VM_FAULT_SIGBUS;
get_page(page); get_page(page);
vmf->page = page;
if (type) return 0;
*type = VM_FAULT_MINOR;
return page;
} }
/* /*
* vm_ops for relay file mappings. * vm_ops for relay file mappings.
*/ */
static struct vm_operations_struct relay_file_mmap_ops = { static struct vm_operations_struct relay_file_mmap_ops = {
.nopage = relay_buf_nopage, .fault = relay_buf_fault,
.close = relay_file_mmap_close, .close = relay_file_mmap_close,
}; };
......
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