Commit 33307fa
committed
fuse: Add DLM retry workaround for iomap write failures
When FUSE server returns -EAGAIN during iomap write operations due to
DLM lock contention, the write fails with an IO error. This happens
because:
1. Page invalidation holds DLM lock and needs folio lock
2. iomap write path holds folio lock and calls fuse_iomap_read_folio_range()
3. FUSE gets -EAGAIN from server (cannot acquire DLM lock - would deadlock)
4. fuse_do_readfolio() converts -EAGAIN to AOP_TRUNCATED_PAGE and unlocks folio
(This prevents the deadlock by releasing the folio lock)
5. However, iomap doesn't understand AOP_TRUNCATED_PAGE and treats it as error
6. Result: Write fails with IO error, even though it's just temporary contention
This is a FUSE-only workaround until mainline iomap gains
AOP_TRUNCATED_PAGE retry support. The solution:
1. Stack-allocate retry state in fuse_cache_write_iter()
2. Register it in fuse_conn xarray before calling iomap (indexed by task pointer)
3. When fuse_iomap_read_folio_range() sees AOP_TRUNCATED_PAGE:
- Mark the retry flag in the registered state
- Convert to -EAGAIN for iomap
4. After iomap returns, check the retry flag
5. If set, retry the entire write operation
6. Remove from xarray when done (or keep for next retry iteration)
This allows writes to succeed by retrying after the DLM lock contention
clears, rather than failing with IO error.
This uses a single per connection xa_array under the assumption that
there won't be too many parallel writers.
Signed-off-by: Bernd Schubert <bernd@bsbernd.com>1 parent 93cf419 commit 33307fa
3 files changed
Lines changed: 102 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1001 | 1001 | | |
1002 | 1002 | | |
1003 | 1003 | | |
| 1004 | + | |
| 1005 | + | |
1004 | 1006 | | |
1005 | | - | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
1006 | 1043 | | |
1007 | 1044 | | |
1008 | 1045 | | |
| |||
1604 | 1641 | | |
1605 | 1642 | | |
1606 | 1643 | | |
| 1644 | + | |
1607 | 1645 | | |
1608 | 1646 | | |
1609 | 1647 | | |
| |||
1621 | 1659 | | |
1622 | 1660 | | |
1623 | 1661 | | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
1624 | 1686 | | |
1625 | 1687 | | |
1626 | 1688 | | |
| |||
1629 | 1691 | | |
1630 | 1692 | | |
1631 | 1693 | | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
1632 | 1714 | | |
1633 | 1715 | | |
1634 | 1716 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
642 | 653 | | |
643 | 654 | | |
644 | 655 | | |
| |||
1022 | 1033 | | |
1023 | 1034 | | |
1024 | 1035 | | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
1025 | 1042 | | |
1026 | 1043 | | |
1027 | 1044 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1056 | 1056 | | |
1057 | 1057 | | |
1058 | 1058 | | |
| 1059 | + | |
1059 | 1060 | | |
1060 | 1061 | | |
1061 | 1062 | | |
| |||
1109 | 1110 | | |
1110 | 1111 | | |
1111 | 1112 | | |
| 1113 | + | |
1112 | 1114 | | |
1113 | 1115 | | |
1114 | 1116 | | |
| |||
0 commit comments