]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-4.4/hang-soft-lockup-in-d_invalidate-with-simultaneous-calls.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / hang-soft-lockup-in-d_invalidate-with-simultaneous-calls.patch
CommitLineData
1c23bb82
GKH
1From 81be24d263dbeddaba35827036d6f6787a59c2c3 Mon Sep 17 00:00:00 2001
2From: Al Viro <viro@ZenIV.linux.org.uk>
3Date: Sat, 3 Jun 2017 07:20:09 +0100
4Subject: Hang/soft lockup in d_invalidate with simultaneous calls
5
6From: Al Viro <viro@ZenIV.linux.org.uk>
7
8commit 81be24d263dbeddaba35827036d6f6787a59c2c3 upstream.
9
10It's not hard to trigger a bunch of d_invalidate() on the same
11dentry in parallel. They end up fighting each other - any
12dentry picked for removal by one will be skipped by the rest
13and we'll go for the next iteration through the entire
14subtree, even if everything is being skipped. Morevoer, we
15immediately go back to scanning the subtree. The only thing
16we really need is to dissolve all mounts in the subtree and
17as soon as we've nothing left to do, we can just unhash the
18dentry and bugger off.
19
20Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
21Signed-off-by: Arnd Bergmann <arnd@arndb.de>
22Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
23
24---
25 fs/dcache.c | 10 ++++------
26 1 file changed, 4 insertions(+), 6 deletions(-)
27
28--- a/fs/dcache.c
29+++ b/fs/dcache.c
30@@ -1510,7 +1510,7 @@ static void check_and_drop(void *_data)
31 {
32 struct detach_data *data = _data;
33
34- if (!data->mountpoint && !data->select.found)
35+ if (!data->mountpoint && list_empty(&data->select.dispose))
36 __d_drop(data->select.start);
37 }
38
39@@ -1552,17 +1552,15 @@ void d_invalidate(struct dentry *dentry)
40
41 d_walk(dentry, &data, detach_and_collect, check_and_drop);
42
43- if (data.select.found)
44+ if (!list_empty(&data.select.dispose))
45 shrink_dentry_list(&data.select.dispose);
46+ else if (!data.mountpoint)
47+ return;
48
49 if (data.mountpoint) {
50 detach_mounts(data.mountpoint);
51 dput(data.mountpoint);
52 }
53-
54- if (!data.mountpoint && !data.select.found)
55- break;
56-
57 cond_resched();
58 }
59 }