We should ideally never encounter a hole during the endio conversion as that indicates something is wrong with our extent handling. Still if we do find a hole at atomic write endio, ext4_map_blocks() returns 0 which would be returned back to callers by ext4_convert_unwritten_extents_atomic(). This can be wrongly interpreted as a success. Fix this by bailing out with -EINVAL instead. Signed-off-by: Ojaswin Mujoo --- fs/ext4/extents.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 7193429a05e1..b54d8227786b 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -5107,6 +5107,14 @@ int ext4_convert_unwritten_extents_atomic(handle_t *handle, struct inode *inode, map.m_lblk += ret; map.m_len = (max_blocks -= ret); ret = ext4_map_blocks(handle, inode, &map, flags); + if (ret == 0) { + ext4_msg(inode->i_sb, KERN_ERR, + "inode #%llu: block %u: len %u: " + "hole found while converting extents for atomic write", + inode->i_ino, map.m_lblk, map.m_len); + ret = -EINVAL; + break; + } if (ret != max_blocks) ext4_msg(inode->i_sb, KERN_INFO, "inode #%llu: block %u: len %u: " --- base-commit: 8c4f6e3376348fc3162eed86a05b933921c8f9ed change-id: 20261023-ext4-atomic-endio-fix-b4-9e1ead9e1aca Best regards, -- Ojaswin Mujoo