ashmem: Add shmem_set_file to mm/shmem.c
NOT FOR STAGING This patch re-adds the original shmem_set_file to mm/shmem.c and converts ashmem.c back to using it. 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>
This commit is contained in:
@@ -314,21 +314,13 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
|
|||||||
}
|
}
|
||||||
get_file(asma->file);
|
get_file(asma->file);
|
||||||
|
|
||||||
/*
|
if (vma->vm_flags & VM_SHARED)
|
||||||
* XXX - Reworked to use shmem_zero_setup() instead of
|
shmem_set_file(vma, asma->file);
|
||||||
* shmem_set_file while we're in staging. -jstultz
|
else {
|
||||||
*/
|
if (vma->vm_file)
|
||||||
if (vma->vm_flags & VM_SHARED) {
|
fput(vma->vm_file);
|
||||||
ret = shmem_zero_setup(vma);
|
vma->vm_file = asma->file;
|
||||||
if (ret) {
|
|
||||||
fput(asma->file);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vma->vm_file)
|
|
||||||
fput(vma->vm_file);
|
|
||||||
vma->vm_file = asma->file;
|
|
||||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
vma->vm_flags |= VM_CAN_NONLINEAR;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|||||||
@@ -873,6 +873,7 @@ extern bool skip_free_areas_node(unsigned int flags, int nid);
|
|||||||
|
|
||||||
int shmem_lock(struct file *file, int lock, struct user_struct *user);
|
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);
|
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 *);
|
int shmem_zero_setup(struct vm_area_struct *);
|
||||||
|
|
||||||
extern int can_do_mlock(void);
|
extern int can_do_mlock(void);
|
||||||
|
|||||||
15
mm/shmem.c
15
mm/shmem.c
@@ -2606,6 +2606,15 @@ put_memory:
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(shmem_file_setup);
|
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
|
* shmem_zero_setup - setup a shared anonymous mapping
|
||||||
* @vma: the vma to be mmapped is prepared by do_mmap_pgoff
|
* @vma: the vma to be mmapped is prepared by do_mmap_pgoff
|
||||||
@@ -2619,11 +2628,7 @@ int shmem_zero_setup(struct vm_area_struct *vma)
|
|||||||
if (IS_ERR(file))
|
if (IS_ERR(file))
|
||||||
return PTR_ERR(file);
|
return PTR_ERR(file);
|
||||||
|
|
||||||
if (vma->vm_file)
|
shmem_set_file(vma, file);
|
||||||
fput(vma->vm_file);
|
|
||||||
vma->vm_file = file;
|
|
||||||
vma->vm_ops = &shmem_vm_ops;
|
|
||||||
vma->vm_flags |= VM_CAN_NONLINEAR;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user