Commit ef687807 authored by Mateusz Kozlowski's avatar Mateusz Kozlowski Committed by Darek Stojaczyk
Browse files

lib/ftl: Band seq is restored from head md only



Fixed issue when restoring from a dirty shutdown - sometimes end md
wasn't erased after a band was prepared from writing when a shutdown
happened. This resulted in inconsistency between the new head md and
old tail md, which was technically valid. Band sequence numbers would
then be reused, causing a failure on any subsequent restore.

Signed-off-by: default avatarMateusz Kozlowski <mateusz.kozlowski@intel.com>
Change-Id: Ic3e968be02bb814d6c85f0a3279403fe99337b86
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459287


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent 77c17661
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -362,6 +362,16 @@ ftl_unpack_tail_md(struct ftl_band *band)
		return rc;
	}

	/*
	 * When restoring from a dirty shutdown it's possible old tail meta wasn't yet cleared -
	 * band had saved head meta, but didn't manage to send erase to all chunks.
	 * The already found tail md header is valid, but inconsistent with the head meta. Treat
	 * such a band as open/without valid tail md.
	 */
	if (band->seq != tail->hdr.seq) {
		return FTL_MD_NO_MD;
	}

	if (tail->num_lbks != ftl_num_band_lbks(dev)) {
		return FTL_MD_INVALID_SIZE;
	}
@@ -374,7 +384,6 @@ ftl_unpack_tail_md(struct ftl_band *band)
		memcpy(lba_map->map, map_offset, map_size);
	}

	band->seq = tail->hdr.seq;
	return FTL_MD_SUCCESS;
}