From f882a577d4088457f98cfc10f9746805f65a3844 Mon Sep 17 00:00:00 2001 From: Wojciech Malikowski Date: Mon, 18 Feb 2019 05:38:48 -0500 Subject: [PATCH] lib/ftl: Fix band picking for write pointer Removing band from "free list" is moved from FTL_BAND_STATE_OPENING to FTL_BAND_STATE_PREP state's change actions. This will fix race condition when one band is prepared (erased) and write pointer is trying to get next active band. Change-Id: I9e4fe9482a01ee732271736e4a0e6fcedf2582d8 Signed-off-by: Wojciech Malikowski Reviewed-on: https://review.gerrithub.io/c/445118 (master) Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/447461 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/ftl/ftl_band.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ftl/ftl_band.c b/lib/ftl/ftl_band.c index 2f374ebee..47eb88ad8 100644 --- a/lib/ftl/ftl_band.c +++ b/lib/ftl/ftl_band.c @@ -224,13 +224,14 @@ _ftl_band_set_free(struct ftl_band *band) } static void -_ftl_band_set_opening(struct ftl_band *band) +_ftl_band_set_preparing(struct ftl_band *band) { struct spdk_ftl_dev *dev = band->dev; struct ftl_md *md = &band->md; /* Verify band's previous state */ - assert(band->state == FTL_BAND_STATE_PREP); + assert(band->state == FTL_BAND_STATE_FREE); + /* Remove band from free list */ LIST_REMOVE(band, list_entry); md->wr_cnt++; @@ -467,8 +468,8 @@ ftl_band_set_state(struct ftl_band *band, enum ftl_band_state state) _ftl_band_set_free(band); break; - case FTL_BAND_STATE_OPENING: - _ftl_band_set_opening(band); + case FTL_BAND_STATE_PREP: + _ftl_band_set_preparing(band); break; case FTL_BAND_STATE_CLOSED: