]> git.hungrycats.org Git - linux/commitdiff
Btrfs: fix merge delalloc logic
authorJosef Bacik <jbacik@fb.com>
Fri, 13 Mar 2015 19:12:08 +0000 (15:12 -0400)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Tue, 14 Apr 2015 02:33:19 +0000 (22:33 -0400)
My patch to properly count outstanding extents wrt MAX_EXTENT_SIZE introduced a
regression when re-dirtying already dirty areas.  We have logic in split to make
sure we are taking the largest space into account but didn't have it for merge,
so it was sometimes making us think we were turning a tiny extent into a huge
extent, when in reality we already had a huge extent and needed to use the other
side in our logic.  This fixes the regression that was reported by a user on
list.  Thanks,

Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Chris Mason <clm@fb.com>
(cherry picked from commit 8461a3de770477a9a7b8eeaebcc4804dbc26ca38)

fs/btrfs/inode.c

index 788df198fdb522c44e18f3dff25070d7c2ccaa61..6a669c25af9de17dc1161ca3c9f68f1dd906a4d9 100644 (file)
@@ -1592,7 +1592,12 @@ static void btrfs_merge_extent_hook(struct inode *inode,
                return;
 
        old_size = other->end - other->start + 1;
-       new_size = old_size + (new->end - new->start + 1);
+       if (old_size < (new->end - new->start + 1))
+               old_size = (new->end - new->start + 1);
+       if (new->start > other->start)
+               new_size = new->end - other->start + 1;
+       else
+               new_size = other->end - new->start + 1;
 
        /* we're not bigger than the max, unreserve the space and go */
        if (new_size <= BTRFS_MAX_EXTENT_SIZE) {