[PATCH] Btrfs: return -1 when lzo compression makes data bigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With this fix the lzo code behaves like the zlib code by returning an error
code when compression does not help reduce the size of the file.
This is currently not a bug since the compressed size is checked again in
the calling method compress_file_range.

Signed-off-by: Stefan Agner <stefan@xxxxxxxx>
---
 fs/btrfs/lzo.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c
index f93151a..b6a6f07 100644
--- a/fs/btrfs/lzo.c
+++ b/fs/btrfs/lzo.c
@@ -207,8 +207,10 @@ static int lzo_compress_pages(struct list_head *ws,
 		}

 		/* we're making it bigger, give up */
-		if (tot_in > 8192 && tot_in < tot_out)
+		if (tot_in > 8192 && tot_in < tot_out) {
+			ret = -1;
 			goto out;
+		}

 		/* we're all done */
 		if (tot_in >= len)
--
1.8.3.1


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux