Commit 67bf780
nfs: skip commit in releasepage if we're freeing memory for fs-related reasons
commit 5cf02d0 upstream.
We've had some reports of a deadlock where rpciod ends up with a stack
trace like this:
PID: 2507 TASK: ffff88103691ab40 CPU: 14 COMMAND: "rpciod/14"
#0 [ffff8810343bf2f0] schedule at ffffffff814dabd9
#1 [ffff8810343bf3b8] nfs_wait_bit_killable at ffffffffa038fc04 [nfs]
#2 [ffff8810343bf3c8] __wait_on_bit at ffffffff814dbc2f
#3 [ffff8810343bf418] out_of_line_wait_on_bit at ffffffff814dbcd8
#4 [ffff8810343bf488] nfs_commit_inode at ffffffffa039e0c1 [nfs]
#5 [ffff8810343bf4f8] nfs_release_page at ffffffffa038bef6 [nfs]
#6 [ffff8810343bf528] try_to_release_page at ffffffff8110c670
#7 [ffff8810343bf538] shrink_page_list.clone.0 at ffffffff81126271
#8 [ffff8810343bf668] shrink_inactive_list at ffffffff81126638
#9 [ffff8810343bf818] shrink_zone at ffffffff8112788f
torvalds#10 [ffff8810343bf8c8] do_try_to_free_pages at ffffffff81127b1e
torvalds#11 [ffff8810343bf958] try_to_free_pages at ffffffff8112812f
torvalds#12 [ffff8810343bfa08] __alloc_pages_nodemask at ffffffff8111fdad
torvalds#13 [ffff8810343bfb28] kmem_getpages at ffffffff81159942
torvalds#14 [ffff8810343bfb58] fallback_alloc at ffffffff8115a55a
torvalds#15 [ffff8810343bfbd8] ____cache_alloc_node at ffffffff8115a2d9
torvalds#16 [ffff8810343bfc38] kmem_cache_alloc at ffffffff8115b09b
torvalds#17 [ffff8810343bfc78] sk_prot_alloc at ffffffff81411808
torvalds#18 [ffff8810343bfcb8] sk_alloc at ffffffff8141197c
torvalds#19 [ffff8810343bfce8] inet_create at ffffffff81483ba6
torvalds#20 [ffff8810343bfd38] __sock_create at ffffffff8140b4a7
torvalds#21 [ffff8810343bfd98] xs_create_sock at ffffffffa01f649b [sunrpc]
torvalds#22 [ffff8810343bfdd8] xs_tcp_setup_socket at ffffffffa01f6965 [sunrpc]
torvalds#23 [ffff8810343bfe38] worker_thread at ffffffff810887d0
torvalds#24 [ffff8810343bfee8] kthread at ffffffff8108dd96
torvalds#25 [ffff8810343bff48] kernel_thread at ffffffff8100c1ca
rpciod is trying to allocate memory for a new socket to talk to the
server. The VM ends up calling ->releasepage to get more memory, and it
tries to do a blocking commit. That commit can't succeed however without
a connected socket, so we deadlock.
Fix this by setting PF_FSTRANS on the workqueue task prior to doing the
socket allocation, and having nfs_release_page check for that flag when
deciding whether to do a commit call. Also, set PF_FSTRANS
unconditionally in rpc_async_schedule since that function can also do
allocations sometimes.
Signed-off-by: Jeff Layton <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
Signed-off-by: Ben Hutchings <[email protected]>1 parent 9f7c36c commit 67bf780
File tree
4 files changed
+19
-3
lines changed- fs/nfs
- net/sunrpc
- xprtrdma
4 files changed
+19
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
456 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
457 | 460 | | |
458 | 461 | | |
459 | 462 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| 758 | + | |
758 | 759 | | |
| 760 | + | |
759 | 761 | | |
760 | 762 | | |
761 | 763 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| |||
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
215 | | - | |
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
| 219 | + | |
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1895 | 1895 | | |
1896 | 1896 | | |
1897 | 1897 | | |
| 1898 | + | |
| 1899 | + | |
1898 | 1900 | | |
1899 | 1901 | | |
1900 | 1902 | | |
| |||
1928 | 1930 | | |
1929 | 1931 | | |
1930 | 1932 | | |
| 1933 | + | |
1931 | 1934 | | |
1932 | 1935 | | |
1933 | 1936 | | |
| |||
1970 | 1973 | | |
1971 | 1974 | | |
1972 | 1975 | | |
| 1976 | + | |
| 1977 | + | |
1973 | 1978 | | |
1974 | 1979 | | |
1975 | 1980 | | |
| |||
1988 | 1993 | | |
1989 | 1994 | | |
1990 | 1995 | | |
| 1996 | + | |
1991 | 1997 | | |
1992 | 1998 | | |
1993 | 1999 | | |
| |||
2113 | 2119 | | |
2114 | 2120 | | |
2115 | 2121 | | |
| 2122 | + | |
| 2123 | + | |
2116 | 2124 | | |
2117 | 2125 | | |
2118 | 2126 | | |
| |||
2162 | 2170 | | |
2163 | 2171 | | |
2164 | 2172 | | |
| 2173 | + | |
2165 | 2174 | | |
2166 | 2175 | | |
2167 | 2176 | | |
| |||
2174 | 2183 | | |
2175 | 2184 | | |
2176 | 2185 | | |
| 2186 | + | |
2177 | 2187 | | |
2178 | 2188 | | |
2179 | 2189 | | |
| |||
0 commit comments