On Thu, Apr 10, 2025 at 12:11:42PM -0700, John Hubbard wrote: > Oh actually I think I was wrong in my earlier reply about clearing > the dirty bit. Because in Jan Kara's original bug report, what > happened was that periodic writeback came in while the pages > were pinned, and cleared the dirty bit--and also deleted the > page buffers (file system specific behavior) that are required > for writeback. > > So then later when the pages are unpinned and marked dirty, > that causes the next writeback to fail in an unexpected way > (it used to cause ext4 BUG checks, in fact). > > So the problem here is that these pinned pages can get cleaned > while they are pinned, and then dirtied again by DMA (invisible > to the filesystem). I've looked around a bit. We do skip pinned pags in shrink_folio_list (btw, can someone please split that thing up, it's so huge that it is completely unreadable) but that's not really relevant for clearing the dirty bit for filemap folios these days despite comments talking about just that. So I guess, yes - we'd need to skip folio_maybe_dma_pinned() in writeback, or wait for the bit to be cleared for data integrity writeback. Which doesn't sound too hard, but there might be pitfalls.