Alloc compress state using vmalloc
This commit is contained in:
parent
92fc5158e2
commit
b8395c8a83
|
@ -65,7 +65,6 @@ lblk_is_zeros(struct cbd_params* params, struct lbd* lbd)
|
|||
}
|
||||
|
||||
struct lblk_compress_state {
|
||||
struct page* pages;
|
||||
u8* buf;
|
||||
#ifdef COMPRESS_HAVE_LZ4
|
||||
u8* lz4_workmem;
|
||||
|
@ -571,21 +570,20 @@ lbdcache_alloc_compress_state(void* percpu, const struct cbd_params* params, int
|
|||
}
|
||||
statep = per_cpu_ptr(percpu, cpu);
|
||||
*statep = state;
|
||||
state->pages = cbd_alloc_pages_nowait(lblk_per_pblk(params));
|
||||
if (!state->pages) {
|
||||
state->buf = vmalloc(PBLK_SIZE * lblk_per_pblk(params));
|
||||
if (!state->buf) {
|
||||
return false;
|
||||
}
|
||||
state->buf = page_address(state->pages);
|
||||
#ifdef COMPRESS_HAVE_LZ4
|
||||
workmem_len = LZ4_compressBound(PBLK_SIZE * lblk_per_pblk(params));
|
||||
state->lz4_workmem = kzalloc(workmem_len, GFP_NOWAIT);
|
||||
state->lz4_workmem = vzalloc(workmem_len);
|
||||
if (!state->lz4_workmem) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
#ifdef COMPRESS_HAVE_ZLIB
|
||||
workmem_len = zlib_deflate_workspacesize(MAX_WBITS, DEF_MEM_LEVEL);
|
||||
state->zlib_cstream.workspace = kzalloc(workmem_len, GFP_NOWAIT);
|
||||
state->zlib_cstream.workspace = vzalloc(workmem_len);
|
||||
if (!state->zlib_cstream.workspace) {
|
||||
return false;
|
||||
}
|
||||
|
@ -594,7 +592,7 @@ lbdcache_alloc_compress_state(void* percpu, const struct cbd_params* params, int
|
|||
Z_DEFAULT_STRATEGY);
|
||||
BUG_ON(ret != Z_OK);
|
||||
workmem_len = zlib_inflate_workspacesize();
|
||||
state->zlib_dstream.workspace = kzalloc(workmem_len, GFP_NOWAIT);
|
||||
state->zlib_dstream.workspace = vzalloc(workmem_len);
|
||||
if (!state->zlib_dstream.workspace) {
|
||||
return false;
|
||||
}
|
||||
|
@ -617,13 +615,13 @@ lbdcache_free_compress_state(void* percpu, const struct cbd_params* params, int
|
|||
return;
|
||||
}
|
||||
#ifdef COMPRESS_HAVE_ZLIB
|
||||
kfree(state->zlib_dstream.workspace);
|
||||
kfree(state->zlib_cstream.workspace);
|
||||
vfree(state->zlib_dstream.workspace);
|
||||
vfree(state->zlib_cstream.workspace);
|
||||
#endif
|
||||
#ifdef COMPRESS_HAVE_LZ4
|
||||
kfree(state->lz4_workmem);
|
||||
vfree(state->lz4_workmem);
|
||||
#endif
|
||||
cbd_free_pages(state->pages, lblk_per_pblk(params));
|
||||
vfree(state->buf);
|
||||
kfree(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,12 +39,6 @@ cbd_alloc_page(void)
|
|||
return alloc_page(GFP_KERNEL);
|
||||
}
|
||||
|
||||
struct page*
|
||||
cbd_alloc_page_nowait(void)
|
||||
{
|
||||
return alloc_page(GFP_NOWAIT);
|
||||
}
|
||||
|
||||
void
|
||||
cbd_free_page(struct page* page)
|
||||
{
|
||||
|
@ -57,12 +51,6 @@ cbd_alloc_pages(size_t len)
|
|||
return alloc_pages(GFP_KERNEL, get_order(len * PAGE_SIZE));
|
||||
}
|
||||
|
||||
struct page*
|
||||
cbd_alloc_pages_nowait(size_t len)
|
||||
{
|
||||
return alloc_pages(GFP_NOWAIT, get_order(len * PAGE_SIZE));
|
||||
}
|
||||
|
||||
void
|
||||
cbd_free_pages(struct page* pages, size_t len)
|
||||
{
|
||||
|
|
|
@ -456,14 +456,10 @@ typedef void (*pblk_endio_t)(struct bio*);
|
|||
/* Single page allocator */
|
||||
struct page*
|
||||
cbd_alloc_page(void);
|
||||
struct page*
|
||||
cbd_alloc_page_nowait(void);
|
||||
void cbd_free_page(struct page* page);
|
||||
/* Multiple page allocator */
|
||||
struct page*
|
||||
cbd_alloc_pages(size_t len);
|
||||
struct page*
|
||||
cbd_alloc_pages_nowait(size_t len);
|
||||
void cbd_free_pages(struct page* pages, size_t len);
|
||||
/* Vector page allocator */
|
||||
bool cbd_alloc_pagev(struct page** pagev, size_t len);
|
||||
|
|
Loading…
Reference in New Issue