[PATCH v0] mkfs.ubifs: Add support for lz4hc compressor in mkfs.ubifs

Elie De Brauwer eliedebrauwer at gmail.com
Sat Oct 5 07:17:45 PDT 2013


On Sat, Oct 5, 2013 at 3:51 PM, Konstantin Tokarev <annulen at yandex.ru> wrote:
>
>
> 05.10.2013, 17:25, "Konstantin Tokarev" <annulen at yandex.ru>:
>> 05.10.2013, 16:56, "Elie De Brauwer" <eliedebrauwer at gmail.com>:
>>
>>>  That's odd, yesterday I started by cloning mtd-utils.git and when I
>>>  try to repeat my own steps and apply my patch it does seem to work.
>>
>> I've figured it out: you've included patch into the mail instead of attaching
>> it as a file, so I copied it, and tab characters got lost. patch -p1 -l
>> works successfully.
>
> When trying to compress my rootfs, I got message "32866 compression errors occurred".
> Resulting image is much larger than LZO one (133M for lz4hc, 86M for lzo, 79M for zlib)
>


That only proofs I wasn't lying when I wrote this morning that my code
was fully untested. I had some time to do some testing and if you
apply the following, (cummulative to my last patch) it should also
work.

diff --git a/mkfs.ubifs/compr.c b/mkfs.ubifs/compr.c
index d9886b4..0900653 100644
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
@@ -110,11 +110,12 @@ static int lz4hc_compress(void *in_buf, size_t in_len, voi
 {
        int ret;
        ret = LZ4_compressHC_limitedOutput(in_buf, out_buf, in_len, *out_len);
-
-       if (ret != 0) {
+       if (ret == 0) {
                errcnt += 1;
                return -1;
        }
+       else
+               *out_len = ret;

        return 0;
 }

I get the following (preliminary) results:

edb at lapelidb:/tmp$ ls -hal imag*
-rw-r--r-- 1 edb  edb  28M Oct  5 16:12 imag.lz4hc
-rw-r--r-- 1 root root 25M Oct  5 16:09 imag.lzo
-rw-r--r-- 1 root root 43M Oct  5 16:11 imag.none
-rw-r--r-- 1 root root 22M Oct  5 16:11 imag.zlib

gr
E.



-- 
Elie De Brauwer



More information about the linux-mtd mailing list