From patchwork Fri Dec 16 02:51:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5795 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3109923E0E for ; Fri, 16 Dec 2011 02:51:24 +0000 (UTC) Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com [74.125.83.52]) by fiordland.canonical.com (Postfix) with ESMTP id 2649FA18971 for ; Fri, 16 Dec 2011 02:51:24 +0000 (UTC) Received: by eeke52 with SMTP id e52so3170980eek.11 for ; Thu, 15 Dec 2011 18:51:24 -0800 (PST) Received: by 10.204.133.213 with SMTP id g21mr2603625bkt.126.1324003883884; Thu, 15 Dec 2011 18:51:23 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.129.2 with SMTP id hg2cs59557bkc; Thu, 15 Dec 2011 18:51:23 -0800 (PST) Received: by 10.68.75.130 with SMTP id c2mr13295856pbw.92.1324003880793; Thu, 15 Dec 2011 18:51:20 -0800 (PST) Received: from e3.ny.us.ibm.com (e3.ny.us.ibm.com. [32.97.182.143]) by mx.google.com with ESMTPS id o4si12441271pbg.190.2011.12.15.18.51.19 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Dec 2011 18:51:20 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.143 as permitted sender) client-ip=32.97.182.143; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.143 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e3.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Dec 2011 21:51:19 -0500 Received: from d01relay06.pok.ibm.com (9.56.227.116) by e3.ny.us.ibm.com (192.168.1.103) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Dec 2011 21:51:16 -0500 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBG2pF9f1573104; Thu, 15 Dec 2011 21:51:15 -0500 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBG2pFHP031776; Thu, 15 Dec 2011 21:51:15 -0500 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av04.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBG2pElX031534; Thu, 15 Dec 2011 21:51:14 -0500 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 79E2B1E7506; Thu, 15 Dec 2011 18:51:12 -0800 (PST) From: John Stultz To: =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= Cc: John Stultz , Brian Swetland , Colin Cross , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Dima Zavin , Robert Love , Greg KH Subject: =?UTF-8?q?=5BPATCH=2010/10=5D=20ashmem=3A=20Add=20shmem=5Fset=5Ffile=20to=20mm/shmem=2Ec?= Date: Thu, 15 Dec 2011 18:51:04 -0800 Message-Id: <1324003864-26776-11-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1324003864-26776-1-git-send-email-john.stultz@linaro.org> References: <1324003864-26776-1-git-send-email-john.stultz@linaro.org> MIME-Version: 1.0 x-cbid: 11121602-8974-0000-0000-000004482142 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 --- drivers/staging/android/ashmem.c | 20 ++++++-------------- include/linux/mm.h | 1 + mm/shmem.c | 16 ++++++++++------ 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 99052bf..f5212a1 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -314,21 +314,13 @@ 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; vma->vm_flags |= VM_CAN_NONLINEAR; out: diff --git a/include/linux/mm.h b/include/linux/mm.h index 4baadd1..b880638 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -872,6 +872,7 @@ 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); diff --git a/mm/shmem.c b/mm/shmem.c index 1e4fdd7..7adc113 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2526,6 +2526,15 @@ 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 @@ -2539,12 +2548,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; - vma->vm_flags |= VM_CAN_NONLINEAR; - + shmem_set_file(vma, file); return 0; }