Commit c5c102ce authored by Wojciech Malikowski's avatar Wojciech Malikowski Committed by Jim Harris
Browse files

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: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/445118


Reviewed-by: default avatarJakub Radtke <jakub.radtke@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 0f12c406
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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: