From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: Re: elementary d_move question Date: Tue, 29 Oct 2013 17:28:24 +0100 Message-ID: <20131029162824.GA6087@quack.suse.cz> References: <20131023154654.GC30796@fieldses.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Al Viro , linux-fsdevel@vger.kernel.org To: "J. Bruce Fields" Return-path: Received: from cantor2.suse.de ([195.135.220.15]:36824 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758051Ab3J2Q21 (ORCPT ); Tue, 29 Oct 2013 12:28:27 -0400 Content-Disposition: inline In-Reply-To: <20131023154654.GC30796@fieldses.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed 23-10-13 11:46:54, J. Bruce Fields wrote: > If I rename foo over bar, while holding bar open, then > /proc//fd/ still shows me bar's old path: > > $ touch foo bar > $ tail -f bar & > [1] 23492 > $ mv foo bar > $ readlink /proc/23492/fd/3 > /home/bfields/bar (deleted) > > The rename does a d_move(dentry, target) where I assume dentry is for > "foo" and target for "bar", with target the same dentry that the file > descriptor holds a reference on. > > But d_move() does > > switch_names(dentry, target); > > giving target name "foo". So how does readlink still get "bar"? > > I've clearly missed something obvious.... You didn't read switch_names() carefully enough :) (and I didn't either on the first reading). There is one (the common) case when the switching doesn't happen and the name is only copied from 'target' to 'dentry' so target's name remains intact... Honza -- Jan Kara SUSE Labs, CR