From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f45.google.com ([74.125.82.45]:32947 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936373AbeE0LJZ (ORCPT ); Sun, 27 May 2018 07:09:25 -0400 MIME-Version: 1.0 References: <20180526171206.GP30522@ZenIV.linux.org.uk> In-Reply-To: <20180526171206.GP30522@ZenIV.linux.org.uk> From: Lei Chen Date: Sun, 27 May 2018 19:09:14 +0800 Message-ID: Subject: Re: Why does d_splice_alias need to check IS_ROOT? To: Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Al Viro =E4=BA=8E2018=E5=B9=B45=E6=9C=8827=E6=97= =A5=E5=91=A8=E6=97=A5 =E4=B8=8A=E5=8D=881:12=E5=86=99=E9=81=93=EF=BC=9A > On Sun, May 27, 2018 at 12:33:40AM +0800, Lei Chen wrote: > > Hello list, > > > > I'm insteresting in how hard link and denry lookup work and their > > implementation. > > > > I know that this interface tries to connect an inode to a dentry, but > > why does it need > > to check whether the inode alias IS_ROOT if the inode represents a directory? > > And the code process in different way according to check result. What > > occasions > > are they used for? > If it's disconnected (and not an ancestor of the place where we want it), > we can just move it in place, no questions asked. If it is *NOT* > disconnected, the only thing we can do is to detach it from where it > is and move it over. Which takes a lot more care wrt locking. Thanks for your reply. But why does it mean "disconnected" if IS_ROOT returns true?? Why not use hlist_unhashed(&entry->d_u.d_alias) or d_is_negative to determine whether a dentry is connected to an inode?? I found that when we allocate a new dentry struct, its parent is not always itself.