From: Al Viro <viro@ZenIV.linux.org.uk>
To: "J. R. Okajima" <hooanon05g@gmail.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: Q: spin_unlock(dentry) after lock_parent(dentry)
Date: Wed, 4 Jun 2014 00:17:12 +0100 [thread overview]
Message-ID: <20140603231712.GU18016@ZenIV.linux.org.uk> (raw)
In-Reply-To: <23341.1401806215@jrobl>
On Tue, Jun 03, 2014 at 11:36:55PM +0900, J. R. Okajima wrote:
>
> Hello Al Viro,
>
> I have a question about spin_unlock(dentry) after lock_parent(dentry).
> In lock_parent(dentry), spin_unlock(dentry) is called. And
> spin_lock(dentry) is called again when (parent != dentry) is
> true. Otherwise, dentry left spin_unlock-ed and lock_parent() returns
> NULL.
Nope. You are misreading it. Note that in *all* cases the parent is
locked. And NULL is returned exactly in the case when that parent is
equal to dentry itself. IOW, in all cases, lock_parent(d) returns with d
locked and after p = lock_parent(d) either
1) d->d_parent == d and p == NULL, or
2) d->d_parent == p, p != d and p is locked as well.
That holds whether we had succeeded with trylock or had to drop and regain
the lock on d.
> Even in the case of lock_parent() returns NULL, shrink_dentry_list()
> calls spin_unlock(dentry). Is it balanced and correct?
Yes.
next prev parent reply other threads:[~2014-06-03 23:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-03 14:36 Q: spin_unlock(dentry) after lock_parent(dentry) J. R. Okajima
2014-06-03 23:17 ` Al Viro [this message]
2014-06-04 17:03 ` J. R. Okajima
2014-06-07 13:51 ` J. R. Okajima
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=20140603231712.GU18016@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=hooanon05g@gmail.com \
--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 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.