@@ -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;