ftl: metadata for unmap support
Setup trim metadata layout. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com> Change-Id: I9395119cb8d5f7a5de4fde7b3f9506eb06452d7b Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13377 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
ea80f87e0e
commit
78c3cbf4c9
@ -128,7 +128,7 @@ static int
|
||||
setup_layout_nvc(struct spdk_ftl_dev *dev)
|
||||
{
|
||||
int region_type;
|
||||
uint64_t left, offset = 0;
|
||||
uint64_t left, offset = 0, l2p_blocks;
|
||||
struct ftl_layout *layout = &dev->layout;
|
||||
struct ftl_layout_region *region, *mirror;
|
||||
static const char *p2l_region_name[] = {
|
||||
@ -222,6 +222,38 @@ setup_layout_nvc(struct spdk_ftl_dev *dev)
|
||||
offset += region->current.blocks;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize trim metadata region
|
||||
*/
|
||||
if (offset >= layout->nvc.total_blocks) {
|
||||
goto error;
|
||||
}
|
||||
l2p_blocks = layout->region[FTL_LAYOUT_REGION_TYPE_L2P].current.blocks;
|
||||
region = &layout->region[FTL_LAYOUT_REGION_TYPE_TRIM_MD];
|
||||
region->type = FTL_LAYOUT_REGION_TYPE_TRIM_MD;
|
||||
region->mirror_type = FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR;
|
||||
region->name = "trim_md";
|
||||
region->current.version = 0;
|
||||
region->prev.version = 0;
|
||||
region->current.offset = offset;
|
||||
region->current.blocks = blocks_region(l2p_blocks * sizeof(uint64_t));
|
||||
region->entry_size = 1;
|
||||
region->num_entries = region->current.blocks;
|
||||
set_region_bdev_nvc(region, dev);
|
||||
offset += region->current.blocks;
|
||||
|
||||
/* Initialize trim metadata mirror region */
|
||||
if (offset >= layout->nvc.total_blocks) {
|
||||
goto error;
|
||||
}
|
||||
mirror = &layout->region[FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR];
|
||||
*mirror = *region;
|
||||
mirror->type = FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR;
|
||||
mirror->mirror_type = FTL_LAYOUT_REGION_TYPE_INVALID;
|
||||
mirror->name = "trim_md_mirror";
|
||||
mirror->current.offset += region->current.blocks;
|
||||
offset += mirror->current.blocks;
|
||||
|
||||
/*
|
||||
* Initialize NV Cache metadata
|
||||
*/
|
||||
|
@ -57,6 +57,11 @@ enum ftl_layout_region_type {
|
||||
FTL_LAYOUT_REGION_TYPE_P2L_CKPT_COMP_NEXT,
|
||||
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,
|
||||
/* Mirrored information about trim */
|
||||
FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR,
|
||||
|
||||
FTL_LAYOUT_REGION_TYPE_MAX,
|
||||
};
|
||||
|
||||
|
@ -40,6 +40,7 @@ is_buffer_needed(enum ftl_layout_region_type type)
|
||||
#ifndef SPDK_FTL_L2P_FLAT
|
||||
case FTL_LAYOUT_REGION_TYPE_L2P:
|
||||
#endif
|
||||
case FTL_LAYOUT_REGION_TYPE_TRIM_MD_MIRROR:
|
||||
return false;
|
||||
|
||||
default:
|
||||
|
@ -1126,6 +1126,7 @@ ftl_md_create_region_flags(struct spdk_ftl_dev *dev, int region_type)
|
||||
}
|
||||
break;
|
||||
case FTL_LAYOUT_REGION_TYPE_VALID_MAP:
|
||||
case FTL_LAYOUT_REGION_TYPE_TRIM_MD:
|
||||
if (!ftl_fast_startup(dev) && !ftl_fast_recovery(dev)) {
|
||||
flags |= FTL_MD_CREATE_SHM_NEW;
|
||||
}
|
||||
@ -1145,6 +1146,7 @@ ftl_md_destroy_region_flags(struct spdk_ftl_dev *dev, int region_type)
|
||||
case FTL_LAYOUT_REGION_TYPE_BAND_MD:
|
||||
case FTL_LAYOUT_REGION_TYPE_VALID_MAP:
|
||||
case FTL_LAYOUT_REGION_TYPE_NVC_MD:
|
||||
case FTL_LAYOUT_REGION_TYPE_TRIM_MD:
|
||||
if (dev->conf.fast_shutdown) {
|
||||
return FTL_MD_DESTROY_SHM_KEEP;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user