Add utils_mpool

Signed-off-by: Robert Baldyga <robert.baldyga@intel.com>
This commit is contained in:
Robert Baldyga
2019-05-27 12:51:40 +02:00
parent ed2bc8712f
commit 8d59e41e20
5 changed files with 227 additions and 19 deletions

View File

@@ -4,6 +4,7 @@
*/
#include "cas_cache.h"
#include "utils/utils_mpool.h"
#if defined(CAS_NVME_FULL)
#include <linux/nvme.h>
@@ -61,7 +62,7 @@ struct cas_atomic_io {
struct bio_vec_iter iter;
};
static struct ocf_mpool *atomic_io_allocator;
static struct cas_mpool *atomic_io_allocator;
static inline uint32_t cas_atomic_max_io_sectors(void)
{
@@ -96,7 +97,7 @@ static void cas_atomic_dealloc(struct cas_atomic_io *atomics)
}
}
ocf_mpool_del(atomic_io_allocator, atomics, atomics->count);
cas_mpool_del(atomic_io_allocator, atomics, atomics->count);
}
static struct cas_atomic_io *cas_atomic_alloc(int dir, struct ocf_io *io, bool write_zero)
@@ -138,7 +139,7 @@ static struct cas_atomic_io *cas_atomic_alloc(int dir, struct ocf_io *io, bool w
/* Get number of IOs to be issued */
ios_count = DIV_ROUND_UP(bytes, max_io_size);
atoms = ocf_mpool_new(atomic_io_allocator,
atoms = cas_mpool_new(atomic_io_allocator,
ios_count);
if (!atoms)
return NULL;
@@ -808,7 +809,7 @@ void cas_atomic_submit_discard(struct ocf_io *io)
}
/* Allocate and setup control structure. */
atom = ocf_mpool_new(atomic_io_allocator, 1);
atom = cas_mpool_new(atomic_io_allocator, 1);
if (!atom) {
CAS_PRINT_RL(KERN_ERR "Couldn't allocate memory for IO ctrl\n");
io->end(io, -ENOMEM);
@@ -880,7 +881,7 @@ void cas_atomic_submit_flush(struct ocf_io *io)
}
/* Allocate and setup control structure. */
atom = ocf_mpool_new(atomic_io_allocator, 1);
atom = cas_mpool_new(atomic_io_allocator, 1);
if (!atom) {
CAS_PRINT_RL(KERN_ERR "Couldn't allocate memory for IO ctrl\n");
io->end(io, -ENOMEM);
@@ -1160,8 +1161,8 @@ int atomic_dev_init(void)
if (ret < 0)
return -EINVAL;
atomic_io_allocator = ocf_mpool_create(NULL, 0,
sizeof(struct cas_atomic_io), GFP_NOIO, 1, "cas_atomic_io");
atomic_io_allocator = cas_mpool_create(0, sizeof(struct cas_atomic_io),
GFP_NOIO, 1, "cas_atomic_io");
if (!atomic_io_allocator) {
ocf_ctx_unregister_volume_type(cas_ctx, ATOMIC_DEVICE_VOLUME);
@@ -1174,7 +1175,7 @@ int atomic_dev_init(void)
void atomic_dev_deinit(void)
{
if (atomic_io_allocator) {
ocf_mpool_destroy(atomic_io_allocator);
cas_mpool_destroy(atomic_io_allocator);
atomic_io_allocator = NULL;
}