Commit 7377e85
f2fs: compress: fix potential deadlock of compress file
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 <[email protected]>
Signed-off-by: Sungjong Seo <[email protected]>
Signed-off-by: Youngjin Gil <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>1 parent 19bdba5 commit 7377e85
1 file changed
+22
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1456 | 1456 | | |
1457 | 1457 | | |
1458 | 1458 | | |
1459 | | - | |
1460 | | - | |
| 1459 | + | |
1461 | 1460 | | |
1462 | 1461 | | |
1463 | | - | |
1464 | | - | |
1465 | | - | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
1466 | 1469 | | |
1467 | 1470 | | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
1468 | 1474 | | |
1469 | 1475 | | |
1470 | 1476 | | |
1471 | 1477 | | |
| 1478 | + | |
| 1479 | + | |
1472 | 1480 | | |
| 1481 | + | |
1473 | 1482 | | |
1474 | 1483 | | |
1475 | 1484 | | |
1476 | 1485 | | |
1477 | | - | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
1478 | 1491 | | |
1479 | 1492 | | |
1480 | 1493 | | |
| |||
1489 | 1502 | | |
1490 | 1503 | | |
1491 | 1504 | | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
1495 | | - | |
| 1505 | + | |
| 1506 | + | |
1496 | 1507 | | |
1497 | 1508 | | |
1498 | 1509 | | |
1499 | 1510 | | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | | - | |
1504 | | - | |
1505 | | - | |
1506 | | - | |
1507 | | - | |
1508 | 1511 | | |
1509 | 1512 | | |
1510 | | - | |
1511 | | - | |
| 1513 | + | |
1512 | 1514 | | |
1513 | 1515 | | |
1514 | 1516 | | |
| |||
1517 | 1519 | | |
1518 | 1520 | | |
1519 | 1521 | | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
1526 | | - | |
1527 | | - | |
1528 | 1522 | | |
1529 | 1523 | | |
1530 | 1524 | | |
| |||
0 commit comments