From patchwork Tue May 29 14:45:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435815 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 C089E60327 for ; Tue, 29 May 2018 14:53:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B25CB28437 for ; Tue, 29 May 2018 14:53:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7675285C5; Tue, 29 May 2018 14:53:38 +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 4C5CD28437 for ; Tue, 29 May 2018 14:53:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936550AbeE2Oxe (ORCPT ); Tue, 29 May 2018 10:53:34 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55279 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936593AbeE2Oq3 (ORCPT ); Tue, 29 May 2018 10:46:29 -0400 Received: by mail-wm0-f66.google.com with SMTP id f6-v6so41372791wmc.4 for ; Tue, 29 May 2018 07:46:29 -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=i9xqLL9YlFuu8rvFxb/N5aIkc9LvneQle6Fwc7e270Y=; b=VL8xCEvI4usiyDwjOZgqnXAiQdW+cJi2DynC7TP9g8VUasvcsjyPFhahVhcwlUtqhT PcmD1bVkC1aoTSyNGgnWT1b7Id8Vo46UPZwi1OdwVT+YeEx46N27WlINv3GqnIhHHaLx yz8oVEZBIJgGaM+CdnsZRQWoOpILiMs4WR/j6UvZgrRHwQMWcRNV3eDg0chbzIOmZAdX zcPdzrMBJ5IdvXwZ9fRj099Cu1TE+lBMbUDbbirZnFwaOzccAdImomacCYDxXDe1NJAs yYLplxBhNNMA7VolKOz4xiO9SP3YLmfdhTrysPXeDFpQIVZnbqHAxny947NAEtk9OcVG SiKg== X-Gm-Message-State: ALKqPwctWBwq8d8ZN0B2EmLNOpRponlIODAOIRSA+gxjMWBofbcfguwp fE4btlyGzZz7NkE+FgQeiXCaNo7DHro= X-Google-Smtp-Source: ADUXVKLIBTuPzZHoVB36VJRXBb/suaHmvffSDksqmyV9zUMjx4L3gJ3+hTLCv0WZlgJkaZFp+UCMGg== X-Received: by 2002:a1c:d046:: with SMTP id h67-v6mr11304922wmg.80.1527605188469; Tue, 29 May 2018 07:46:28 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:27 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/28] ovl: Add helper ovl_dentry_lowerdata() to get lower data dentry Date: Tue, 29 May 2018 16:45:55 +0200 Message-Id: <20180529144612.16675-12-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 Now we have the notion of data dentry and metacopy dentry. ovl_dentry_lower() will return uppermost lower dentry, but it could be either data or metacopy dentry. Now we support metacopy dentries in lower layers so it is possible that lowerstack[0] is metacopy dentry while lowerstack[1] is actual data dentry. So add an helper which returns lowest most dentry which is supposed to be data dentry. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/overlayfs.h | 1 + fs/overlayfs/util.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 31795c041d61..13b2151cf4df 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -221,6 +221,7 @@ 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); +struct dentry *ovl_dentry_lowerdata(struct dentry *dentry); struct ovl_layer *ovl_layer_lower(struct dentry *dentry); struct dentry *ovl_dentry_real(struct dentry *dentry); struct dentry *ovl_i_dentry_upper(struct inode *inode); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 32ff67fa0bfb..7c7b95d5da1f 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -207,6 +207,19 @@ struct ovl_layer *ovl_layer_lower(struct dentry *dentry) return oe->numlower ? oe->lowerstack[0].layer : NULL; } +/* + * ovl_dentry_lower() could return either a data dentry or metacopy dentry + * dependig on what is stored in lowerstack[0]. At times we need to find + * lower dentry which has data (and not metacopy dentry). This helper + * returns the lower data dentry. + */ +struct dentry *ovl_dentry_lowerdata(struct dentry *dentry) +{ + struct ovl_entry *oe = dentry->d_fsdata; + + return oe->numlower ? oe->lowerstack[oe->numlower - 1].dentry : NULL; +} + struct dentry *ovl_dentry_real(struct dentry *dentry) { return ovl_dentry_upper(dentry) ?: ovl_dentry_lower(dentry);