Commit a666e5c
dm: fix deadlock when swapping to encrypted device
The system would deadlock when swapping to a dm-crypt device. The reason
is that for each incoming write bio, dm-crypt allocates memory that holds
encrypted data. These excessive allocations exhaust all the memory and the
result is either deadlock or OOM trigger.
This patch limits the number of in-flight swap bios, so that the memory
consumed by dm-crypt is limited. The limit is enforced if the target set
the "limit_swap_bios" variable and if the bio has REQ_SWAP set.
Non-swap bios are not affected becuase taking the semaphore would cause
performance degradation.
This is similar to request-based drivers - they will also block when the
number of requests is over the limit.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>1 parent e3290b9 commit a666e5c
File tree
4 files changed
+70
-0
lines changed- drivers/md
- include/linux
4 files changed
+70
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3342 | 3342 | | |
3343 | 3343 | | |
3344 | 3344 | | |
| 3345 | + | |
3345 | 3346 | | |
3346 | 3347 | | |
3347 | 3348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
156 | 166 | | |
157 | 167 | | |
158 | 168 | | |
| |||
974 | 984 | | |
975 | 985 | | |
976 | 986 | | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
977 | 992 | | |
978 | 993 | | |
979 | 994 | | |
| |||
1025 | 1040 | | |
1026 | 1041 | | |
1027 | 1042 | | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
1028 | 1048 | | |
1029 | 1049 | | |
1030 | 1050 | | |
| |||
1258 | 1278 | | |
1259 | 1279 | | |
1260 | 1280 | | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
1261 | 1297 | | |
1262 | 1298 | | |
1263 | 1299 | | |
| |||
1277 | 1313 | | |
1278 | 1314 | | |
1279 | 1315 | | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
1280 | 1324 | | |
1281 | 1325 | | |
1282 | 1326 | | |
| |||
1287 | 1331 | | |
1288 | 1332 | | |
1289 | 1333 | | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
1290 | 1338 | | |
1291 | 1339 | | |
1292 | 1340 | | |
1293 | 1341 | | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1294 | 1346 | | |
1295 | 1347 | | |
1296 | 1348 | | |
| |||
1767 | 1819 | | |
1768 | 1820 | | |
1769 | 1821 | | |
| 1822 | + | |
1770 | 1823 | | |
1771 | 1824 | | |
1772 | 1825 | | |
| |||
1834 | 1887 | | |
1835 | 1888 | | |
1836 | 1889 | | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
1837 | 1894 | | |
1838 | 1895 | | |
1839 | 1896 | | |
| |||
3117 | 3174 | | |
3118 | 3175 | | |
3119 | 3176 | | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
3120 | 3180 | | |
3121 | 3181 | | |
3122 | 3182 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
343 | 343 | | |
344 | 344 | | |
345 | 345 | | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
346 | 351 | | |
347 | 352 | | |
348 | 353 | | |
| |||
0 commit comments