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

ftl: Add explicit values to the ftl_layout_region_type



This should prevent accidental reordering/removal of regions from
causing problems after loading against such changed metadata.

Signed-off-by: default avatarKozlowski Mateusz <mateusz.kozlowski@intel.com>
Change-Id: I75c62810157db4bb0de4dfc84f5656fd187befde
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13614


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 7f5a982f
Loading
Loading
Loading
Loading
+25 −26
Original line number Diff line number Diff line
@@ -15,54 +15,53 @@ struct ftl_md;
	(FTL_LAYOUT_REGION_TYPE_P2L_CKPT_MAX - FTL_LAYOUT_REGION_TYPE_P2L_CKPT_MIN + 1)

enum ftl_layout_region_type {
#ifdef SPDK_FTL_VSS_EMU
	/** VSS region for NV cache VSS emulation */
	FTL_LAYOUT_REGION_TYPE_VSS,
#endif
	/* Superblock describing the basic FTL information */
	FTL_LAYOUT_REGION_TYPE_SB,
	FTL_LAYOUT_REGION_TYPE_SB = 0,
	/* Mirrored instance of the superblock on the base device */
	FTL_LAYOUT_REGION_TYPE_SB_BASE,
	FTL_LAYOUT_REGION_TYPE_SB_BASE = 1,
	/* If using cached L2P, this region stores the serialized instance of it */
	FTL_LAYOUT_REGION_TYPE_L2P,
	FTL_LAYOUT_REGION_TYPE_L2P = 2,

	/* State of bands */
	FTL_LAYOUT_REGION_TYPE_BAND_MD,
	FTL_LAYOUT_REGION_TYPE_BAND_MD = 3,
	/* Mirrored instance of bands state */
	FTL_LAYOUT_REGION_TYPE_BAND_MD_MIRROR,
	FTL_LAYOUT_REGION_TYPE_BAND_MD_MIRROR = 4,

	/* Map of valid physical addresses, used for more efficient garbage collection */
	FTL_LAYOUT_REGION_TYPE_VALID_MAP,
	FTL_LAYOUT_REGION_TYPE_VALID_MAP = 5,

	/* State of chunks */
	FTL_LAYOUT_REGION_TYPE_NVC_MD,
	FTL_LAYOUT_REGION_TYPE_NVC_MD = 6,
	/* Mirrored instance of the state of chunks */
	FTL_LAYOUT_REGION_TYPE_NVC_MD_MIRROR,
	FTL_LAYOUT_REGION_TYPE_NVC_MD_MIRROR = 7,

	/* User data region on the nv cache device */
	FTL_LAYOUT_REGION_TYPE_DATA_NVC,
	FTL_LAYOUT_REGION_TYPE_DATA_NVC = 8,

	/* User data region on the base device */
	FTL_LAYOUT_REGION_TYPE_DATA_BASE,
	FTL_LAYOUT_REGION_TYPE_DATA_BASE = 9,

	/* P2L checkpointing allows for emulation of VSS on base device.
	 * 4 entries are needed - 2 for each writer
	 * Although the naming may suggest a particular region is assigned to its corresponding writer, it's not
	 * the case - they can be used interchangeably
	 */
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_GC,
	 * 4 entries are needed - 2 for each writer */
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_GC = 10,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_MIN = FTL_LAYOUT_REGION_TYPE_P2L_CKPT_GC,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_GC_NEXT,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_COMP,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_COMP_NEXT,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_GC_NEXT = 11,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_COMP = 12,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_COMP_NEXT = 13,
	FTL_LAYOUT_REGION_TYPE_P2L_CKPT_MAX = FTL_LAYOUT_REGION_TYPE_P2L_CKPT_COMP_NEXT,

	/* Information about trimmed space in FTL */
	FTL_LAYOUT_REGION_TYPE_TRIM_MD,
	FTL_LAYOUT_REGION_TYPE_TRIM_MD = 14,
	/* Mirrored information about trim */
	FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR,

	FTL_LAYOUT_REGION_TYPE_MAX,
	FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR = 15,

#ifndef SPDK_FTL_VSS_EMU
	FTL_LAYOUT_REGION_TYPE_MAX = 16
#else
	/* VSS region for NV cache VSS emulation */
	FTL_LAYOUT_REGION_TYPE_VSS = 16,
	FTL_LAYOUT_REGION_TYPE_MAX = 17,
#endif
};

/* last nvc/base region in terms of lba address space */
+1 −1
Original line number Diff line number Diff line
@@ -534,7 +534,7 @@ ftl_mngt_md_init_vss_emu(struct spdk_ftl_dev *dev, struct ftl_mngt_process *mngt

	/* Allocate md buf */
	layout->md[FTL_LAYOUT_REGION_TYPE_VSS] = ftl_md_create(dev, region->current.blocks,
			region->vss_blksz, NULL, 0, region);
			region->vss_blksz, NULL, FTL_MD_CREATE_HEAP, region);
	if (NULL == layout->md[FTL_LAYOUT_REGION_TYPE_VSS]) {
		ftl_mngt_fail_step(mngt);
		return;
+3 −3
Original line number Diff line number Diff line
@@ -33,9 +33,6 @@ extern struct ftl_region_upgrade_desc nvc_upgrade_desc[];
extern struct ftl_region_upgrade_desc band_upgrade_desc[];

static struct ftl_layout_upgrade_desc_list layout_upgrade_desc[] = {
#ifdef SPDK_FTL_VSS_EMU
	[FTL_LAYOUT_REGION_TYPE_VSS] = {},
#endif
	[FTL_LAYOUT_REGION_TYPE_SB] = {
		.count = FTL_SB_VERSION_CURRENT,
		.desc = sb_upgrade_desc,
@@ -82,6 +79,9 @@ static struct ftl_layout_upgrade_desc_list layout_upgrade_desc[] = {
	},
	[FTL_LAYOUT_REGION_TYPE_TRIM_MD] = {},
	[FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR] = {},
#ifdef SPDK_FTL_VSS_EMU
	[FTL_LAYOUT_REGION_TYPE_VSS] = {},
#endif
};

SPDK_STATIC_ASSERT(sizeof(layout_upgrade_desc) / sizeof(*layout_upgrade_desc) ==