zram: check comp algorithm availability earlier
authorSergey Senozhatsky <[email protected]>
Thu, 25 Jun 2015 22:00:32 +0000 (15:00 -0700)
committerLinus Torvalds <[email protected]>
Fri, 26 Jun 2015 00:00:37 +0000 (17:00 -0700)
commitd93435c3fba4a47b773693b0c8992470d38510d5
tree0eee23d9451b404c4f2aa9ad7e6a6fe970806cae
parent4bbacd51a683e45c13f7d6df6f85cb7391590311
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 <[email protected]>
Reported-by: Marcin Jabrzyk <[email protected]>
Acked-by: Minchan Kim <[email protected]>
Cc: Nitin Gupta <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/block/zram/zcomp.c
drivers/block/zram/zcomp.h
drivers/block/zram/zram_drv.c