Commit e7457f4
committed
fix(vfs): clamp tracked dirty range to staging length + cleanup nits
Code review follow-up addressing 5 nits:
1. write() recorded the dirty range with the unclamped `written` even
when the post-pwrite metadata read showed the staging file had been
shrunk by a concurrent setattr(truncate). At flush, range_upload
would seek to the range start and read end - start bytes, short-
reading on the smaller staging. Now use `effective_end.saturating_sub
(offset)` so the tracked range matches what's actually on disk.
2. trim_dirty_ranges now drops ranges where the clipped end equals
start. track_write doesn't produce zero-length ranges so this is
defense, but keeping the (s < e) invariant downstream is cheap and
avoids consumers having to think about it.
3. Comment on fill_sparse_holes: the CAS download grabs the whole
[offset, orig_end) even when most of it overlaps dirty bytes. Worth
a follow-up only if profiling shows it.
4. Comment on apply_commit's generation-mismatch path: the CAS upload
and Hub commit fire even when local metadata can't be updated, and
the next flush will re-upload. CAS dedup handles duplicate content;
noting the sparse path makes redundant flushes more visible.
5. Replace the unreachable!() at the end of the retry loop in open()
with an explicit `Err(libc::EAGAIN)`. Same observable behavior,
cleaner control flow that the compiler can prove total.
Plus a regression test (write_tracked_range_clamped_to_staging_after_
concurrent_shrink) that pwrites then setattr-shrinks past the dirty
range and asserts the tracked dirty_ranges stay within entry.size.1 parent 78024d8 commit e7457f4
3 files changed
Lines changed: 112 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
228 | | - | |
| 231 | + | |
229 | 232 | | |
230 | 233 | | |
231 | 234 | | |
| |||
316 | 319 | | |
317 | 320 | | |
318 | 321 | | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
319 | 333 | | |
320 | 334 | | |
321 | 335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1610 | 1610 | | |
1611 | 1611 | | |
1612 | 1612 | | |
1613 | | - | |
1614 | | - | |
| 1613 | + | |
| 1614 | + | |
1615 | 1615 | | |
1616 | | - | |
1617 | | - | |
1618 | | - | |
1619 | | - | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
| 1616 | + | |
1623 | 1617 | | |
1624 | 1618 | | |
1625 | 1619 | | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
1630 | 1623 | | |
1631 | 1624 | | |
1632 | 1625 | | |
1633 | 1626 | | |
1634 | | - | |
| 1627 | + | |
| 1628 | + | |
1635 | 1629 | | |
1636 | 1630 | | |
1637 | 1631 | | |
| |||
2104 | 2098 | | |
2105 | 2099 | | |
2106 | 2100 | | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
2107 | 2110 | | |
2108 | 2111 | | |
2109 | 2112 | | |
| |||
2383 | 2386 | | |
2384 | 2387 | | |
2385 | 2388 | | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
2386 | 2395 | | |
2387 | 2396 | | |
2388 | 2397 | | |
2389 | 2398 | | |
2390 | 2399 | | |
2391 | | - | |
| 2400 | + | |
2392 | 2401 | | |
2393 | 2402 | | |
2394 | 2403 | | |
2395 | 2404 | | |
2396 | 2405 | | |
2397 | 2406 | | |
2398 | | - | |
| 2407 | + | |
2399 | 2408 | | |
2400 | 2409 | | |
2401 | 2410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5776 | 5776 | | |
5777 | 5777 | | |
5778 | 5778 | | |
| 5779 | + | |
| 5780 | + | |
| 5781 | + | |
| 5782 | + | |
| 5783 | + | |
| 5784 | + | |
| 5785 | + | |
| 5786 | + | |
| 5787 | + | |
| 5788 | + | |
| 5789 | + | |
| 5790 | + | |
| 5791 | + | |
| 5792 | + | |
| 5793 | + | |
| 5794 | + | |
| 5795 | + | |
| 5796 | + | |
| 5797 | + | |
| 5798 | + | |
| 5799 | + | |
| 5800 | + | |
| 5801 | + | |
| 5802 | + | |
| 5803 | + | |
| 5804 | + | |
| 5805 | + | |
| 5806 | + | |
| 5807 | + | |
| 5808 | + | |
| 5809 | + | |
| 5810 | + | |
| 5811 | + | |
| 5812 | + | |
| 5813 | + | |
| 5814 | + | |
| 5815 | + | |
| 5816 | + | |
| 5817 | + | |
| 5818 | + | |
| 5819 | + | |
| 5820 | + | |
| 5821 | + | |
| 5822 | + | |
| 5823 | + | |
| 5824 | + | |
| 5825 | + | |
| 5826 | + | |
| 5827 | + | |
| 5828 | + | |
| 5829 | + | |
| 5830 | + | |
| 5831 | + | |
| 5832 | + | |
| 5833 | + | |
| 5834 | + | |
| 5835 | + | |
| 5836 | + | |
| 5837 | + | |
| 5838 | + | |
| 5839 | + | |
| 5840 | + | |
| 5841 | + | |
| 5842 | + | |
| 5843 | + | |
| 5844 | + | |
| 5845 | + | |
| 5846 | + | |
| 5847 | + | |
| 5848 | + | |
| 5849 | + | |
5779 | 5850 | | |
5780 | 5851 | | |
5781 | 5852 | | |
| |||
0 commit comments