From patchwork Tue May 29 14:45:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435747 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 6DA73604D4 for ; Tue, 29 May 2018 14:46:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DA0B28643 for ; Tue, 29 May 2018 14:46:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 527B428653; Tue, 29 May 2018 14:46:49 +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 E6A2028643 for ; Tue, 29 May 2018 14:46:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936675AbeE2Oqq (ORCPT ); Tue, 29 May 2018 10:46:46 -0400 Received: from mail-wr0-f176.google.com ([209.85.128.176]:34811 "EHLO mail-wr0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936574AbeE2Oq2 (ORCPT ); Tue, 29 May 2018 10:46:28 -0400 Received: by mail-wr0-f176.google.com with SMTP id j1-v6so26001516wrm.1 for ; Tue, 29 May 2018 07:46:27 -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=012N5M0SWdtwBO8c5/j/puuB27evw5GYpoxUhgnV6XQ=; b=CyXjnKsMfB5MhMLuVO8Zw7tbU3qX/5m5bS65kl4Vfl/LUZyHF7QVbpLnm3QJZrBdTk hPi+Yty8cnlbcPKOc8hNFYb2pd3ZoAW9rO726RzyFRePnSyp9Fr9GM1VcxHIgvkZz31X tbi4ps69JrvP3A8dEiG6cSpX+WIPs5XKtMByc0000QJJq9w2XeJsR4F8NpwizqS3LtdV bxUEb71WevH9rrx+GGxz4pHCdIrq5+ksRgSuLh9A/WiFQ/qZ1bcP7Z+nuhpVsu6E0d1x DH3moB5JcPvUhHBfSK/lFx86Uevc9osVmbrpZuFVeLurNwOBIJOhdKsyYHUCIFL7ObhW 1taA== X-Gm-Message-State: ALKqPwdMKiLAlF17FMsYruB0gc8h4xRUMdFbvcDrM55K4NBYJxjUwuKy RE/yqkbvPmT5eoo57LGmzR5Tdg== X-Google-Smtp-Source: AB8JxZpsq+dJ/WyzJG+FERFHc8MkoRlZpvEhBgviHxSV/T6WpBNQkduNR/XshHtNHidu6htT+oeLQg== X-Received: by 2002:adf:b583:: with SMTP id c3-v6mr15170645wre.228.1527605187078; Tue, 29 May 2018 07:46:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:26 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/28] ovl: Copy up meta inode data from lowest data inode Date: Tue, 29 May 2018 16:45:54 +0200 Message-Id: <20180529144612.16675-11-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 So far lower could not be a meta inode. So whenever it was time to copy up data of a meta inode, we could copy it up from top most lower dentry. But now lower itself can be a metacopy inode. That means data copy up needs to take place from a data inode in metacopy inode chain. Find lower data inode in the chain and use that for data copy up. Introduced a helper called ovl_path_lowerdata() to find the lower data inode chain. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/copy_up.c | 13 +++++++++---- fs/overlayfs/overlayfs.h | 1 + fs/overlayfs/util.c | 12 ++++++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 7d01afd345e9..8c05e9ad9782 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -519,13 +519,14 @@ static int ovl_copy_up_inode(struct ovl_copy_up_ctx *c, struct dentry *temp) } if (S_ISREG(c->stat.mode) && !c->metacopy) { - struct path upperpath; + struct path upperpath, datapath; ovl_path_upper(c->dentry, &upperpath); BUG_ON(upperpath.dentry != NULL); upperpath.dentry = temp; - err = ovl_copy_up_data(&c->lowerpath, &upperpath, c->stat.size); + ovl_path_lowerdata(c->dentry, &datapath); + err = ovl_copy_up_data(&datapath, &upperpath, c->stat.size); if (err) return err; } @@ -706,14 +707,18 @@ static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode, /* Copy up data of an inode which was copied up metadata only in the past. */ static int ovl_copy_up_meta_inode_data(struct ovl_copy_up_ctx *c) { - struct path upperpath; + struct path upperpath, datapath; int err; ovl_path_upper(c->dentry, &upperpath); if (WARN_ON(upperpath.dentry == NULL)) return -EIO; - err = ovl_copy_up_data(&c->lowerpath, &upperpath, c->stat.size); + ovl_path_lowerdata(c->dentry, &datapath); + if (WARN_ON(datapath.dentry == NULL)) + return -EIO; + + err = ovl_copy_up_data(&datapath, &upperpath, c->stat.size); if (err) return err; diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index b1f6591b9af4..31795c041d61 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -217,6 +217,7 @@ bool ovl_dentry_weird(struct dentry *dentry); enum ovl_path_type ovl_path_type(struct dentry *dentry); void ovl_path_upper(struct dentry *dentry, struct path *path); void ovl_path_lower(struct dentry *dentry, struct path *path); +void ovl_path_lowerdata(struct dentry *dentry, struct path *path); enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path); struct dentry *ovl_dentry_upper(struct dentry *dentry); struct dentry *ovl_dentry_lower(struct dentry *dentry); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index ab9a8fae0f99..32ff67fa0bfb 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -164,6 +164,18 @@ void ovl_path_lower(struct dentry *dentry, struct path *path) } } +void ovl_path_lowerdata(struct dentry *dentry, struct path *path) +{ + struct ovl_entry *oe = dentry->d_fsdata; + + if (oe->numlower) { + path->mnt = oe->lowerstack[oe->numlower - 1].layer->mnt; + path->dentry = oe->lowerstack[oe->numlower - 1].dentry; + } else { + *path = (struct path) { }; + } +} + enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path) { enum ovl_path_type type = ovl_path_type(dentry);