On Sat, Jun 25, 2022 at 11:11:43AM +0200, Christoph Hellwig wrote: > On Fri, Jun 24, 2022 at 03:07:50PM +0200, Jan Kara wrote: > > I'm not sure I get the context 100% right but pages getting randomly dirty > > behind filesystem's back can still happen - most commonly with RDMA and > > similar stuff which calls set_page_dirty() on pages it has got from > > pin_user_pages() once the transfer is done. page_maybe_dma_pinned() should > > be usable within filesystems to detect such cases and protect the > > filesystem but so far neither me nor John Hubbart has got to implement this > > in the generic writeback infrastructure + some filesystem as a sample case > > others could copy... > > Well, so far the strategy elsewhere seems to be to just ignore pages > only dirtied through get_user_pages. E.g. iomap skips over pages > reported as holes, and ext4_writepage complains about pages without > buffers and then clears the dirty bit and continues. > > I'm kinda surprised that btrfs wants to treat this so special > especially as more of the btrfs page and sub-page status will be out > of date as well. I'm not sure it's safe to ignore that in btrfs, that's sounds quite risky and potentially breaking something. It's not only that page does not have buffers but that there's page with dirty bit set but without the associated extents updated. So this needs a COW to get it back to sync. It's special because it's for COW, can't compare that to ext4.