Corner case
Corner case
Posted Nov 12, 2025 16:35 UTC (Wed) by abatters (✭ supporter ✭, #6932)Parent article: The intersection of unstable pages and direct I/O
Example:
4k buffer (one page)
write #1: 2k @ offset 0 written to sector 100
write #2: 2k @ offset 2k written to sector 200
Posted Nov 12, 2025 17:42 UTC (Wed)
by farnz (subscriber, #17727)
[Link]
This is a fixable problem if it's a common false positive - once page granularity detection says "two direct I/O reads to same page", you'd add in a check for overlap there.
Posted Nov 12, 2025 20:02 UTC (Wed)
by kreijack (guest, #43513)
[Link] (2 responses)
My be that I am misunderstanding something, but direct-I/O have some requirements. One of these is that the read/write size shall be multiple of the page size, and the offset must be multiple of the page size. So under direct-io is not possible to update a portion of a page, because you have to write (at least) the full-page.
Posted Nov 12, 2025 20:20 UTC (Wed)
by abatters (✭ supporter ✭, #6932)
[Link]
Posted Nov 12, 2025 20:23 UTC (Wed)
by koverstreet (✭ supporter ✭, #4296)
[Link]
We recently ran into an application (rocksdb) that didn't work on bcachefs in largebs mode because of this - it was only checking dma alignment, not offset.
My understanding is that your corner case as shown would not trigger conflict detection, because the buffer is not changed by the write. The problem would come with two reads to different parts of the same page (at sector alignment, on a system where sectors are smaller than pages), where page granularity would detect two places changing the same page.
Corner case
Corner case
Corner case
Corner case
