ftl: configuration structure and utils
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com> Change-Id: I5364e09e0e501443ac6e99df5d814cc5fac397e8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13290 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
293cdc484b
commit
310836b9af
@ -17,6 +17,34 @@ extern "C" {
|
|||||||
|
|
||||||
struct spdk_ftl_dev;
|
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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,6 +15,7 @@ FTL_SUBDIRS := mngt utils
|
|||||||
|
|
||||||
C_SRCS = ftl_core.c
|
C_SRCS = ftl_core.c
|
||||||
C_SRCS += mngt/ftl_mngt.c
|
C_SRCS += mngt/ftl_mngt.c
|
||||||
|
C_SRCS += utils/ftl_conf.c
|
||||||
|
|
||||||
SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_ftl.map)
|
SPDK_MAP_FILE = $(abspath $(CURDIR)/spdk_ftl.map)
|
||||||
|
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
#define FTL_FTL_UTILS_H
|
#define FTL_FTL_UTILS_H
|
||||||
|
|
||||||
#include "utils/ftl_defs.h"
|
#include "utils/ftl_defs.h"
|
||||||
|
#include "utils/ftl_conf.h"
|
||||||
|
|
||||||
#endif /* FTL_FTL_UTILS_H */
|
#endif /* FTL_FTL_UTILS_H */
|
||||||
|
60
lib/ftl/utils/ftl_conf.c
Normal file
60
lib/ftl/utils/ftl_conf.c
Normal file
@ -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);
|
||||||
|
}
|
15
lib/ftl/utils/ftl_conf.h
Normal file
15
lib/ftl/utils/ftl_conf.h
Normal file
@ -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 */
|
Loading…
Reference in New Issue
Block a user