> + struct iomap_iter *iter = container_of(iomap, struct iomap_iter, iomap); Overly long line. > struct xfs_inode *ip = XFS_I(inode); > struct xfs_mount *mp = ip->i_mount; > xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); > @@ -1065,12 +1066,21 @@ xfs_buffered_write_iomap_begin( > */ > if (flags & IOMAP_ZERO) { > xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); > + u64 end; > > if (isnullstartblock(imap.br_startblock) && > offset_fsb >= eof_fsb) > goto convert_delay; > if (offset_fsb < eof_fsb && end_fsb > eof_fsb) > end_fsb = eof_fsb; > + if (imap.br_state == XFS_EXT_UNWRITTEN && > + offset_fsb < eof_fsb) { > + xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); > + end = iomap_fill_dirty_folios(iter, > + XFS_FSB_TO_B(mp, imap.br_startoff), > + XFS_FSB_TO_B(mp, imap.br_blockcount)); > + end_fsb = min_t(xfs_fileoff_t, end_fsb, XFS_B_TO_FSB(mp, end)); A few more here. But most importantly please add a comment desribing the logic behind this in the function. It's hairy logic and not obvious from reading the code, so explaining it will be helpful. Splitting it into a separate helper might be useful for that, but due to the amount of state shared with the caller that might not look all that pretty in the end, so I'm not entirely sure about it.