]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Btrfs: fix incorrect block_len in merge_extent_mapping
authorLiu Bo <bo.li.liu@oracle.com>
Tue, 19 Dec 2017 22:42:54 +0000 (15:42 -0700)
committerJack Vogel <jack.vogel@oracle.com>
Thu, 1 Feb 2018 23:34:32 +0000 (15:34 -0800)
Orabug: 27446668

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

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, while for regular extent, em->block_len always
equals to em->len, hence this sets em->block_len with em->len.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
fs/btrfs/inode.c

index 77f73795ed42204f50cc7240e54f5ea5a8d9cd7e..27831a4aa8cbb446f50f5125683251a22441b0f6 100644 (file)
@@ -6667,7 +6667,7 @@ static int merge_extent_mapping(struct extent_map_tree *em_tree,
        if (em->block_start < EXTENT_MAP_LAST_BYTE &&
            !test_bit(EXTENT_FLAG_COMPRESSED, &em->flags)) {
                em->block_start += start_diff;
-               em->block_len -= start_diff;
+               em->block_len = em->len;
        }
        return add_extent_mapping(em_tree, em, 0);
 }