aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/inode.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 91a87f53be3c..97b601bec326 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1592,7 +1592,12 @@ static void btrfs_merge_extent_hook(struct inode *inode,
1592 return; 1592 return;
1593 1593
1594 old_size = other->end - other->start + 1; 1594 old_size = other->end - other->start + 1;
1595 new_size = old_size + (new->end - new->start + 1); 1595 if (old_size < (new->end - new->start + 1))
1596 old_size = (new->end - new->start + 1);
1597 if (new->start > other->start)
1598 new_size = new->end - other->start + 1;
1599 else
1600 new_size = other->end - new->start + 1;
1596 1601
1597 /* we're not bigger than the max, unreserve the space and go */ 1602 /* we're not bigger than the max, unreserve the space and go */
1598 if (new_size <= BTRFS_MAX_EXTENT_SIZE) { 1603 if (new_size <= BTRFS_MAX_EXTENT_SIZE) {