From: John Stultz Date: Fri, 16 Dec 2011 02:51:04 +0000 (-0800) Subject: ashmem: Add shmem_set_file to mm/shmem.c X-Git-Tag: firefly_0821_release~4090^2~876 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=456b818a9e8cd3e2e8684858dd5082e932ac8b75;p=firefly-linux-kernel-4.4.55.git 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 CC: Colin Cross CC: Arve Hjønnevåg CC: Dima Zavin CC: Robert Love CC: Greg KH Signed-off-by: John Stultz --- diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index e681bdd9aa5f..4a7db762a2e1 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -317,22 +317,14 @@ 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) { - ret = shmem_zero_setup(vma); - if (ret) { - fput(asma->file); - goto out; - } + 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; } - if (vma->vm_file) - fput(vma->vm_file); - vma->vm_file = asma->file; - out: mutex_unlock(&ashmem_mutex); return ret; diff --git a/include/linux/mm.h b/include/linux/mm.h index e0c8528a41a4..bd5679ddcd3f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -908,6 +908,7 @@ extern void pagefault_out_of_memory(void); extern void show_free_areas(unsigned int flags); extern bool skip_free_areas_node(unsigned int flags, int nid); +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); diff --git a/mm/shmem.c b/mm/shmem.c index 5e6a8422658b..695db3b6216b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2950,6 +2950,14 @@ 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; +} + /** * shmem_zero_setup - setup a shared anonymous mapping * @vma: the vma to be mmapped is prepared by do_mmap_pgoff @@ -2963,10 +2971,7 @@ int shmem_zero_setup(struct vm_area_struct *vma) if (IS_ERR(file)) return PTR_ERR(file); - if (vma->vm_file) - fput(vma->vm_file); - vma->vm_file = file; - vma->vm_ops = &shmem_vm_ops; + shmem_set_file(vma, file); return 0; }