From bfd67f9405d241516d86a3b2e8092cf0ef8f7372 Mon Sep 17 00:00:00 2001 From: Wojciech Malikowski Date: Wed, 12 Jun 2019 07:03:55 -0400 Subject: [PATCH] lib/ftl: Initialize band tail metadata physical address Band tail PPA should be initialized when new FTL instance is created. Change-Id: Ie2fb72aa3f29eece0b6f8912998b33af3ba6b355 Signed-off-by: Wojciech Malikowski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457777 Reviewed-by: Konrad Sztyber Reviewed-by: Darek Stojaczyk Reviewed-by: Shuhei Matsumoto Tested-by: SPDK CI Jenkins --- lib/ftl/ftl_band.c | 7 ++++--- lib/ftl/ftl_core.c | 1 - lib/ftl/ftl_init.c | 5 +++++ lib/ftl/ftl_restore.c | 1 - 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/ftl/ftl_band.c b/lib/ftl/ftl_band.c index 3369dfd9e..9d39d1752 100644 --- a/lib/ftl/ftl_band.c +++ b/lib/ftl/ftl_band.c @@ -138,7 +138,6 @@ ftl_band_write_failed(struct ftl_band *band) struct spdk_ftl_dev *dev = band->dev; band->high_prio = 1; - band->tail_md_ppa = ftl_to_ppa(FTL_PPA_INVALID); if (!dev->df_band) { dev->df_band = band; @@ -1085,14 +1084,16 @@ static void ftl_erase_fail(struct ftl_io *io, int status) { struct ftl_chunk *chunk; + struct ftl_band *band = io->band; char buf[128]; SPDK_ERRLOG("Erase failed @ppa: %s, status: %d\n", ftl_ppa2str(io->ppa, buf, sizeof(buf)), status); - chunk = ftl_band_chunk_from_ppa(io->band, io->ppa); + chunk = ftl_band_chunk_from_ppa(band, io->ppa); chunk->state = FTL_CHUNK_STATE_BAD; - ftl_band_remove_chunk(io->band, chunk); + ftl_band_remove_chunk(band, chunk); + band->tail_md_ppa = ftl_band_tail_md_ppa(band); } static void diff --git a/lib/ftl/ftl_core.c b/lib/ftl/ftl_core.c index 2b143ff84..b20b750b7 100644 --- a/lib/ftl/ftl_core.c +++ b/lib/ftl/ftl_core.c @@ -266,7 +266,6 @@ ftl_wptr_close_band(struct ftl_wptr *wptr) struct ftl_band *band = wptr->band; ftl_band_set_state(band, FTL_BAND_STATE_CLOSING); - band->tail_md_ppa = wptr->ppa; return ftl_band_write_tail_md(band, ftl_md_write_cb); } diff --git a/lib/ftl/ftl_init.c b/lib/ftl/ftl_init.c index 2ea4d5b2d..c974244f1 100644 --- a/lib/ftl/ftl_init.c +++ b/lib/ftl/ftl_init.c @@ -377,6 +377,11 @@ ftl_dev_init_bands(struct spdk_ftl_dev *dev) } } + for (i = 0; i < ftl_dev_num_bands(dev); ++i) { + band = &dev->bands[i]; + band->tail_md_ppa = ftl_band_tail_md_ppa(band); + } + ftl_remove_empty_bands(dev); out: free(info); diff --git a/lib/ftl/ftl_restore.c b/lib/ftl/ftl_restore.c index a5f241ebf..3c40e0222 100644 --- a/lib/ftl/ftl_restore.c +++ b/lib/ftl/ftl_restore.c @@ -623,7 +623,6 @@ ftl_restore_tail_md(struct ftl_restore_band *rband) struct ftl_restore *restore = rband->parent; struct ftl_band *band = rband->band; - band->tail_md_ppa = ftl_band_tail_md_ppa(band); band->lba_map.map = restore->lba_map; band->lba_map.dma_buf = restore->md_buf;