diff options
Diffstat (limited to 'mm/memory.c')
-rw-r--r-- | mm/memory.c | 33 |
1 files changed, 6 insertions, 27 deletions
diff --git a/mm/memory.c b/mm/memory.c index 6953d3926e01..9b8a01d941cb 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -305,6 +305,7 @@ int __tlb_remove_page(struct mmu_gather *tlb, struct page *page) | |||
305 | if (batch->nr == batch->max) { | 305 | if (batch->nr == batch->max) { |
306 | if (!tlb_next_batch(tlb)) | 306 | if (!tlb_next_batch(tlb)) |
307 | return 0; | 307 | return 0; |
308 | batch = tlb->active; | ||
308 | } | 309 | } |
309 | VM_BUG_ON(batch->nr > batch->max); | 310 | VM_BUG_ON(batch->nr > batch->max); |
310 | 311 | ||
@@ -1112,11 +1113,13 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, | |||
1112 | int force_flush = 0; | 1113 | int force_flush = 0; |
1113 | int rss[NR_MM_COUNTERS]; | 1114 | int rss[NR_MM_COUNTERS]; |
1114 | spinlock_t *ptl; | 1115 | spinlock_t *ptl; |
1116 | pte_t *start_pte; | ||
1115 | pte_t *pte; | 1117 | pte_t *pte; |
1116 | 1118 | ||
1117 | again: | 1119 | again: |
1118 | init_rss_vec(rss); | 1120 | init_rss_vec(rss); |
1119 | pte = pte_offset_map_lock(mm, pmd, addr, &ptl); | 1121 | start_pte = pte_offset_map_lock(mm, pmd, addr, &ptl); |
1122 | pte = start_pte; | ||
1120 | arch_enter_lazy_mmu_mode(); | 1123 | arch_enter_lazy_mmu_mode(); |
1121 | do { | 1124 | do { |
1122 | pte_t ptent = *pte; | 1125 | pte_t ptent = *pte; |
@@ -1196,7 +1199,7 @@ again: | |||
1196 | 1199 | ||
1197 | add_mm_rss_vec(mm, rss); | 1200 | add_mm_rss_vec(mm, rss); |
1198 | arch_leave_lazy_mmu_mode(); | 1201 | arch_leave_lazy_mmu_mode(); |
1199 | pte_unmap_unlock(pte - 1, ptl); | 1202 | pte_unmap_unlock(start_pte, ptl); |
1200 | 1203 | ||
1201 | /* | 1204 | /* |
1202 | * mmu_gather ran out of room to batch pages, we break out of | 1205 | * mmu_gather ran out of room to batch pages, we break out of |
@@ -1296,7 +1299,7 @@ static unsigned long unmap_page_range(struct mmu_gather *tlb, | |||
1296 | 1299 | ||
1297 | /** | 1300 | /** |
1298 | * unmap_vmas - unmap a range of memory covered by a list of vma's | 1301 | * unmap_vmas - unmap a range of memory covered by a list of vma's |
1299 | * @tlbp: address of the caller's struct mmu_gather | 1302 | * @tlb: address of the caller's struct mmu_gather |
1300 | * @vma: the starting vma | 1303 | * @vma: the starting vma |
1301 | * @start_addr: virtual address at which to start unmapping | 1304 | * @start_addr: virtual address at which to start unmapping |
1302 | * @end_addr: virtual address at which to end unmapping | 1305 | * @end_addr: virtual address at which to end unmapping |
@@ -2796,30 +2799,6 @@ void unmap_mapping_range(struct address_space *mapping, | |||
2796 | } | 2799 | } |
2797 | EXPORT_SYMBOL(unmap_mapping_range); | 2800 | EXPORT_SYMBOL(unmap_mapping_range); |
2798 | 2801 | ||
2799 | int vmtruncate_range(struct inode *inode, loff_t offset, loff_t end) | ||
2800 | { | ||
2801 | struct address_space *mapping = inode->i_mapping; | ||
2802 | |||
2803 | /* | ||
2804 | * If the underlying filesystem is not going to provide | ||
2805 | * a way to truncate a range of blocks (punch a hole) - | ||
2806 | * we should return failure right now. | ||
2807 | */ | ||
2808 | if (!inode->i_op->truncate_range) | ||
2809 | return -ENOSYS; | ||
2810 | |||
2811 | mutex_lock(&inode->i_mutex); | ||
2812 | down_write(&inode->i_alloc_sem); | ||
2813 | unmap_mapping_range(mapping, offset, (end - offset), 1); | ||
2814 | truncate_inode_pages_range(mapping, offset, end); | ||
2815 | unmap_mapping_range(mapping, offset, (end - offset), 1); | ||
2816 | inode->i_op->truncate_range(inode, offset, end); | ||
2817 | up_write(&inode->i_alloc_sem); | ||
2818 | mutex_unlock(&inode->i_mutex); | ||
2819 | |||
2820 | return 0; | ||
2821 | } | ||
2822 | |||
2823 | /* | 2802 | /* |
2824 | * We enter with non-exclusive mmap_sem (to exclude vma changes, | 2803 | * We enter with non-exclusive mmap_sem (to exclude vma changes, |
2825 | * but allow concurrent faults), and pte mapped but not yet locked. | 2804 | * but allow concurrent faults), and pte mapped but not yet locked. |