diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-11-24 07:43:18 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-11 06:30:22 -0500 |
commit | 1a0ef85f84feb13f07b604fcf5b90ef7c2b5c82f (patch) | |
tree | 2d2ec02c42d69ffbf1c3d027cd8dbd8634754942 /mm/mremap.c | |
parent | ecc1a8993751de4e82eb18640d631dae1f626bd6 (diff) |
do_mremap() untangling, part 3
Take the check for being able to expand vma in place into a separate
helper.
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm/mremap.c')
-rw-r--r-- | mm/mremap.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/mm/mremap.c b/mm/mremap.c index 5f346178f16f..90e422c9f410 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -366,6 +366,17 @@ out: | |||
366 | return ret; | 366 | return ret; |
367 | } | 367 | } |
368 | 368 | ||
369 | static int vma_expandable(struct vm_area_struct *vma, unsigned long delta) | ||
370 | { | ||
371 | unsigned long max_addr = TASK_SIZE; | ||
372 | if (vma->vm_next) | ||
373 | max_addr = vma->vm_next->vm_start; | ||
374 | if (max_addr - vma->vm_end < delta) | ||
375 | return 0; | ||
376 | /* we need to do arch-specific checks here */ | ||
377 | return 1; | ||
378 | } | ||
379 | |||
369 | /* | 380 | /* |
370 | * Expand (or shrink) an existing mapping, potentially moving it at the | 381 | * Expand (or shrink) an existing mapping, potentially moving it at the |
371 | * same time (controlled by the MREMAP_MAYMOVE flag and available VM space) | 382 | * same time (controlled by the MREMAP_MAYMOVE flag and available VM space) |
@@ -430,11 +441,8 @@ unsigned long do_mremap(unsigned long addr, | |||
430 | /* old_len exactly to the end of the area.. | 441 | /* old_len exactly to the end of the area.. |
431 | */ | 442 | */ |
432 | if (old_len == vma->vm_end - addr) { | 443 | if (old_len == vma->vm_end - addr) { |
433 | unsigned long max_addr = TASK_SIZE; | ||
434 | if (vma->vm_next) | ||
435 | max_addr = vma->vm_next->vm_start; | ||
436 | /* can we just expand the current mapping? */ | 444 | /* can we just expand the current mapping? */ |
437 | if (max_addr - addr >= new_len) { | 445 | if (vma_expandable(vma, new_len - old_len)) { |
438 | int pages = (new_len - old_len) >> PAGE_SHIFT; | 446 | int pages = (new_len - old_len) >> PAGE_SHIFT; |
439 | 447 | ||
440 | vma_adjust(vma, vma->vm_start, | 448 | vma_adjust(vma, vma->vm_start, |