From patchwork Tue May 29 14:45:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10435843 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 99ADA60327 for ; Tue, 29 May 2018 14:58:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C873286F7 for ; Tue, 29 May 2018 14:58:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B38C28761; Tue, 29 May 2018 14:58:17 +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 2EE24286F7 for ; Tue, 29 May 2018 14:58:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936423AbeE2Ox0 (ORCPT ); Tue, 29 May 2018 10:53:26 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:37791 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936604AbeE2Oqd (ORCPT ); Tue, 29 May 2018 10:46:33 -0400 Received: by mail-wr0-f195.google.com with SMTP id i12-v6so26014511wrc.4 for ; Tue, 29 May 2018 07:46:32 -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=piun7pLqn9Ii1ipCp5eZlO7fYUHIsX4G+IG649VtG64=; b=fZnDhH6R+Ti+mW5scZH/QoHMwA2O92MzSNe8NKsUokfNI78L3eOFZXOxh6NhhjfwIK hIJVz6qW996SNQz8fBwbvjrOqrQGUEo53ng3fvOX/JErIUY8gMVwawDwwDOJ6oBgXbw6 aI3WsFqqkbyq8Y/hUpXF5PCiYJ5uwqIb0o7cEpIwaERZaPINVVhwh0hK8iFCgUluGs0g KePIeTqPYKRRUzadN5540UzH2pA4KWT0Gj5O8Cmb2xm5Q/WyVo9OrHolPpLxjaIIIgGK G9Mm/dz7BU5fCr04Qd7ZlwWpeKoUh64j08MDgpc7NnQaCzoP/CL9CUy7U0CEfrTzrADZ 4vUw== X-Gm-Message-State: ALKqPwd3tcuz66GhLo73J7vjxzx5d29/DvTCMWL3J3ySUgx3MlJW1Pdf KfrFHu1Q0KUP7aG37IfaXL/m+Q== X-Google-Smtp-Source: ADUXVKJhSFZinTq5jhqvozcROLaRYg9NNPA5FJI0sZKsz2sbBzHeEb8CVxGiKSOsoawzPil/LuurtQ== X-Received: by 2002:adf:b2c9:: with SMTP id g67-v6mr11366791wrd.147.1527605192297; Tue, 29 May 2018 07:46:32 -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.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:46:31 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/28] ovl: Add helper ovl_inode_realdata() Date: Tue, 29 May 2018 16:45:58 +0200 Message-Id: <20180529144612.16675-15-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 Add an helper to retrieve real data inode associated with overlay inode. This helper will ignore all metacopy inodes and will return only the real inode which has data. Signed-off-by: Vivek Goyal Reviewed-by: Amir Goldstein Signed-off-by: Miklos Szeredi --- fs/overlayfs/overlayfs.h | 1 + fs/overlayfs/util.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 558a1b444286..dcd600201ec8 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -229,6 +229,7 @@ struct inode *ovl_inode_upper(struct inode *inode); struct inode *ovl_inode_lower(struct inode *inode); struct inode *ovl_inode_lowerdata(struct inode *inode); struct inode *ovl_inode_real(struct inode *inode); +struct inode *ovl_inode_realdata(struct inode *inode); struct ovl_dir_cache *ovl_dir_cache(struct inode *inode); void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache); void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry); diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 63311c536216..73939e08d8bf 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -256,6 +256,18 @@ struct inode *ovl_inode_lowerdata(struct inode *inode) return OVL_I(inode)->lowerdata ?: ovl_inode_lower(inode); } +/* Return real inode which contains data. Does not return metacopy inode */ +struct inode *ovl_inode_realdata(struct inode *inode) +{ + struct inode *upperinode; + + upperinode = ovl_inode_upper(inode); + if (upperinode && ovl_has_upperdata(inode)) + return upperinode; + + return ovl_inode_lowerdata(inode); +} + struct ovl_dir_cache *ovl_dir_cache(struct inode *inode) { return OVL_I(inode)->cache;