From patchwork Tue Mar 1 18:12:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 8468351 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B4404C0554 for ; Tue, 1 Mar 2016 18:13:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA7D9202EC for ; Tue, 1 Mar 2016 18:13:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F380202FF for ; Tue, 1 Mar 2016 18:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752225AbcCASM4 (ORCPT ); Tue, 1 Mar 2016 13:12:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:35086 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750997AbcCASMz (ORCPT ); Tue, 1 Mar 2016 13:12:55 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 63A4AAD02; Tue, 1 Mar 2016 18:12:53 +0000 (UTC) From: Goldwyn Rodrigues To: miklos@szeredi.hu Cc: linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, Goldwyn Rodrigues Subject: [PATCH 2/3] vfs: Add d_select_inode for overlayfs translation Date: Tue, 1 Mar 2016 12:12:07 -0600 Message-Id: <1456855928-29913-3-git-send-email-rgoldwyn@suse.de> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1456855928-29913-1-git-send-email-rgoldwyn@suse.de> References: <1456855928-29913-1-git-send-email-rgoldwyn@suse.de> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Goldwyn Rodrigues d_select_inode() is a helper function to translate dentry to inodes while using in conjunction with overlayfs so dentries evaluate to true lower inodes. Signed-off-by: Goldwyn Rodrigues --- include/linux/dcache.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 7781ce11..dbaa420 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -541,6 +541,21 @@ static inline struct inode *d_inode(const struct dentry *dentry) } /** + * d_select_inode - Get the actual inode of this dentry + * @dentry: The dentry to query + * @flags: open flags passed + * + * This is the helper to select the underlying true inode associated with + * a dentry to cover cases of translating overlay filesystem. + */ +static inline struct inode *d_select_inode(struct dentry *dentry, int flags) +{ + if (dentry->d_flags & DCACHE_OP_SELECT_INODE) + return dentry->d_op->d_select_inode(dentry, flags); + return dentry->d_inode; +} + +/** * d_inode_rcu - Get the actual inode of this dentry with ACCESS_ONCE() * @dentry: The dentry to query *