All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: Neil Brown <neilb@suse.de>
Cc: Theodore Ts'o <tytso@mit.edu>, linux-fsdevel@vger.kernel.org
Subject: Re: Why do we pass in a directory and a dentry to lookup() and rename()
Date: Wed, 5 Jan 2011 11:26:05 +0000	[thread overview]
Message-ID: <20110105112605.GM19804@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20101228204619.4f9e1722@notabene.brown>

On Tue, Dec 28, 2010 at 08:46:19PM +1100, Neil Brown wrote:

> Some times it isn't safe to de-reference ->d_parent without extra locking
> (via dget_parent) so there could be cases where passing an
> already-ref-counted pointer might be cleaner, but during lookup and rename
> there must be sufficient locking so that ->d_parent cannot change.
> So all you could gain by passing the pointer separately is avoiding a single
> memory reference.  As d_parent is almost certainly in cache when these are
> called, that would not be a big gain.
> 
> It might be worth checking that the code doesn't get bigger if you drop the
> arg and use ->d_parent instead, but assuming it doesn't (which seems likely),
> I would agree that passing the parent inode explicitly is unnecessary.

In fact, all directory operations have relevant ->d_parent stable; a lot
of instances rely on that, actually.  So locking isn't a problem.

We could switch, but I'm not sure if it's worth the code churn.  Do we
really win anything there?  On targets where everything is pushed on
stack - probably yes, but I suspect that for majority of those methods
it'll be a loss on just about every target.  _Maybe_ it's not true for
->rename() (more arguments than for everything else), but...

Hell knows; I suspect that it might be worth playing with if/when we go
for explicit passing of creds to the methods.  Extra argument plus the
need to go through the instances anyway might make it worth bothering.

      reply	other threads:[~2011-01-05 11:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-26 21:45 Why do we pass in a directory and a dentry to lookup() and rename() Theodore Ts'o
     [not found] ` <AANLkTikS1BMu+DyZEVZ9H6daoh5dJM7uGPUB9ugdHuRA@mail.gmail.com>
2010-12-27  5:50   ` Ted Ts'o
2010-12-28  9:46 ` Neil Brown
2011-01-05 11:26   ` Al Viro [this message]

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=20110105112605.GM19804@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.