diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 484cb7388802..4fadc476d645 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -418,9 +418,7 @@ static const struct iomap_dio_ops ext4_dio_write_ops = { * updating inode i_disksize and/or orphan handling with exclusive lock. * * - shared locking will only be true mostly with overwrites, including - * initialized blocks and unwritten blocks. For overwrite unwritten blocks - * we protect splitting extents by i_data_sem in ext4_inode_info, so we can - * also release exclusive i_rwsem lock. + * initialized blocks and unwritten blocks. * * - Otherwise we will switch to exclusive i_rwsem lock. */ diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index b86ddc9e85ce..1cb7775c5e41 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3813,9 +3813,14 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, ret = ext4_map_blocks(NULL, inode, &map, 0); /* * For atomic writes the entire requested length should - * be mapped. + * be mapped. For DAX we convert extents to initialized + * ones before copying the data, otherwise we do it + * after I/O so there's no need to call into + * ext4_iomap_alloc(). */ - if (map.m_flags & EXT4_MAP_MAPPED) { + if ((map.m_flags & EXT4_MAP_MAPPED) || + (!(flags & IOMAP_DAX) && + (map.m_flags & EXT4_MAP_UNWRITTEN))) { if ((!(flags & IOMAP_ATOMIC) && ret > 0) || (flags & IOMAP_ATOMIC && ret >= orig_mlen)) goto out;