* Patch "dealing with the rest of shrink_dentry_list() livelock" has been added to the 3.14-stable tree
@ 2016-03-01 8:15 gregkh
0 siblings, 0 replies; only message in thread
From: gregkh @ 2016-03-01 8:15 UTC (permalink / raw)
To: viro, gregkh; +Cc: stable, stable-commits
This is a note to let you know that I've just added the patch titled
dealing with the rest of shrink_dentry_list() livelock
to the 3.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
dealing-with-the-rest-of-shrink_dentry_list-livelock.patch
and it can be found in the queue-3.14 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
>From b2b80195d8829921506880f6dccd21cabd163d0d Mon Sep 17 00:00:00 2001
From: Al Viro <viro@zeniv.linux.org.uk>
Date: Thu, 29 May 2014 09:11:45 -0400
Subject: dealing with the rest of shrink_dentry_list() livelock
From: Al Viro <viro@zeniv.linux.org.uk>
commit b2b80195d8829921506880f6dccd21cabd163d0d upstream.
We have the same problem with ->d_lock order in the inner loop, where
we are dropping references to ancestors. Same solution, basically -
instead of using dentry_kill() we use lock_parent() (introduced in the
previous commit) to get that lock in a safe way, recheck ->d_count
(in case if lock_parent() has ended up dropping and retaking ->d_lock
and somebody managed to grab a reference during that window), trylock
the inode->i_lock and use __dentry_kill() to do the rest.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/dcache.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -886,8 +886,26 @@ static void shrink_dentry_list(struct li
* fragmentation.
*/
dentry = parent;
- while (dentry && !lockref_put_or_lock(&dentry->d_lockref))
- dentry = dentry_kill(dentry, 1);
+ while (dentry && !lockref_put_or_lock(&dentry->d_lockref)) {
+ parent = lock_parent(dentry);
+ if (dentry->d_lockref.count != 1) {
+ dentry->d_lockref.count--;
+ spin_unlock(&dentry->d_lock);
+ if (parent)
+ spin_unlock(&parent->d_lock);
+ break;
+ }
+ inode = dentry->d_inode; /* can't be NULL */
+ if (unlikely(!spin_trylock(&inode->i_lock))) {
+ spin_unlock(&dentry->d_lock);
+ if (parent)
+ spin_unlock(&parent->d_lock);
+ cpu_relax();
+ continue;
+ }
+ __dentry_kill(dentry);
+ dentry = parent;
+ }
}
}
Patches currently in stable-queue which might be from viro@zeniv.linux.org.uk are
queue-3.14/lock_parent-don-t-step-on-stale-d_parent-of-all-but-freed-one.patch
queue-3.14/lift-the-already-marked-killed-case-into-shrink_dentry_list.patch
queue-3.14/expand-dentry_kill-dentry-0-in-shrink_dentry_list.patch
queue-3.14/bcache-fix-a-leak-in-bch_cached_dev_run.patch
queue-3.14/dcache-add-missing-lockdep-annotation.patch
queue-3.14/dealing-with-the-rest-of-shrink_dentry_list-livelock.patch
queue-3.14/split-dentry_kill.patch
queue-3.14/shrink_dentry_list-take-parent-s-d_lock-earlier.patch
queue-3.14/dentry_kill-doesn-t-need-the-second-argument-now.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-03-01 8:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01 8:15 Patch "dealing with the rest of shrink_dentry_list() livelock" has been added to the 3.14-stable tree gregkh
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).