Re: [PATCH] btrfs: use kmalloc for lzo de/compress buffer

From: David Sterba
Date: Fri Feb 15 2013 - 08:17:30 EST


On Fri, Feb 15, 2013 at 10:08:21PM +0900, Kyungsik Lee wrote:
> The size of de/compress buffer and LZO1X_MEM_COMPRESS is small enough.

Unfortunatelly it is not.

include/linux/lzo.h:

#define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *))

128k with 8 byte pointers

> @@ -54,9 +53,10 @@ static struct list_head *lzo_alloc_workspace(void)
> if (!workspace)
> return ERR_PTR(-ENOMEM);
>
> - workspace->mem = vmalloc(LZO1X_MEM_COMPRESS);

vmalloc needed

> - workspace->buf = vmalloc(PAGE_CACHE_SIZE);

kmalloc is ok here

> - workspace->cbuf = vmalloc(lzo1x_worst_compress(PAGE_CACHE_SIZE));

#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)

4096+4096/16+64+3 = 4419

vmalloc needed as well

david
--
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/