Commit fa378811 authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Jim Harris
Browse files

lib/ftl: Introducing FTL properties mechanism



It provides a method to register a FTL property (a setting)
that can be accessed by the user. The intention is to
get and set the property using a FTL RPC call.

Change-Id: I2209c057c531627c5735b9ef8dd18fb3d9d96873
Signed-off-by: default avatarMariusz Barczak <Mariusz.Barczak@solidigmtechnology.com>
Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/19005


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
parent c26733cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ C_SRCS += mngt/ftl_mngt.c mngt/ftl_mngt_bdev.c mngt/ftl_mngt_shutdown.c mngt/ftl
C_SRCS += mngt/ftl_mngt_md.c mngt/ftl_mngt_misc.c mngt/ftl_mngt_ioch.c mngt/ftl_mngt_l2p.c
C_SRCS += mngt/ftl_mngt_band.c mngt/ftl_mngt_self_test.c mngt/ftl_mngt_p2l.c
C_SRCS += mngt/ftl_mngt_recovery.c mngt/ftl_mngt_upgrade.c
C_SRCS += utils/ftl_conf.c utils/ftl_md.c utils/ftl_mempool.c utils/ftl_bitmap.c
C_SRCS += utils/ftl_conf.c utils/ftl_md.c utils/ftl_mempool.c utils/ftl_bitmap.c utils/ftl_property.c
C_SRCS += upgrade/ftl_layout_upgrade.c upgrade/ftl_sb_upgrade.c upgrade/ftl_p2l_upgrade.c
C_SRCS += upgrade/ftl_band_upgrade.c upgrade/ftl_chunk_upgrade.c
C_SRCS += nvc/ftl_nvc_dev.c nvc/ftl_nvc_bdev_vss.c
+4 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include "ftl_l2p.h"
#include "utils/ftl_bitmap.h"
#include "utils/ftl_log.h"
#include "utils/ftl_property.h"

/*
 * We need to reserve at least 2 buffers for band close / open sequence
@@ -185,6 +186,9 @@ struct spdk_ftl_dev {
		/* In use regions */
		TAILQ_HEAD(, ftl_p2l_ckpt)	inuse;
	} p2l_ckpt;

	/* FTL properties which can be configured by user */
	struct ftl_properties			*properties;
};

void ftl_apply_limits(struct spdk_ftl_dev *dev);
+7 −0
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@ free_dev(struct spdk_ftl_dev *dev)

	deinit_core_thread(dev);
	spdk_ftl_conf_deinit(&dev->conf);
	ftl_properties_deinit(dev);
	free(dev);
}

@@ -103,6 +104,12 @@ allocate_dev(const struct spdk_ftl_conf *conf, int *error)
		return NULL;
	}

	rc = ftl_properties_init(dev);
	if (rc) {
		*error = rc;
		goto error;
	}

	rc = ftl_conf_init_dev(dev, conf);
	if (rc) {
		*error = rc;
+1 −0
Original line number Diff line number Diff line
@@ -10,5 +10,6 @@
#include "utils/ftl_mempool.h"
#include "utils/ftl_conf.h"
#include "utils/ftl_md.h"
#include "utils/ftl_property.h"

#endif /* FTL_FTL_UTILS_H */
+89 −0
Original line number Diff line number Diff line
/*   SPDX-License-Identifier: BSD-3-Clause
 *   Copyright 2023 Solidigm All Rights Reserved
 */

#include "spdk/queue.h"

#include "ftl_core.h"
#include "ftl_property.h"

struct ftl_properties {
	LIST_HEAD(, ftl_property) list;
};

/**
 * @brief FTL property descriptor
 */
struct ftl_property {
	/** Name of the property */
	const char *name;

	/** Link to put the property to the list */
	LIST_ENTRY(ftl_property) entry;
};

static struct ftl_property *
get_property_item(struct ftl_properties *properties, const char *name)
{
	struct ftl_property *entry;

	LIST_FOREACH(entry, &properties->list, entry) {
		/* TODO think about strncmp */
		if (0 == strcmp(entry->name, name)) {
			return entry;
		}
	}

	return NULL;
}

void
ftl_property_register(struct spdk_ftl_dev *dev, const char *name)
{
	struct ftl_properties *properties = dev->properties;

	if (get_property_item(properties, name)) {
		FTL_ERRLOG(dev, "FTL property registration ERROR, already exist, name %s\n", name);
		ftl_abort();
	} else {
		struct ftl_property *prop = calloc(1, sizeof(*prop));
		if (NULL == prop) {
			FTL_ERRLOG(dev, "FTL property registration ERROR, out of memory, name %s\n", name);
			ftl_abort();
		}

		prop->name = name;
		LIST_INSERT_HEAD(&properties->list, prop, entry);
	}
}

int
ftl_properties_init(struct spdk_ftl_dev *dev)
{
	dev->properties = calloc(1, sizeof(*dev->properties));
	if (!dev->properties) {
		return -ENOMEM;
	}

	LIST_INIT(&dev->properties->list);
	return 0;
}

void
ftl_properties_deinit(struct spdk_ftl_dev *dev)
{
	struct ftl_properties *properties = dev->properties;
	struct ftl_property *prop;

	if (!properties) {
		return;
	}

	while (!LIST_EMPTY(&properties->list)) {
		prop = LIST_FIRST(&properties->list);
		LIST_REMOVE(prop, entry);
		free(prop);
	}

	free(dev->properties);
}
Loading