Include mpool in env and use new allocator API

Signed-off-by: Jan Musial <jan.musial@intel.com>
This commit is contained in:
Jan Musial
2021-02-25 09:46:34 +01:00
parent bcc55f4f3c
commit f1a19363e5
5 changed files with 107 additions and 78 deletions

View File

@@ -11,7 +11,7 @@
#include "utils/utils_mpool.h"
#include "threads.h"
struct cas_mpool *cas_bvec_pool;
struct env_mpool *cas_bvec_pool;
struct cas_reserve_pool *cas_bvec_pages_rpool;
@@ -87,7 +87,7 @@ ctx_data_t *__cas_ctx_data_alloc(uint32_t pages, bool zalloc)
struct page *page = NULL;
int cpu;
data = cas_mpool_new(cas_bvec_pool, pages);
data = env_mpool_new(cas_bvec_pool, pages);
if (!data) {
CAS_PRINT_RL(KERN_ERR "Couldn't allocate BIO vector.\n");
@@ -133,7 +133,7 @@ ctx_data_t *__cas_ctx_data_alloc(uint32_t pages, bool zalloc)
}
}
cas_mpool_del(cas_bvec_pool, data, pages);
env_mpool_del(cas_bvec_pool, data, pages);
data = NULL;
} else {
/* Initialize iterator */
@@ -175,7 +175,7 @@ void cas_ctx_data_free(ctx_data_t *ctx_data)
__free_page(page);
}
cas_mpool_del(cas_bvec_pool, data, data->size);
env_mpool_del(cas_bvec_pool, data, data->size);
}
static int _cas_ctx_data_mlock(ctx_data_t *ctx_data)
@@ -426,15 +426,15 @@ static const struct ocf_ctx_config ctx_cfg = {
int cas_initialize_context(void)
{
struct blk_data data;
int ret;
ret = ocf_ctx_create(&cas_ctx, &ctx_cfg);
if (ret < 0)
return ret;
cas_bvec_pool = cas_mpool_create(sizeof(data), sizeof(data.vec[0]),
GFP_NOIO, 7, "cas_biovec");
cas_bvec_pool = env_mpool_create(sizeof(struct blk_data),
sizeof(struct bio_vec), GFP_NOIO, 7, true, NULL,
"cas_biovec");
if (!cas_bvec_pool) {
printk(KERN_ERR "Cannot create BIO vector memory pool\n");
@@ -472,7 +472,7 @@ int cas_initialize_context(void)
err_rpool:
cas_rpool_destroy(cas_bvec_pages_rpool, _cas_free_page_rpool, NULL);
err_mpool:
cas_mpool_destroy(cas_bvec_pool);
env_mpool_destroy(cas_bvec_pool);
err_ctx:
ocf_ctx_put(cas_ctx);
@@ -482,7 +482,7 @@ err_ctx:
void cas_cleanup_context(void)
{
cas_garbage_collector_deinit();
cas_mpool_destroy(cas_bvec_pool);
env_mpool_destroy(cas_bvec_pool);
cas_rpool_destroy(cas_bvec_pages_rpool, _cas_free_page_rpool, NULL);
ocf_ctx_put(cas_ctx);
@@ -495,7 +495,7 @@ void cas_cleanup_context(void)
*/
struct blk_data *cas_alloc_blk_data(uint32_t size, gfp_t flags)
{
struct blk_data *data = cas_mpool_new_f(cas_bvec_pool, size, flags);
struct blk_data *data = env_mpool_new_f(cas_bvec_pool, size, flags);
if (data)
data->size = size;
@@ -511,6 +511,6 @@ void cas_free_blk_data(struct blk_data *data)
if (!data)
return;
cas_mpool_del(cas_bvec_pool, data, data->size);
env_mpool_del(cas_bvec_pool, data, data->size);
}