From f8a911229292521d60a496deae16d00a8fbab766 Mon Sep 17 00:00:00 2001 From: Wojciech Malikowski Date: Wed, 12 Jun 2019 13:24:24 -0400 Subject: [PATCH] lib/ftl: Mark all lba map segments as cached for open bands Open bands need to have lba map segments set to cached state to prevent read lba map from disk during relocation events. Change-Id: Ib4f1ed19131fad174c1d2f70e4c02e83701e2a0a Signed-off-by: Wojciech Malikowski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457853 Reviewed-by: Konrad Sztyber Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- lib/ftl/ftl_band.c | 28 +++++++++++++++++----------- test/unit/lib/ftl/ftl_md/ftl_md_ut.c | 1 + 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/ftl/ftl_band.c b/lib/ftl/ftl_band.c index 9d39d17529..7751667664 100644 --- a/lib/ftl/ftl_band.c +++ b/lib/ftl/ftl_band.c @@ -147,17 +147,6 @@ ftl_band_write_failed(struct ftl_band *band) ftl_band_set_state(band, FTL_BAND_STATE_CLOSED); } -void -ftl_band_clear_lba_map(struct ftl_band *band) -{ - struct ftl_lba_map *lba_map = &band->lba_map; - - spdk_bit_array_clear_mask(lba_map->vld); - memset(lba_map->map, 0, ftl_lba_map_pool_elem_size(band->dev)); - - lba_map->num_vld = 0; -} - static void ftl_band_free_lba_map(struct ftl_band *band) { @@ -1187,6 +1176,23 @@ ftl_band_next_operational_chunk(struct ftl_band *band, struct ftl_chunk *chunk) return result; } +void +ftl_band_clear_lba_map(struct ftl_band *band) +{ + struct ftl_lba_map *lba_map = &band->lba_map; + size_t num_segments; + + spdk_bit_array_clear_mask(lba_map->vld); + memset(lba_map->map, 0, ftl_lba_map_pool_elem_size(band->dev)); + + /* For open band all lba map segments are already cached */ + assert(band->state == FTL_BAND_STATE_PREP); + num_segments = spdk_divide_round_up(ftl_num_band_lbks(band->dev), FTL_NUM_LBA_IN_BLOCK); + ftl_lba_map_set_segment_state(&band->lba_map, 0, num_segments, FTL_LBA_MAP_SEG_CACHED); + + lba_map->num_vld = 0; +} + size_t ftl_lba_map_pool_elem_size(struct spdk_ftl_dev *dev) { diff --git a/test/unit/lib/ftl/ftl_md/ftl_md_ut.c b/test/unit/lib/ftl/ftl_md/ftl_md_ut.c index 53438cf5f9..7b64302a25 100644 --- a/test/unit/lib/ftl/ftl_md/ftl_md_ut.c +++ b/test/unit/lib/ftl/ftl_md/ftl_md_ut.c @@ -64,6 +64,7 @@ setup_band(struct ftl_band **band, const struct spdk_ocssd_geometry_data *geo, *band = test_init_ftl_band(dev, 0); rc = ftl_band_alloc_lba_map(*band); SPDK_CU_ASSERT_FATAL(rc == 0); + (*band)->state = FTL_BAND_STATE_PREP; ftl_band_clear_lba_map(*band); }