On Mon, Jun 09, 2025 at 04:30:14PM -0700, Joanne Koong wrote: > > When writing this code I was under the impression that > > folio_end_writeback needs to be called after unlocking the page. > > > > If that is not actually the case we can just move the unlocking into the > > caller and make things a lot cleaner than the conditional locking > > argument. > > I don't think we can move this into the caller of ->writeback_folio() > / ->map_blocks(). iomap does some preliminary optimization checking > (eg skipping writing back truncated ranges) in > iomap_writepage_handle_eof() which will unlock the folio if succesful > and is called separately from those callbacks. As well it's not clear > for the caller to know when the folio can be unlocked (eg if the range > being written back / mapped is the last range in that folio). Note that with caller I meant the immediate caller of iomap_writepage_map, i.e. iomap_writepages only for the existing code that needs the unlock, and your new iomap_writeback_dirty_folio that doesn't.