From patchwork Tue May 29 14:45:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435917 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 03FF7604D4 for ; Tue, 29 May 2018 15:03:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8DC328750 for ; Tue, 29 May 2018 15:03:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A78B328754; Tue, 29 May 2018 15:03:16 +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=unavailable 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 236AA288E5 for ; Tue, 29 May 2018 15:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935484AbeE2O7A (ORCPT ); Tue, 29 May 2018 10:59:00 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33246 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936517AbeE2OqV (ORCPT ); Tue, 29 May 2018 10:46:21 -0400 Received: by mail-wm0-f66.google.com with SMTP id x12-v6so48336440wmc.0 for ; Tue, 29 May 2018 07:46:21 -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=s1PcickK35rYO0JJUkWR8abNTSGhGNi2S+32Hr4sI60=; b=mKF00kn9uyt1Yg9P7ZKpq2CrBZ/i2xrQJIKre64zMEMaUG9FnQUKVEyi9/5izFOBLj J02Sxn4iRA07+zIqC0Ma+yB3JFCK6WNDPkkighDYF1RmNpKuKm3vey4yfnM081twkRRD 5zXMG48UqSbmBUlYoCgAwEtqrRfADM5LzBLaHXw7wu433VWwQZlNFpMMV01Nz44Hjefz NcAwsr5nsXXy/bgM6dsL/5fgNUlLiMedTOzoZnm1zjes01EIoNZsoir5B10JdkTkFY72 NPoHmdrXtzjnIvGpc1QjmnBajB7GLcHPund/pHBOoY0AWOor87TDA76YOHpqS0PKLKC/ f8Sg== X-Gm-Message-State: ALKqPwf/8+dLuype3vBJivi8xpfKT7RURyt3677vmZAFRPIK+v1Q2U4x VDqZbiUlDNrvDZwRGJZ2NulnGQ== X-Google-Smtp-Source: ADUXVKLaWITRuoT29wyYAOOTkHvusBOuh67y850KyeFHAwEN/jaYvK4rjxvpq+gggXf+J6td64G0FA== X-Received: by 2002:a1c:30ce:: with SMTP id w197-v6mr10355597wmw.22.1527605180578; Tue, 29 May 2018 07:46:20 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:19 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/28] ovl: Copy up only metadata during copy up where it makes sense Date: Tue, 29 May 2018 16:45:49 +0200 Message-Id: <20180529144612.16675-6-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 If it makes sense to copy up only metadata during copy up, do it. This is done for regular files which are not opened for WRITE. Right now ->metacopy is set to 0 always. Last patch in the series will remove the hard coded statement and enable metacopy feature. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/copy_up.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index c072a4c0cf08..38cfd1acc196 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -388,6 +388,7 @@ struct ovl_copy_up_ctx { bool tmpfile; bool origin; bool indexed; + bool metacopy; }; static int ovl_link_up(struct ovl_copy_up_ctx *c) @@ -507,7 +508,7 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) return err; } - if (S_ISREG(c->stat.mode)) { + if (S_ISREG(c->stat.mode) && !c->metacopy) { struct path upperpath; ovl_path_upper(c->dentry, &upperpath); @@ -660,6 +661,26 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c) return err; } +static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode, + int flags) +{ + struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + + /* TODO: Will enable metacopy in last patch of series */ + return false; + + if (!ofs->config.metacopy) + return false; + + if (!S_ISREG(mode)) + return false; + + if (flags && ((OPEN_FMODE(flags) & FMODE_WRITE) || (flags & O_TRUNC))) + return false; + + return true; +} + static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, int flags) { @@ -681,6 +702,8 @@ static int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, if (err) return err; + ctx.metacopy = ovl_need_meta_copy_up(dentry, ctx.stat.mode, flags); + if (parent) { ovl_path_upper(parent, &parentpath); ctx.destdir = parentpath.dentry;