While writing Merkle tree, file is read-only and there's no further writes except Merkle tree building. The file will be truncated beforehand to remove any preallocated extents in futher patches. The Merkle tree is the only data XFS will write. We don't want XFS to truncate any post EOF extests due to existing preallocated extents. Therefore, we also need to disable preallocations while writing merkle tree. Signed-off-by: Andrey Albershteyn --- fs/xfs/xfs_iomap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index b5d70bcb63b9..52c41ef36d6d 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1941,7 +1941,9 @@ xfs_buffered_write_iomap_begin( * Determine the initial size of the preallocation. * We clean up any extra preallocation when the file is closed. */ - if (xfs_has_allocsize(mp)) + if (xfs_iflags_test(ip, XFS_VERITY_CONSTRUCTION)) + prealloc_blocks = 0; + else if (xfs_has_allocsize(mp)) prealloc_blocks = mp->m_allocsize_blocks; else if (allocfork == XFS_DATA_FORK) prealloc_blocks = xfs_iomap_prealloc_size(ip, allocfork, -- 2.51.2