diff --git a/lib/ftl/ftl_reloc.c b/lib/ftl/ftl_reloc.c index 4383978f8..3ebd8cc34 100644 --- a/lib/ftl/ftl_reloc.c +++ b/lib/ftl/ftl_reloc.c @@ -204,8 +204,12 @@ ftl_reloc_prep(struct ftl_band_reloc *breloc) reloc->num_active++; if (!band->high_prio) { - if (ftl_band_alloc_lba_map(band)) { - assert(false); + if (band->lba_map.ref_cnt == 0) { + if (ftl_band_alloc_lba_map(band)) { + assert(false); + } + } else { + ftl_band_acquire_lba_map(band); } } @@ -551,7 +555,7 @@ ftl_reloc_release(struct ftl_band_reloc *breloc) return; } - if (ftl_band_empty(band)) { + if (ftl_band_empty(band) && band->state == FTL_BAND_STATE_CLOSED) { ftl_band_set_state(breloc->band, FTL_BAND_STATE_FREE); } } @@ -749,6 +753,7 @@ ftl_reloc(struct ftl_reloc *reloc) if (reloc->num_active == reloc->max_active) { break; } + ftl_reloc_add_active_queue(breloc); } diff --git a/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c b/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c index d969ac453..39372d968 100644 --- a/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c +++ b/test/unit/lib/ftl/ftl_reloc.c/ftl_reloc_ut.c @@ -415,6 +415,9 @@ test_reloc_chunk(void) breloc = &reloc->brelocs[0]; band = breloc->band; + /* High priority band have allocated lba map */ + band->high_prio = 1; + ftl_band_alloc_lba_map(band); num_io = MAX_RELOC_QDEPTH * reloc->xfer_size; num_iters = ftl_dev_lbks_in_chunk(dev) / num_io;