summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorLiu Bo <bo.li.liu@oracle.com>2018-01-05 20:51:08 +0100
committerDavid Sterba <dsterba@suse.com>2018-01-22 16:08:21 +0100
commita520a7e0b548690ea8eb77bb45800459351a7cf5 (patch)
tree6f865743331bbeeba4babc96f23fe2229d17accc /fs/btrfs/inode.c
parentbtrfs: Remove unused readahead spinlock (diff)
downloadlinux-a520a7e0b548690ea8eb77bb45800459351a7cf5.tar.xz
linux-a520a7e0b548690ea8eb77bb45800459351a7cf5.zip
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: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to '')
-rw-r--r--fs/btrfs/inode.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 633b83b709a1..f9fd8b14ef08 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6874,7 +6874,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);
}