]>
Commit | Line | Data |
---|---|---|
1c23bb82 GKH |
1 | From 81be24d263dbeddaba35827036d6f6787a59c2c3 Mon Sep 17 00:00:00 2001 |
2 | From: Al Viro <viro@ZenIV.linux.org.uk> | |
3 | Date: Sat, 3 Jun 2017 07:20:09 +0100 | |
4 | Subject: Hang/soft lockup in d_invalidate with simultaneous calls | |
5 | ||
6 | From: Al Viro <viro@ZenIV.linux.org.uk> | |
7 | ||
8 | commit 81be24d263dbeddaba35827036d6f6787a59c2c3 upstream. | |
9 | ||
10 | It's not hard to trigger a bunch of d_invalidate() on the same | |
11 | dentry in parallel. They end up fighting each other - any | |
12 | dentry picked for removal by one will be skipped by the rest | |
13 | and we'll go for the next iteration through the entire | |
14 | subtree, even if everything is being skipped. Morevoer, we | |
15 | immediately go back to scanning the subtree. The only thing | |
16 | we really need is to dissolve all mounts in the subtree and | |
17 | as soon as we've nothing left to do, we can just unhash the | |
18 | dentry and bugger off. | |
19 | ||
20 | Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> | |
21 | Signed-off-by: Arnd Bergmann <arnd@arndb.de> | |
22 | Signed-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 | } |