linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Btrfs: return -1 when lzo compression makes data bigger
Date: Mon, 01 Jul 2013 20:33:39 +0200	[thread overview]
Message-ID: <ee94bd82a8a03550596ada76ce4cca29@agner.ch> (raw)

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@agner.ch>
---
  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



                 reply	other threads:[~2013-07-01 18:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee94bd82a8a03550596ada76ce4cca29@agner.ch \
    --to=stefan@agner.ch \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).