From b8919745c54d4854ed1f1b0085fcaf858b2860e1 Mon Sep 17 00:00:00 2001 From: Mateusz Kozlowski Date: Fri, 26 Jul 2019 10:57:38 +0200 Subject: [PATCH] lib/ftl: ANM during write error handling If an ANM event has come to a chunk/sector that has been marked as high_prio (eg. after a write failure), there's no need to add any sectors for relocation, as the whole band should be marked for a move anyway. Signed-off-by: Mateusz Kozlowski Change-Id: I57824ba7e592540ea639f9f011149210fd688a5a Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463289 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Tomasz Zawadzki Reviewed-by: Wojciech Malikowski Reviewed-by: Darek Stojaczyk Reviewed-by: Ben Walker --- lib/ftl/ftl_band.c | 2 +- lib/ftl/ftl_core.c | 4 +++- lib/ftl/ftl_reloc.c | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/ftl/ftl_band.c b/lib/ftl/ftl_band.c index 50bca8ce2..6e649f6fc 100644 --- a/lib/ftl/ftl_band.c +++ b/lib/ftl/ftl_band.c @@ -451,7 +451,7 @@ ftl_band_set_state(struct ftl_band *band, enum ftl_band_state state) case FTL_BAND_STATE_CLOSED: if (band->state != FTL_BAND_STATE_CLOSED) { - assert(band->state == FTL_BAND_STATE_CLOSING); + assert(band->state == FTL_BAND_STATE_CLOSING || band->high_prio); _ftl_band_set_closed(band); } break; diff --git a/lib/ftl/ftl_core.c b/lib/ftl/ftl_core.c index ce2f54722..9e801f442 100644 --- a/lib/ftl/ftl_core.c +++ b/lib/ftl/ftl_core.c @@ -211,7 +211,6 @@ ftl_wptr_from_band(struct ftl_band *band) } } - assert(false); return NULL; } @@ -223,6 +222,7 @@ ftl_md_write_fail(struct ftl_io *io, int status) char buf[128]; wptr = ftl_wptr_from_band(band); + assert(wptr); SPDK_ERRLOG("Metadata write failed @ppa: %s, status: %d\n", ftl_ppa2str(wptr->ppa, buf, sizeof(buf)), status); @@ -240,6 +240,7 @@ ftl_md_write_cb(struct ftl_io *io, void *arg, int status) size_t id; wptr = ftl_wptr_from_band(band); + assert(wptr); if (status) { ftl_md_write_fail(io, status); @@ -498,6 +499,7 @@ ftl_close_direct_wptr(struct ftl_band *band) { struct ftl_wptr *wptr = ftl_wptr_from_band(band); + assert(wptr); assert(wptr->direct_mode); assert(band->state == FTL_BAND_STATE_CLOSED); diff --git a/lib/ftl/ftl_reloc.c b/lib/ftl/ftl_reloc.c index 4108bb481..3dcf5a2e0 100644 --- a/lib/ftl/ftl_reloc.c +++ b/lib/ftl/ftl_reloc.c @@ -780,6 +780,11 @@ ftl_reloc_add(struct ftl_reloc *reloc, struct ftl_band *band, size_t offset, struct ftl_band_reloc *breloc = &reloc->brelocs[band->id]; size_t i, prev_lbks = breloc->num_lbks; + /* No need to add anything if already at high prio - whole band should be relocated */ + if (!prio && band->high_prio) { + return; + } + pthread_spin_lock(&band->lba_map.lock); if (band->lba_map.num_vld == 0) { pthread_spin_unlock(&band->lba_map.lock);