Repository navigation
Commit 39ad058
f2fs: compress: fix potential deadlock of compress file
commit 7377e85 upstream.
There is a potential deadlock between writeback process and a process
performing write_begin() or write_cache_pages() while trying to write
same compress file, but not compressable, as below:
[Process A] - doing checkpoint
[Process B] [Process C]
f2fs_write_cache_pages()
- lock_page() [all pages in cluster, 0-31]
- f2fs_write_multi_pages()
- f2fs_write_raw_pages()
- f2fs_write_single_data_page()
- f2fs_do_write_data_page()
- return -EAGAIN [f2fs_trylock_op() failed]
- unlock_page(page) [e.g., page 0]
- generic_perform_write()
- f2fs_write_begin()
- f2fs_prepare_compress_overwrite()
- prepare_compress_overwrite()
- lock_page() [e.g., page 0]
- lock_page() [e.g., page 1]
- lock_page(page) [e.g., page 0]
Since there is no compress process, it is no longer necessary to hold
locks on every pages in cluster within f2fs_write_raw_pages().
This patch changes f2fs_write_raw_pages() to release all locks first
and then perform write same as the non-compress file in
f2fs_write_cache_pages().
Fixes: 4c8ff70 ("f2fs: support data compression")
Signed-off-by: Hyeong-Jun Kim <hj514.kim@samsung.com>
Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent e184036 commit 39ad058
1 file changed
Lines changed: 22 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1362 | 1362 | | |
1363 | 1363 | | |
1364 | 1364 | | |
1365 | | - | |
1366 | | - | |
| 1365 | + | |
1367 | 1366 | | |
1368 | 1367 | | |
1369 | | - | |
1370 | | - | |
1371 | | - | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
1372 | 1375 | | |
1373 | 1376 | | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
1374 | 1380 | | |
1375 | 1381 | | |
1376 | 1382 | | |
1377 | 1383 | | |
| 1384 | + | |
| 1385 | + | |
1378 | 1386 | | |
| 1387 | + | |
1379 | 1388 | | |
1380 | 1389 | | |
1381 | 1390 | | |
1382 | 1391 | | |
1383 | | - | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1384 | 1397 | | |
1385 | 1398 | | |
1386 | 1399 | | |
| |||
1395 | 1408 | | |
1396 | 1409 | | |
1397 | 1410 | | |
1398 | | - | |
1399 | | - | |
1400 | | - | |
1401 | | - | |
| 1411 | + | |
| 1412 | + | |
1402 | 1413 | | |
1403 | 1414 | | |
1404 | 1415 | | |
1405 | 1416 | | |
1406 | | - | |
1407 | | - | |
1408 | | - | |
1409 | | - | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | 1417 | | |
1415 | 1418 | | |
1416 | | - | |
1417 | | - | |
| 1419 | + | |
1418 | 1420 | | |
1419 | 1421 | | |
1420 | 1422 | | |
| |||
1423 | 1425 | | |
1424 | 1426 | | |
1425 | 1427 | | |
1426 | | - | |
1427 | | - | |
1428 | | - | |
1429 | | - | |
1430 | | - | |
1431 | | - | |
1432 | | - | |
1433 | | - | |
1434 | 1428 | | |
1435 | 1429 | | |
1436 | 1430 | | |
| |||
0 commit comments