linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tobin C. Harding" <me@tobin.cc>
To: linux-fsdevel@vger.kernel.org
Subject: dcache locking question
Date: Fri, 15 Mar 2019 09:56:32 +1100	[thread overview]
Message-ID: <20190314225632.GB15813@eros.localdomain> (raw)

Hi,

I'm not able to understand the locking order in dcache.  dcache has been
around for a while so clearly its right and I'm wrong.

Could someone please explain to me how the locking order commented at
the top of the file is not violated in the following:

From top of fs/dcache.c

 * If there is an ancestor relationship:
 * dentry->d_parent->...->d_parent->d_lock
 *   ...
 *     dentry->d_parent->d_lock
 *       dentry->d_lock


dentry_kill() appears to require caller to hold the dentry->d_lock yet
it locks the parent with spin_trylock(&parent->d_lock), if this
fails it calls __lock_parent() which releases the dentry->d_lock before
locking the parent and re-acquiring [1] the dentry->d_lock .  Is this not
locking in two different orders? 

The same logic exists in lock_parent().

thanks,
Tobin.


[1] I do not fully understand the spin_lock_nested() macro.

             reply	other threads:[~2019-03-14 22:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14 22:56 Tobin C. Harding [this message]
2019-03-14 23:09 ` dcache locking question Matthew Wilcox
2019-03-15  1:38   ` Tobin C. Harding
2019-03-14 23:19 ` Tobin C. Harding
2019-03-15  1:50   ` Al Viro
2019-03-15 17:38     ` Eric Biggers
2019-03-15 18:54       ` Al Viro
2019-03-16 22:31         ` Paul E. McKenney
2019-03-17  0:18           ` Al Viro
2019-03-17  0:50             ` Paul E. McKenney
2019-03-17  2:20               ` James Bottomley
2019-03-17  3:06                 ` Al Viro
2019-03-17  4:23                   ` James Bottomley
2019-03-18  0:35                     ` Paul E. McKenney
2019-03-18 16:26                       ` James Bottomley
2019-03-18 17:11                         ` Paul E. McKenney
2019-03-19 15:45                           ` Paul E. McKenney

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=20190314225632.GB15813@eros.localdomain \
    --to=me@tobin.cc \
    --cc=linux-fsdevel@vger.kernel.org \
    /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).