On Thu, May 18, 2023 at 06:23:44AM -0700, Christoph Hellwig wrote: > On Wed, May 17, 2023 at 02:48:12PM -0400, Brian Foster wrote: > > But I also wonder.. if we can skip the iop alloc on full folio buffered > > overwrites, isn't that also true of mapped writes to folios that don't > > already have an iop? > > Yes. Hm, well, maybe? If somebody stores to a page, we obviously set the dirty flag on the folio, but depending on the architecture, we may or may not have independent dirty bits on the PTEs (eg if it's a PMD, we have one dirty bit for the entire folio; similarly if ARM uses the contiguous PTE bit). If we do have independent dirty bits, we could dirty only the blocks corresponding to a single page at a time. This has potential for causing some nasty bugs, so I'm inclined to rule that if a folio is mmaped, then it's all dirty from any writable page fault. The fact is that applications generally do not perform writes through mmap because the error handling story is so poor. There may be a different answer for anonymous memory, but that doesn't feel like my problem and shouldn't feel like any FS developer's problem.