From: Jan Kara <jack@suse.cz>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>, linux-fsdevel@vger.kernel.org
Subject: Re: elementary d_move question
Date: Tue, 29 Oct 2013 17:28:24 +0100 [thread overview]
Message-ID: <20131029162824.GA6087@quack.suse.cz> (raw)
In-Reply-To: <20131023154654.GC30796@fieldses.org>
On Wed 23-10-13 11:46:54, J. Bruce Fields wrote:
> If I rename foo over bar, while holding bar open, then
> /proc/<pid>/fd/<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 <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2013-10-29 16:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-23 15:46 elementary d_move question J. Bruce Fields
2013-10-29 16:28 ` Jan Kara [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-10-23 17:27 J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131029162824.GA6087@quack.suse.cz \
--to=jack@suse.cz \
--cc=bfields@fieldses.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).