linux/drivers/staging/zram
Nitin Gupta c8f2f0db1d staging: zram: Fix handling of incompressible pages
Change 130f315a (staging: zram: remove special handle of uncompressed page)
introduced a bug in the handling of incompressible pages which resulted in
memory allocation failure for such pages.

When a page expands on compression, say from 4K to 4K+30, we were trying to
do zsmalloc(pool, 4K+30). However, the maximum size which zsmalloc can
allocate is PAGE_SIZE (for obvious reasons), so such allocation requests
always return failure (0).

For a page that has compressed size larger than the original size (this may
happen with already compressed or random data), there is no point storing
the compressed version as that would take more space and would also require
time for decompression when needed again. So, the fix is to store any page,
whose compressed size exceeds a threshold (max_zpage_size), as-it-is i.e.
without compression.  Memory required for storing this uncompressed page can
then be requested from zsmalloc which supports PAGE_SIZE sized allocations.

Lastly, the fix checks that we do not attempt to "decompress" the page which
we stored in the uncompressed form -- we just memcpy() out such pages.

Signed-off-by: Nitin Gupta <ngupta@vflare.org>
Reported-by: viechweg@gmail.com
Reported-by: paerley@gmail.com
Reported-by: wu.tommy@gmail.com
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-10-22 13:45:19 -07:00
..
Kconfig staging: zram/zcache: swtich Kconfig dependency from X86 to ZSMALLOC 2012-06-25 10:00:53 -07:00
Makefile staging: zram: replace xvmalloc with zsmalloc 2012-02-08 17:13:00 -08:00
zram_drv.c staging: zram: Fix handling of incompressible pages 2012-10-22 13:45:19 -07:00
zram_drv.h staging: zram: conventions, __aligned() attribute 2012-06-11 09:04:15 -07:00
zram_sysfs.c staging: zram: remove special handle of uncompressed page 2012-06-11 09:00:01 -07:00
zram.txt Staging: zram: Update zram documentation 2010-08-31 15:36:36 -07:00