From patchwork Fri Dec 16 02:50:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 5797 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 BF40023E0E for ; Fri, 16 Dec 2011 02:51:27 +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 AF920A182C3 for ; Fri, 16 Dec 2011 02:51:27 +0000 (UTC) Received: by mail-ee0-f52.google.com with SMTP id e52so3170980eek.11 for ; Thu, 15 Dec 2011 18:51:27 -0800 (PST) Received: by 10.204.131.74 with SMTP id w10mr2612308bks.36.1324003887497; Thu, 15 Dec 2011 18:51:27 -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 hg2cs59559bkc; Thu, 15 Dec 2011 18:51:27 -0800 (PST) Received: by 10.68.74.69 with SMTP id r5mr13278420pbv.118.1324003884980; Thu, 15 Dec 2011 18:51:24 -0800 (PST) Received: from e36.co.us.ibm.com (e36.co.us.ibm.com. [32.97.110.154]) by mx.google.com with ESMTPS id j7si12461114pbd.133.2011.12.15.18.51.24 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Dec 2011 18:51:24 -0800 (PST) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.154 as permitted sender) client-ip=32.97.110.154; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.110.154 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from /spool/local by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Dec 2011 19:51:23 -0700 Received: from d03relay01.boulder.ibm.com (9.17.195.226) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Dec 2011 19:51:16 -0700 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pBG2pGdb128466; Thu, 15 Dec 2011 19:51:16 -0700 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pBG2pDu1017597; Thu, 15 Dec 2011 19:51:15 -0700 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id pBG2pCqt017555; Thu, 15 Dec 2011 19:51:13 -0700 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 3B5CD1E74FE; 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: [PATCH 03/10] ashmem: Avoid touching mm/shmem.c while we're in staging Date: Thu, 15 Dec 2011 18:50:57 -0800 Message-Id: <1324003864-26776-4-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-3352-0000-0000-00000163CD55 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 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, 20 insertions(+), 17 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 34a5f8b..5775c6c 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -247,13 +247,21 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma) } get_file(asma->file); - 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; + /* + * 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_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 b880638..4baadd1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -872,7 +872,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); diff --git a/mm/shmem.c b/mm/shmem.c index 7adc113..1e4fdd7 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -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; }