So, the whole scan for delalloc logic seems pretty generic, I think it can an should be lifted to iomap, with xfs_buffered_write_delalloc_punch provided as a callback. As for the reuse of the seek hole / data helpers, and I'm not sure this actually helps all that much, and certainly is not super efficient. I don't want you to directly talk into rewriting this once again, but a simple while ((folio = find_get_entry(&xas, max, XA_PRESENT))) { if (xa_is_value(folio) || folio_test_uptodate(folio) || ops->is_partially_uptodate) { xas_pause(xas); rcu_read_unlock(); folio_lock(folio); if (likely(folio->mapping == mapping) && folio_test_dirty(folio)) { // crop folio start / end by total range if (ops->is_partially_uptodate) { // find partial range } // add to or start new range } } else { // pause rcu unlock and submit previous range if // needed } // move to next folio with size magic etc } // submit pending range if it exists