Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356501
b: refs/heads/master
c: 940e7da
h: refs/heads/master
i:
  356499: f5237fe
v: v3
  • Loading branch information
Michel Lespinasse authored and Linus Torvalds committed Feb 24, 2013
1 parent 3b002e6 commit 497dd38
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dafcb73e385e39b9a7ebd5c4ecbc4ae921862eb9
refs/heads/master: 940e7da5163029978c2f6b5bbe213607add59062
22 changes: 14 additions & 8 deletions trunk/mm/fremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
/*
* Make sure the vma is shared, that it supports prefaulting,
* and that the remapped range is valid and fully within
* the single existing vma. vm_private_data is used as a
* swapout cursor in a VM_NONLINEAR vma.
* the single existing vma.
*/
if (!vma || !(vma->vm_flags & VM_SHARED))
goto out;

if (vma->vm_private_data && !(vma->vm_flags & VM_NONLINEAR))
goto out;

if (!vma->vm_ops || !vma->vm_ops->remap_pages)
goto out;

Expand All @@ -177,13 +173,21 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,

/* Must set VM_NONLINEAR before any pages are populated. */
if (!(vma->vm_flags & VM_NONLINEAR)) {
/*
* vm_private_data is used as a swapout cursor
* in a VM_NONLINEAR vma.
*/
if (vma->vm_private_data)
goto out;

/* Don't need a nonlinear mapping, exit success */
if (pgoff == linear_page_index(vma, start)) {
err = 0;
goto out;
}

if (!has_write_lock) {
get_write_lock:
up_read(&mm->mmap_sem);
down_write(&mm->mmap_sem);
has_write_lock = 1;
Expand All @@ -199,7 +203,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
unsigned long addr;
struct file *file = get_file(vma->vm_file);

flags &= MAP_NONBLOCK;
flags = (flags & MAP_NONBLOCK) | MAP_POPULATE;
addr = mmap_region(file, start, size,
flags, vma->vm_flags, pgoff);
fput(file);
Expand All @@ -225,20 +229,22 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
* drop PG_Mlocked flag for over-mapped range
*/
vm_flags_t saved_flags = vma->vm_flags;
if (!has_write_lock)
goto get_write_lock;
munlock_vma_pages_range(vma, start, start + size);
vma->vm_flags = saved_flags;
}

mmu_notifier_invalidate_range_start(mm, start, start + size);
err = vma->vm_ops->remap_pages(vma, start, size, pgoff);
mmu_notifier_invalidate_range_end(mm, start, start + size);
if (!err && !(flags & MAP_NONBLOCK)) {
if (!err) {
if (vma->vm_flags & VM_LOCKED) {
/*
* might be mapping previously unmapped range of file
*/
mlock_vma_pages_range(vma, start, start + size);
} else {
} else if (!(flags & MAP_NONBLOCK)) {
if (unlikely(has_write_lock)) {
downgrade_write(&mm->mmap_sem);
has_write_lock = 0;
Expand Down

0 comments on commit 497dd38

Please sign in to comment.