Skip to content

Commit

Permalink
Btrfs: fix autodefrag with compression
Browse files Browse the repository at this point in the history
The autodefrag code skips defrag when two extents are adjacent.  But one
big advantage for autodefrag is cutting down on the number of small
extents, even when they are adjacent.  This commit changes it to defrag
all small extents.

Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Chris Mason committed Aug 27, 2014
1 parent 9e0af23 commit e9512d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,10 @@ static bool defrag_check_next_extent(struct inode *inode, struct extent_map *em)
return false;

next = defrag_lookup_extent(inode, em->start + em->len);
if (!next || next->block_start >= EXTENT_MAP_LAST_BYTE ||
(em->block_start + em->block_len == next->block_start))
if (!next || next->block_start >= EXTENT_MAP_LAST_BYTE)
ret = false;
else if ((em->block_start + em->block_len == next->block_start) &&
(em->block_len > 128 * 1024 && next->block_len > 128 * 1024))
ret = false;

free_extent_map(next);
Expand Down Expand Up @@ -1055,7 +1057,6 @@ static int should_defrag_range(struct inode *inode, u64 start, int thresh,
}

next_mergeable = defrag_check_next_extent(inode, em);

/*
* we hit a real extent, if it is big or the next extent is not a
* real extent, don't bother defragging it
Expand Down

0 comments on commit e9512d7

Please sign in to comment.