From patchwork Thu Feb 28 18:26:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4/6] ext4: fix wrong m_len value after unwritten extent conversion Date: Thu, 28 Feb 2013 08:26:42 -0000 From: Zheng Liu X-Patchwork-Id: 224128 Message-Id: <1362076004-10087-5-git-send-email-wenqing.lz@taobao.com> To: linux-ext4@vger.kernel.org Cc: Zheng Liu , "Theodore Ts'o" , Dmitry Monakhov From: Zheng Liu We always assume that the return value of ext4_ext_map_blocks is equal to map->m_len but when we try to convert an unwritten extent 'm_len' value will break this assumption. It is harmless until we use status tree as a extent cache because we need to update status tree according to 'm_len' value. Meanwhile this commit marks EXT4_MAP_MAPPED flag after unwritten extent conversion. It shouldn't cause a bug because we update status tree according to checking EXT4_MAP_UNWRITTEN flag. But it should be fixed. After applied this commit, the following error message from self-testing infrastructure disappears. ... kernel: ES len assertation failed for inode: 230 retval 1 != map->m_len 3 in ext4_map_blocks (allocation) ... Signed-off-by: Zheng Liu Cc: "Theodore Ts'o" Cc: Dmitry Monakhov --- fs/ext4/extents.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 372b2cb..0793a13 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3626,6 +3626,10 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, path, map->m_len); } else err = ret; + map->m_flags |= EXT4_MAP_MAPPED; + if (allocated > map->m_len) + allocated = map->m_len; + map->m_len = allocated; goto out2; } /* buffered IO case */