From patchwork Tue May 29 14:46:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6867C602BF for ; Tue, 29 May 2018 14:48:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58FCF284C3 for ; Tue, 29 May 2018 14:48:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DA762860C; Tue, 29 May 2018 14:48:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE8F2284C3 for ; Tue, 29 May 2018 14:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936494AbeE2Os0 (ORCPT ); Tue, 29 May 2018 10:48:26 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:50828 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935583AbeE2Oqr (ORCPT ); Tue, 29 May 2018 10:46:47 -0400 Received: by mail-wm0-f66.google.com with SMTP id t11-v6so41425627wmt.0 for ; Tue, 29 May 2018 07:46:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=W07LBnJ/tBx7rhhLSkVFLGqSTze5RhHtD01gjcJ5qCg=; b=smiGdOBPsO2O6drv9bJsCyYZSVubzQ/dmykZt67vOuSiomOGdOEAoJmtzB05mqXo9v HknX2sRgl6MKGrCqfimHCb3hpCMcnHMHYqj4RFwZ4gESRcRPwKKY+Fo7yc57t3mJgGLc LxxlKfpJ0dlPDYXNAjc9sTBNAYiPMawhET1ahoJqJDrX4i9lxTHN9aZV/jW+fbAsm2Hs ZaRyo7GV9QZMmZwfDQhbk2EvYp9+4CcwUxZYABJtAww5y/KM0zjgEej9ur/z728KJmj+ +wpnEmw5nBB7gsdG8qp9IQ2wohh6jga9epCXrVoTePj9hgzz3dip5s8fuj+ROtlsjE79 /YBg== X-Gm-Message-State: ALKqPwdG+XXRD16Xuiuzkf5k3aWcOEO4vMjQaO9c0sp2X6xDNnXWRx0m R0CreHb9s0t5rRAFnbfwxOGgtg== X-Google-Smtp-Source: ADUXVKKxg9+J4BvriV8wC0tXec3QUcZWH9spw1S/RuvqxGJTLOELDHRoNSWvYXa/Mb2sm4SW0HaV/g== X-Received: by 2002:a1c:95d3:: with SMTP id x202-v6mr13181707wmd.52.1527605205814; Tue, 29 May 2018 07:46:45 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id n71-v6sm20942227wmi.14.2018.05.29.07.46.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:45 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 25/28] ovl: Disbale metacopy for MAP_SHARED mmap() Date: Tue, 29 May 2018 16:46:09 +0200 Message-Id: <20180529144612.16675-26-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144612.16675-1-mszeredi@redhat.com> References: <20180529144612.16675-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vivek Goyal When user chose the option of copying up a file when mmap(MAP_SHARED) happens, then do full copy up and not just metacopy. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/copy_up.c | 5 +++++ fs/overlayfs/file.c | 2 +- fs/overlayfs/overlayfs.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 8c05e9ad9782..c31f198bed99 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -867,6 +867,11 @@ int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags) return err; } +int ovl_copy_up_with_data(struct dentry *dentry) +{ + return ovl_copy_up_flags(dentry, O_WRONLY); +} + int ovl_copy_up(struct dentry *dentry) { return ovl_copy_up_flags(dentry, 0); diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index c7738ef492c8..953295774471 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -296,7 +296,7 @@ static int ovl_pre_mmap(struct file *file, unsigned long prot, * later. */ if ((flag & MAP_SHARED) && ovl_copy_up_shared(file_inode(file)->i_sb)) - err = ovl_copy_up(file_dentry(file)); + err = ovl_copy_up_with_data(file_dentry(file)); return err; } diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 24f1d0e8a178..93c84929d422 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -414,6 +414,7 @@ extern const struct file_operations ovl_file_operations; /* copy_up.c */ int ovl_copy_up(struct dentry *dentry); +int ovl_copy_up_with_data(struct dentry *dentry); int ovl_copy_up_flags(struct dentry *dentry, int flags); int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags); int ovl_copy_xattr(struct dentry *old, struct dentry *new);