From: Dave Chinner <dchinner@xxxxxxxxxx> For buffered writes into block size > page size filesystems, XFS will need to trigger zero-around for delayed allocation mappings and writes over unwritten extents. Unwritten extents will only remain unwritten until the first data gets written back, so we have to ensure that any write mapping triggers zero-around for them. Delayed allocation occurs over holes, which then require the data in the page cache to completely cover them at write-out time. Hence we have to trigger write-around for these mappings, too. Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx> --- fs/xfs/xfs_iomap.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 27c93b5f029d..35626855e207 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -575,6 +575,15 @@ xfs_file_iomap_begin_delay( goto out_unlock; } + /* + * If we are about to write to an unwritten extent and the + * the block size is larger than page size, then we need to make sure + * that the caller zeroes blocks partially covered by data. + */ + if (got.br_state == XFS_EXT_UNWRITTEN && + mp->m_sb.sb_blocksize > PAGE_SIZE) + iomap->flags |= IOMAP_F_ZERO_AROUND; + trace_xfs_iomap_found(ip, offset, count, 0, &got); goto done; } @@ -647,6 +656,8 @@ xfs_file_iomap_begin_delay( * them out if the write happens to fail. */ iomap->flags |= IOMAP_F_NEW; + if (mp->m_sb.sb_blocksize > PAGE_SIZE) + iomap->flags |= IOMAP_F_ZERO_AROUND; trace_xfs_iomap_alloc(ip, offset, count, 0, &got); done: if (isnullstartblock(got.br_startblock)) @@ -1107,6 +1118,15 @@ xfs_file_iomap_begin( if (flags & IOMAP_ZERO) goto out_found; + /* + * If we are about to write to an unwritten extent and the + * the block size is larger than page size, then we need to make sure + * that the caller zeroes blocks partially covered by data. + */ + if (imap.br_state == XFS_EXT_UNWRITTEN && + mp->m_sb.sb_blocksize > PAGE_SIZE) + iomap->flags |= IOMAP_F_ZERO_AROUND; + if (!imap_needs_alloc(inode, &imap, nimaps)) goto out_found; -- 2.19.1