zram: check comp algorithm availability earlier
authorSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Thu, 25 Jun 2015 22:00:32 +0000 (15:00 -0700)
committerDanny Wood <danwood76@gmail.com>
Tue, 14 Sep 2021 19:02:54 +0000 (20:02 +0100)
commit6a57d62a52bdc7c4fa95b1a1f398bfd0311e2a65
tree8d4ba97a4680ca2f072391cb6b929cf13694284d
parent5b25b5dac9c3a3c9cd1e90cd66887f779b1d0d37
zram: check comp algorithm availability earlier

Improvement idea by Marcin Jabrzyk.

comp_algorithm_store() silently accepts any supplied algorithm name,
because zram performs algorithm availability check later, during the
device configuration phase in disksize_store() and emits the following
error:

  "zram: Cannot initialise %s compressing backend"

this error line is somewhat generic and, besides, can indicate a failed
attempt to allocate compression backend's working buffers.

add algorithm availability check to comp_algorithm_store():

  echo lzz > /sys/block/zram0/comp_algorithm
  -bash: echo: write error: Invalid argument

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Reported-by: Marcin Jabrzyk <m.jabrzyk@samsung.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: Iece40446b18e7e37fa4ced3459d40ddbb9984297
drivers/block/zram/zcomp.c
drivers/block/zram/zcomp.h
drivers/block/zram/zram_drv.c