提交 a520a7e0 编写于 作者: L Liu Bo 提交者: David Sterba

Btrfs: fix incorrect block_len in merge_extent_mapping

%block_len could be checked on deciding if two em are mergeable.

merge_extent_mapping() has only added the front pad if the front part
of em gets truncated, but it's possible that the end part gets
truncated.

For both compressed extent and inline extent, em->block_len is not
adjusted accordingly, and for regular extent, em->block_len always
equals to em->len, hence this sets em->block_len with em->len.
Signed-off-by: NLiu Bo <bo.li.liu@oracle.com>
Reviewed-by: NJosef Bacik <jbacik@fb.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 3cbf26da
...@@ -6874,7 +6874,7 @@ static int merge_extent_mapping(struct extent_map_tree *em_tree, ...@@ -6874,7 +6874,7 @@ static int merge_extent_mapping(struct extent_map_tree *em_tree,
if (em->block_start < EXTENT_MAP_LAST_BYTE && if (em->block_start < EXTENT_MAP_LAST_BYTE &&
!test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) { !test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) {
em->block_start += start_diff; em->block_start += start_diff;
em->block_len -= start_diff; em->block_len = em->len;
} }
return add_extent_mapping(em_tree, em, 0); return add_extent_mapping(em_tree, em, 0);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册