diff --git a/include/spdk/ftl.h b/include/spdk/ftl.h index 67b89660e..3ae8c3bff 100644 --- a/include/spdk/ftl.h +++ b/include/spdk/ftl.h @@ -17,6 +17,34 @@ extern "C" { struct spdk_ftl_dev; +struct spdk_ftl_conf { + /* Percentage of base device blocks not exposed to the user */ + uint64_t overprovisioning; + + /* Core mask - core thread plus additional relocation threads */ + char *core_mask; + + /* IO pool size per user thread */ + size_t user_io_pool_size; + + /* FTL startup mode mask, see spdk_ftl_mode enum for possible values */ + uint32_t mode; + + /* Name of base block device (zoned or non-zoned) */ + char *base_bdev; + + /* Name of cache block device (must support extended metadata) */ + char *cache_bdev; + + /* Base bdev reclaim unit size */ + uint64_t base_bdev_reclaim_unit_size; +}; + +enum spdk_ftl_mode { + /* Create new device */ + SPDK_FTL_MODE_CREATE = (1 << 0), +}; + #ifdef __cplusplus } #endif diff --git a/lib/ftl/Makefile b/lib/ftl/Makefile index d565abf94..aeb376ad2 100644 --- a/lib/ftl/Makefile +++ b/lib/ftl/Makefile @@ -15,6 +15,7 @@ FTL_SUBDIRS := mngt utils C_SRCS = ftl_core.c C_SRCS += mngt/ftl_mngt.c +C_SRCS += utils/ftl_conf.c SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_ftl.map) diff --git a/lib/ftl/ftl_utils.h b/lib/ftl/ftl_utils.h index 24cb94bca..d7fe42299 100644 --- a/lib/ftl/ftl_utils.h +++ b/lib/ftl/ftl_utils.h @@ -7,5 +7,6 @@ #define FTL_FTL_UTILS_H #include "utils/ftl_defs.h" +#include "utils/ftl_conf.h" #endif /* FTL_FTL_UTILS_H */ diff --git a/lib/ftl/utils/ftl_conf.c b/lib/ftl/utils/ftl_conf.c new file mode 100644 index 000000000..0d7c552d7 --- /dev/null +++ b/lib/ftl/utils/ftl_conf.c @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) Intel Corporation. + * All rights reserved. + */ +#include "spdk/ftl.h" + +#include "ftl_conf.h" +#include "ftl_core.h" + +int +ftl_conf_cpy(struct spdk_ftl_conf *dst, const struct spdk_ftl_conf *src) +{ + char *core_mask = NULL; + char *l2p_path = NULL; + char *base_bdev = NULL; + char *cache_bdev = NULL; + + if (src->core_mask) { + core_mask = strdup(src->core_mask); + if (!core_mask) { + goto error; + } + } + if (src->base_bdev) { + base_bdev = strdup(src->base_bdev); + if (!base_bdev) { + goto error; + } + } + if (src->cache_bdev) { + cache_bdev = strdup(src->cache_bdev); + if (!cache_bdev) { + goto error; + } + } + + free(dst->core_mask); + free(dst->base_bdev); + free(dst->cache_bdev); + + *dst = *src; + dst->core_mask = core_mask; + dst->base_bdev = base_bdev; + dst->cache_bdev = cache_bdev; + return 0; +error: + free(core_mask); + free(l2p_path); + free(base_bdev); + free(cache_bdev); + return -ENOMEM; +} + +void +ftl_conf_deinit(struct spdk_ftl_conf *conf) +{ + free(conf->core_mask); + free(conf->base_bdev); + free(conf->cache_bdev); +} diff --git a/lib/ftl/utils/ftl_conf.h b/lib/ftl/utils/ftl_conf.h new file mode 100644 index 000000000..a14e3d1fe --- /dev/null +++ b/lib/ftl/utils/ftl_conf.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) Intel Corporation. + * All rights reserved. + */ + +#ifndef FTL_CONF_H +#define FTL_CONF_H + +#include "spdk/ftl.h" + +int ftl_conf_cpy(struct spdk_ftl_conf *dst, const struct spdk_ftl_conf *src); + +void ftl_conf_deinit(struct spdk_ftl_conf *conf); + +#endif /* FTL_DEFS_H */