Skip to content

Commit

Permalink
Btrfs: compression must free at least one sector size
Browse files Browse the repository at this point in the history
We already skip storing data where compression does not make the result
at least one byte less.  Let's make the logic better and check
that compression frees at least one sector size of bytes, otherwise it's
not that useful.

Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ changelog updated ]
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Timofey Titovets authored and David Sterba committed Jun 19, 2017
1 parent c5e4c3d commit 170607e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,11 @@ static noinline void compress_file_range(struct inode *inode,

/*
* one last check to make sure the compression is really a
* win, compare the page count read with the blocks on disk
* win, compare the page count read with the blocks on disk,
* compression must free at least one sector size
*/
total_in = ALIGN(total_in, PAGE_SIZE);
if (total_compressed >= total_in) {
will_compress = 0;
} else {
if (total_compressed + blocksize <= total_in) {
num_bytes = total_in;
*num_added += 1;

Expand Down

0 comments on commit 170607e

Please sign in to comment.