linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers3@gmail.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <clm@fb.com>,
	linux-fsdevel@vger.kernel.org
Subject: Re: d_instantiate() and unlock_new_inode() order in btrfs_mkdir()
Date: Wed, 18 Apr 2018 17:54:03 -0700	[thread overview]
Message-ID: <20180419005403.GA946@sol.localdomain> (raw)
In-Reply-To: <20180419001559.GG30522@ZenIV.linux.org.uk>

On Thu, Apr 19, 2018 at 01:15:59AM +0100, Al Viro wrote:
> On Thu, Apr 19, 2018 at 01:06:13AM +0100, Al Viro wrote:
> > On Wed, Apr 18, 2018 at 05:00:29PM -0700, Eric Biggers wrote:
> > > Hi Chris and other btrfs folks,
> > > 
> > > btrfs_mkdir() calls d_instantiate() before unlock_new_inode(), which is wrong
> > > because it exposes the inode to lookups before it's been fully initialized.
> > 
> > Huh?  It *is* fully initialized by that point; what else is left to do?
> 
> 	ISTR something about false positives from lockdep (with
> lockdep_annotate_inode_mutex_key() called too late, perhaps?); said that, it
> was a long time ago and I don't remember details at the moment...  Are you
> actually seeing a deadlock there or is that just lockdep complaining?

It's an actual deadlock.  unlock_new_inode() calls
lockdep_annotate_inode_mutex_key() which calls init_rwsem(), which resets
i_rwsem->count while it's read-locked by lookup_slow().  Then the unlock in
lookup_slow() makes i_rwsem->count negative, which makes it appear to be
write-locked.

So no, the inode isn't fully initialized until unlock_new_inode() ran.

Eric

      reply	other threads:[~2018-04-19  0:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-19  0:00 d_instantiate() and unlock_new_inode() order in btrfs_mkdir() Eric Biggers
2018-04-19  0:06 ` Al Viro
2018-04-19  0:15   ` Al Viro
2018-04-19  0:54     ` Eric Biggers [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=20180419005403.GA946@sol.localdomain \
    --to=ebiggers3@gmail.com \
    --cc=clm@fb.com \
    --cc=linux-btrfs@vger.kernel.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).