OSDN Git Service

Btrfs: compression must free at least one sector size
authorTimofey Titovets <nefelim4ag@gmail.com>
Tue, 6 Jun 2017 11:41:15 +0000 (14:41 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Jun 2017 16:26:04 +0000 (18:26 +0200)
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>
fs/btrfs/inode.c

index b74a6d2..a21a984 100644 (file)
@@ -607,12 +607,11 @@ cont:
 
                /*
                 * 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;