Received: by 10.192.165.148 with SMTP id m20csp3449419imm; Mon, 7 May 2018 12:29:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrS4X1ldtIfd2K+qETzU6COCxXO5Qd8PeMuJi/kG1TUqhfYoTP6K8Qv4kZ25r6zwkItOFPH X-Received: by 2002:a6b:954c:: with SMTP id x73-v6mr30618657iod.225.1525721369692; Mon, 07 May 2018 12:29:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525721369; cv=none; d=google.com; s=arc-20160816; b=lK2/I2SD+JH78hUSEG1CD22vNAynQiZnvinlglZlp+uXaoTL0fUsJxQPd4y3BUY9dH Gq/t7siv0HpCRVm78zL8l7EmxsJnn2JY7KjuhbO0wy//F+LQJE6n7mobH/U52VMDH7qn osuVCEmjCX24Jn6vdWNUeApABW8bAqJQOl5eI2j32XnDG8HKqXdNTL4LX2VQOSMPi8TY Mpv6O6kvudnTh0GHc1i3T1NrfdrAqYjmr0CGLCCV5mwtbOuiQkWXb3By/o3kPoJjFVTi pF4w9UyP3B0t+5iSCPfog/Kb986k04jFAWAaxq+EN7eVhl9cu8i8xAK2zR7eNdM7i4lG BIaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=G1lJ9HEP0GySqljPMyeht0Et3IMfUECW5pdykI7v2Hc=; b=riu3wjI4N1WTgnsar8MaZ6hcwVqWD6CKaX6OQnhNjOLw5coK5c510xFEDVARvNfu/P aX+/YODEMTxErsrJTDAvEKPi9LkJl5GSoWwmVNAm9+P9ihvK1LvfcsHiNcJVOB6f458C 68hoVt/Dsrfr/utvOownHbMLqMaKc6c3X2KCahlaJbDIehXUYfwW2mfpIHvEwxJ3BD3N Rov1tzOd5NjHgS77oQ5pnZGACccWwMHY8xm1nXQgbJ3+KjDYI7j2JQjBFHAmaq3blNeP Hip/dWPvDPJq70DLk0vL49EobS4lycTLu/gvK9/d4O6BuEZ3D6ngRcYnesMSAypnkbSR It4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=EkYpXa/c; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f126-v6si8203460itb.85.2018.05.07.12.29.16; Mon, 07 May 2018 12:29:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=EkYpXa/c; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752830AbeEGT2l (ORCPT + 99 others); Mon, 7 May 2018 15:28:41 -0400 Received: from merlin.infradead.org ([205.233.59.134]:53470 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752815AbeEGT2j (ORCPT ); Mon, 7 May 2018 15:28:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=G1lJ9HEP0GySqljPMyeht0Et3IMfUECW5pdykI7v2Hc=; b=EkYpXa/c3IFzXWfi2z5aoTw/t7 tcEetvFvTRS1l1Nzxfr3koV4EybkKoivPq5gDjWfer+r1w/zBrmzmZWCdFhzcXQ8wZ4Y0GqhJ2GD8 jsRSje3L00YErMzyX7lz5zXavt3gxcKdFIu+FtUCPVatQ+5SSO0Xkdqv515M4h+Gw72YzBtpy3g5S KfqD5thK1hTwZDnYkVi/hWMbD0rdYudMaNrHUJmtf2Xf+QvSVh4hAloZg16UOpWdt0qpGqeuo3ZWn xUJh/uh46XzyVM1Nfr0OsgXLVy/7Jbc37jMX+wzyFu3JoATIwNQ0B3MI0oZBa/y0dgmr4cEEkfxmu gbu/Rs0A==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fFloL-0007GU-Vo; Mon, 07 May 2018 19:28:38 +0000 Subject: Re: [PATCH v2 23/35] ovl: copy-up on MAP_SHARED To: Miklos Szeredi , linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180507083807.28792-1-mszeredi@redhat.com> <20180507083807.28792-24-mszeredi@redhat.com> From: Randy Dunlap Message-ID: <8f464b5f-a479-6bfe-3abf-b2ed6efe5eb6@infradead.org> Date: Mon, 7 May 2018 12:28:34 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180507083807.28792-24-mszeredi@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/07/2018 01:37 AM, Miklos Szeredi wrote: > A corner case of a corner case is when > > - file opened for O_RDONLY > - which is then memory mapped SHARED > - file opened for O_WRONLY > - contents modified > - contents read back though the shared mapping > > Unfortunately it looks very difficult to do anything about the established > shared map after the file is copied up. > > Instead, when a read-only file is mapped shared, copy up the file before > actually doing the map. This may result in unnecessary copy-ups (but so > may copy-up on open(O_RDWR) for exampe). for example). > > We can revisit this later if it turns out to be a performance problem in > real life. > > Signed-off-by: Miklos Szeredi > --- > fs/overlayfs/Kconfig | 21 +++++++++++++++++++++ > fs/overlayfs/file.c | 22 ++++++++++++++++++++++ > fs/overlayfs/overlayfs.h | 7 +++++++ > fs/overlayfs/ovl_entry.h | 1 + > fs/overlayfs/super.c | 22 ++++++++++++++++++++++ > 5 files changed, 73 insertions(+) > > diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig > index 17032631c5cf..991c0a5a0e00 100644 > --- a/fs/overlayfs/Kconfig > +++ b/fs/overlayfs/Kconfig > @@ -103,3 +103,24 @@ config OVERLAY_FS_XINO_AUTO > For more information, see Documentation/filesystems/overlayfs.txt > > If unsure, say N. > + > +config OVERLAY_FS_COPY_UP_SHARED > + bool "Overlayfs: copy up when mapping a file shared" a shared file" ?? > + default n > + depends on OVERLAY_FS > + help > + If this option is enabled then on mapping a file with MAP_SHARED > + overlayfs copies up the file in anticipation of it being modified (just > + like we copy up the file on O_WRONLY and O_RDWR in anticipation of > + modification). This does not interfere with shared library loading, as > + that uses MAP_PRIVATE. But there might be use cases out there where > + this impacts performance and disk usage. > + > + This just selects the default, the feature can also be enabled or > + disabled in the running kernel or individually on each overlay mount. > + > + To get maximally standard compliant behavior, enable this option. > + > + To get a maximally backward compatible kernel, disable this option. > + > + If unsure, say N. For Kconfig (coding-style.rst): Lines under a ``config`` definition are indented with one tab, while help text is indented an additional two spaces. -- ~Randy