Thread (27 messages) 27 messages, 8 authors, 2025-10-22

Re: O_DIRECT vs BLK_FEAT_STABLE_WRITES, was Re: [PATCH] btrfs: never trust the bio from direct IO

From: Christoph Hellwig <hch@infradead.org>
Date: 2025-10-21 07:49:50
Also in: linux-btrfs, linux-fsdevel, linux-mm, linux-xfs

On Mon, Oct 20, 2025 at 09:00:50PM +0200, David Hildenbrand wrote:
Just FYI, because it might be interesting in this context.

For anonymous memory we have this working by only writing the folio out if
it is completely unmapped and there are no unexpected folio references/pins
(see pageout()), and only allowing to write to such a folio ("reuse") if
SWP_STABLE_WRITES is not set (see do_swap_page()).

So once we start writeback the folio has no writable page table mappings
(unmapped) and no GUP pins. Consequently, when trying to write to it we can
just fallback to creating a page copy without causing trouble with GUP pins.
Yeah.  But anonymous is the easy case, the pain is direct I/O to file
mappings.  Mapping the right answer is to just fail pinning them and fall 
back to (dontcache) buffered I/O.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help