From: Al Viro <viro@ZenIV.linux.org.uk>
To: John Ogness <john.ogness@linutronix.de>
Cc: linux-fsdevel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Christoph Hellwig <hch@lst.de>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] fs/dcache: Avoid the try_lock loop in d_delete()
Date: Thu, 22 Feb 2018 05:18:57 +0000 [thread overview]
Message-ID: <20180222051857.GL30522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180216150933.971-4-john.ogness@linutronix.de>
On Fri, Feb 16, 2018 at 04:09:32PM +0100, John Ogness wrote:
> @@ -2378,22 +2420,36 @@ void d_delete(struct dentry * dentry)
> /*
> * Are we the only user?
> */
> -again:
> spin_lock(&dentry->d_lock);
> +again:
> inode = dentry->d_inode;
> isdir = S_ISDIR(inode->i_mode);
> if (dentry->d_lockref.count == 1) {
> - if (!spin_trylock(&inode->i_lock)) {
> - spin_unlock(&dentry->d_lock);
> - cpu_relax();
> + /*
> + * Lock the inode. Might drop dentry->d_lock temporarily
> + * which allows inode to change. Start over if that happens.
> + */
> + if (!dentry_lock_inode(dentry))
> goto again;
IDGI. First of all, why do we need to fetch ->d_inode (and calculate isdir)
before that dentry_lock_inode() of yours? That's at least partially understandable
in the current version, where we need inode in d_delete() scope, but here it looks
bloody odd.
And if you move those fetches past the call of dentry_lock_inode(), you suddenly
get the life much simpler:
grab d_lock
if d_count is greater than 1, drop it and bugger off
while !dentry_lock_inode(dentry)
;
fetch inode
recheck d_count, in the unlikely case when it's greater than 1,
drop and bugger off
clear CANT_MOUNT
calculate isdir
unlink_inode
fsnotify shite
I mean, do we really want to keep rechecking d_count on each loop iteration?
What does it buy us? Sure, we want to recheck in the end for correctness
sake, but...
It might make sense to move the loop inside dentry_lock_inode(), IMO.
next prev parent reply other threads:[~2018-02-22 5:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-16 15:09 [PATCH 0/4] fs/dcache: avoid trylock loops John Ogness
2018-02-16 15:09 ` [PATCH 1/4] fs/dcache: Remove stale comment from dentry_kill() John Ogness
2018-02-16 15:09 ` [PATCH 2/4] fs/dcache: Move dentry_kill() below lock_parent() John Ogness
2018-02-16 15:09 ` [PATCH 3/4] fs/dcache: Avoid the try_lock loop in d_delete() John Ogness
2018-02-16 17:10 ` Peter Zijlstra
2018-02-16 17:30 ` Peter Zijlstra
2018-02-22 5:18 ` Al Viro [this message]
2018-02-22 8:35 ` John Ogness
2018-02-16 15:09 ` [PATCH 4/4] fs/dcache: Avoid the try_lock loops in dentry_kill() John Ogness
2018-02-16 18:03 ` Linus Torvalds
2018-02-16 22:32 ` John Ogness
2018-02-16 22:42 ` Linus Torvalds
2018-02-16 23:05 ` John Ogness
2018-02-16 23:31 ` Linus Torvalds
2018-02-16 23:49 ` John Ogness
2018-02-17 0:06 ` Linus Torvalds
2018-02-19 23:34 ` John Ogness
2018-02-20 0:42 ` Linus Torvalds
2018-02-20 8:39 ` Peter Zijlstra
2018-02-20 8:43 ` Peter Zijlstra
2018-02-22 5:29 ` Al Viro
2018-02-22 5:40 ` Al Viro
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=20180222051857.GL30522@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=bigeasy@linutronix.de \
--cc=hch@lst.de \
--cc=john.ogness@linutronix.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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).