aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ramfs/file-nommu.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ramfs/file-nommu.c')
-rw-r--r--fs/ramfs/file-nommu.c29
1 files changed, 3 insertions, 26 deletions
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index 32fae4040ebf..5ea4ad81a429 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -21,6 +21,7 @@
21#include <linux/pagevec.h> 21#include <linux/pagevec.h>
22#include <linux/mman.h> 22#include <linux/mman.h>
23#include <linux/sched.h> 23#include <linux/sched.h>
24#include <linux/slab.h>
24 25
25#include <asm/uaccess.h> 26#include <asm/uaccess.h>
26#include "internal.h" 27#include "internal.h"
@@ -60,7 +61,7 @@ const struct inode_operations ramfs_file_inode_operations = {
60 */ 61 */
61int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize) 62int ramfs_nommu_expand_for_mapping(struct inode *inode, size_t newsize)
62{ 63{
63 unsigned long npages, xpages, loop, limit; 64 unsigned long npages, xpages, loop;
64 struct page *pages; 65 struct page *pages;
65 unsigned order; 66 unsigned order;
66 void *data; 67 void *data;
@@ -123,30 +124,6 @@ add_error:
123 124
124/*****************************************************************************/ 125/*****************************************************************************/
125/* 126/*
126 * check that file shrinkage doesn't leave any VMAs dangling in midair
127 */
128static int ramfs_nommu_check_mappings(struct inode *inode,
129 size_t newsize, size_t size)
130{
131 struct vm_area_struct *vma;
132 struct prio_tree_iter iter;
133
134 /* search for VMAs that fall within the dead zone */
135 vma_prio_tree_foreach(vma, &iter, &inode->i_mapping->i_mmap,
136 newsize >> PAGE_SHIFT,
137 (size + PAGE_SIZE - 1) >> PAGE_SHIFT
138 ) {
139 /* found one - only interested if it's shared out of the page
140 * cache */
141 if (vma->vm_flags & VM_SHARED)
142 return -ETXTBSY; /* not quite true, but near enough */
143 }
144
145 return 0;
146}
147
148/*****************************************************************************/
149/*
150 * 127 *
151 */ 128 */
152static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size) 129static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
@@ -164,7 +141,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
164 141
165 /* check that a decrease in size doesn't cut off any shared mappings */ 142 /* check that a decrease in size doesn't cut off any shared mappings */
166 if (newsize < size) { 143 if (newsize < size) {
167 ret = ramfs_nommu_check_mappings(inode, newsize, size); 144 ret = nommu_shrink_inode_mappings(inode, size, newsize);
168 if (ret < 0) 145 if (ret < 0)
169 return ret; 146 return ret;
170 } 147 }