Skip to contentSkip to conversation

Btrfs: compression must free at least one sector size

PATCH In review Timofey Titovets 2 participants 2 messages Jun 6, 2017 – Jun 13, 2017 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 Btrfs: compression must free at least one sector size

Btrfs already skip store of data where compression didn't free at least one byte. Let's make logic better and make check that compression free at least one sector size
because in another case it useless to store this data compressed

---
 fs/btrfs/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/inode.c +2 -3
index 17cbe930..7646f46b 100644
@@ -609,11 +609,10 @@ 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
+		 * 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;
 

--
2.13.0

Reviewed-by on v6 1/1
#1 lore raw
Quoted 6 lines · Timofey Titovets

Btrfs already skip store of data where compression didn't free at least one byte. Let's make logic better and make check that compression free at least one sector size
because in another case it useless to store this data compressed

I've updated the changelog a bit.