Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752307AbcCUF2P (ORCPT ); Mon, 21 Mar 2016 01:28:15 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:59536 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221AbcCUF2L (ORCPT ); Mon, 21 Mar 2016 01:28:11 -0400 Date: Mon, 21 Mar 2016 05:28:09 +0000 From: Al Viro To: Miklos Szeredi Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, dhowells@redhat.com, Goldwyn Rodrigues , Trond Myklebust , stable@vger.kernel.org, "Theodore Ts'o" , Daniel Axtens Subject: Re: [PATCH 1/4] vfs: add file_dentry() Message-ID: <20160321052808.GH17997@ZenIV.linux.org.uk> References: <1458205323-25685-1-git-send-email-miklos@szeredi.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1458205323-25685-1-git-send-email-miklos@szeredi.hu> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 995 Lines: 19 On Thu, Mar 17, 2016 at 10:02:00AM +0100, Miklos Szeredi wrote: > Add a new helper, file_dentry() [*], to get the filesystem's own dentry > from the file. This simply compares file_inode(file->f_path.dentry) to > file_inode(file) and if they are equal returns file->f_path.dentry (this is > the common, non-overlayfs case). > > In the uncommon case (regular file on overlayfs) it will call into > overlayfs's ->d_native_dentry() to get the underlying dentry matching > file_inode(file). What's wrong with making ovl_dentry_real() an instance of optional ->d_real() method and having a flag (DCACHE_OP_REAL) controlling its calls? With d_real(dentry) returning either that or dentry itself, and file_dentry(file) being simply d_real(file->f_path.dentry)... Why do we need to look at the inode at all? d_set_d_op() dereferences ->d_op anyway, as well as setting ->d_flags, so there's no extra cost there, and "test bit in ->d_flags + branch not taken" is all it would cost in normal case...