Re: [PATCH] zram: don't copy invalid compression algorithms

From: Sergey Senozhatsky
Date: Mon Sep 07 2015 - 21:57:53 EST


On (09/08/15 10:33), Sergey Senozhatsky wrote:
> > I don't understand your concern. To me, this patch makes sense to me.
> > Could you explain your point clearly, again?
>
> OK. suppose someone landed a typo in a 'zram device management' script
>
> echo llzo > /sys/block/zram0/comp_algorithm
> -bash: echo: write error: Invalid argument
>
>
> but the script ignores 'echo: write error'.
> Because we added compression algorithm name check recently.
>
> then the script does
>
> echo 200M > /sys/block/zram0/disksize
> -bash: echo: write error: Invalid argument
>
>
> doing a simple dmesg reveals the problem
>
> [ 7076.657184] zram: Cannot initialise llzo compressing backend
>
> note that zram provides 'llzo' here, which is convenient.

ah, forgot to mention. there is another misleading thing.

suppose the script checks the comp_algorithm() error code.
and it attempts to do somthing like
echo llzo > /sys/block/zram0/comp_algorithm
-bash: echo: write error: Device or resource busy


so user knows that comp_algorithm failed. so now
he/she goes and checks zram

cat /sys/block/zram0/comp_algorithm
[lzo] lz4


and finds out... that [lzo] is supported and selected for usage.

so what't the problem then? so user wrongly assumes now that the
script has provided 'lzo' as input to zram... false!



the existing scheme of things will provide additional hint.

#current implementation
cat /sys/block/zram0/comp_algorithm
lzo lz4

so, none of the supported compression algorithms is selected.
aha, that is obviously lead us to a conclusion that something
wrong was with the input that script provided to zram. correct!

-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/