@@ -247,13 +247,16 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
}
get_file(asma->file);
+ /*
+ * XXX - Reworked to use shmem_zero_setup() instead of
+ * shmem_set_file while we're in staging. -jstultz
+ */
if (vma->vm_flags & VM_SHARED)
- shmem_set_file(vma, asma->file);
- else {
- if (vma->vm_file)
- fput(vma->vm_file);
- vma->vm_file = asma->file;
- }
+ shmem_zero_setup(vma);
+
+ if (vma->vm_file)
+ fput(vma->vm_file);
+ vma->vm_file = asma->file;
vma->vm_flags |= VM_CAN_NONLINEAR;
out:
@@ -871,7 +871,6 @@ extern bool skip_free_areas_node(unsigned int flags, int nid);
int shmem_lock(struct file *file, int lock, struct user_struct *user);
struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags);
-void shmem_set_file(struct vm_area_struct *vma, struct file *file);
int shmem_zero_setup(struct vm_area_struct *);
extern int can_do_mlock(void);
@@ -2526,15 +2526,6 @@ put_memory:
}
EXPORT_SYMBOL_GPL(shmem_file_setup);
-void shmem_set_file(struct vm_area_struct *vma, struct file *file)
-{
- if (vma->vm_file)
- fput(vma->vm_file);
- vma->vm_file = file;
- vma->vm_ops = &shmem_vm_ops;
- vma->vm_flags |= VM_CAN_NONLINEAR;
-}
-
/**
* shmem_zero_setup - setup a shared anonymous mapping
* @vma: the vma to be mmapped is prepared by do_mmap_pgoff
@@ -2548,7 +2539,12 @@ int shmem_zero_setup(struct vm_area_struct *vma)
if (IS_ERR(file))
return PTR_ERR(file);
- shmem_set_file(vma, file);
+ if (vma->vm_file)
+ fput(vma->vm_file);
+ vma->vm_file = file;
+ vma->vm_ops = &shmem_vm_ops;
+ vma->vm_flags |= VM_CAN_NONLINEAR;
+
return 0;
}
This patch cuts out the mm/shmem.c modifications from the original ashmem patch, because while we're in staging we shouldn't be modifiying anything outside of the staging dir. This patch likely needs the closest review to ensure the shmem_file_set() replacement code is correct. NOTE: This patch will be folded into the previous before pushing the patch queue to staging. CC: Brian Swetland <swetland@google.com> CC: Colin Cross <ccross@android.com> CC: Arve Hjønnevåg <arve@android.com> CC: Dima Zavin <dima@android.com> CC: Robert Love <rlove@google.com> CC: Greg KH <greg@kroah.com> Signed-off-by: John Stultz <john.stultz@linaro.org> --- drivers/staging/android/ashmem.c | 15 +++++++++------ include/linux/mm.h | 1 - mm/shmem.c | 16 ++++++---------- 3 files changed, 15 insertions(+), 17 deletions(-)