On Mon, Jun 09, 2025 at 09:27:07PM -0700, Christoph Hellwig wrote: > On Mon, Jun 09, 2025 at 09:04:20AM -0700, Darrick J. Wong wrote: > > > + if (iter->fbatch) { > > > + struct folio *folio = folio_batch_next(iter->fbatch); > > > + > > > + if (folio) { > > > + folio_get(folio); > > > + folio_lock(folio); > > > > Hrm. So each folio that is added to the batch isn't locked, nor does > > the batch (or iomap) hold a refcount on the folio until we get here. > > find_get_entry references a folio, and filemap_get_folios_dirty > preserves that reference. It will be released in folio_batch_release. > So this just add an extra reference for local operation so that the > rest of iomap doesn't need to know about that magic. > Exactly. > > Do > > we have to re-check that folio->{mapping,index} match what iomap is > > trying to process? Or can we assume that nobody has removed the folio > > from the mapping? > > That's a good point, though as without having the folio locked it > could get truncated, so I think we'll have to redo the truncate > check here. > > Hm Ok thanks, I'll take a closer look at that.. Brian