Skip to content

Commit

Permalink
Btrfs: fix merge delalloc logic
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Josef Bacik <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
Josef Bacik authored and masoncl committed Mar 13, 2015
1 parent 48da5f0 commit 8461a3d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8461a3d

Please sign in to comment.