Commit 217332a9 authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Ben Walker
Browse files

lib/ftl: Add flag to prepare for major upgrade



FTL publishes a new property - prep_upgrade_on_shutdown. When this flag is on,
during shutdown, FTL executes all actions which are needed for upgrade
to a new version.

Change-Id: I95e05eb22420e069e16b9dee24ed4f4cfa472471
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/+/19010


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 804f67cf
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -112,8 +112,14 @@ struct spdk_ftl_conf {
		uint32_t			chunk_free_target;
	} nv_cache;

	/* Hole at bytes 0x60 - 0x67. */
	uint8_t					reserved[4];
	/*
	 * This flags indicates that FTL during shutdown should execute all
	 * actions which are needed for upgrade to a new version
	 */
	bool					prep_upgrade_on_shutdown;

	/* Hole at bytes 0x65 - 0x67. */
	uint8_t					reserved[3];

	/* Name of base block device (zoned or non-zoned) */
	char					*base_bdev;
+2 −2
Original line number Diff line number Diff line
@@ -6,8 +6,8 @@
SPDK_ROOT_DIR := $(abspath $(CURDIR)/../..)
include $(SPDK_ROOT_DIR)/mk/spdk.common.mk

SO_VER := 7
SO_MINOR := 1
SO_VER := 8
SO_MINOR := 0

ifdef SPDK_FTL_RETRY_ON_ERROR
CFLAGS += -DSPDK_FTL_RETRY_ON_ERROR
+19 −1
Original line number Diff line number Diff line
@@ -535,11 +535,25 @@ chunk_compaction_advance(struct ftl_nv_cache_chunk *chunk, uint64_t num_blocks)
	ftl_chunk_free(chunk);
}

static bool
is_compaction_required_for_upgrade(struct ftl_nv_cache *nv_cache)
{
	struct spdk_ftl_dev *dev = SPDK_CONTAINEROF(nv_cache, struct spdk_ftl_dev, nv_cache);

	if (dev->conf.prep_upgrade_on_shutdown) {
		if (nv_cache->chunk_full_count || nv_cache->chunk_open_count) {
			return true;
		}
	}

	return false;
}

static bool
is_compaction_required(struct ftl_nv_cache *nv_cache)
{
	if (spdk_unlikely(nv_cache->halt)) {
		return false;
		return is_compaction_required_for_upgrade(nv_cache);
	}

	if (nv_cache->chunk_full_count >= nv_cache->chunk_compaction_threshold) {
@@ -1168,6 +1182,10 @@ ftl_nv_cache_is_halted(struct ftl_nv_cache *nv_cache)
		return false;
	}

	if (is_compaction_required_for_upgrade(nv_cache)) {
		return false;
	}

	return true;
}

+6 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@

#include "ftl_conf.h"
#include "ftl_core.h"
#include "ftl_utils.h"

static const struct spdk_ftl_conf g_default_conf = {
	/* 2 free bands - compaction is blocked, gc only */
@@ -140,6 +141,11 @@ ftl_conf_init_dev(struct spdk_ftl_dev *dev, const struct spdk_ftl_conf *conf)
	}

	dev->limit = SPDK_FTL_LIMIT_MAX;

	ftl_property_register_bool_rw(dev, "prep_upgrade_on_shutdown", &dev->conf.prep_upgrade_on_shutdown,
				      "", "During shutdown, FTL executes all actions which "
				      "are needed for upgrade to a new version");

	return 0;
}

+17 −0
Original line number Diff line number Diff line
@@ -140,4 +140,21 @@ void ftl_property_set_generic(struct spdk_ftl_dev *dev, struct ftl_mngt_process
			      const struct ftl_property *property,
			      void *new_value, size_t new_value_size);

/**
 * @brief The wrapper function to register mutable boolean property
 *
 * @param dev FTL device
 * @param name The property name
 * @param value The pointer to the boolean value of the property
 * @param unit The property unit
 * @param desc The property description
 */
static inline void
ftl_property_register_bool_rw(struct spdk_ftl_dev *dev, const char *name, bool *value,
			      const char *unit, const char *desc)
{
	ftl_property_register(dev, name, value, sizeof(*value), unit, desc, ftl_property_dump_bool,
			      ftl_property_decode_bool, ftl_property_set_generic);
}

#endif
Loading