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

lib/ftl: Free IO in case band's relocation was interrupted by shutdown



This leak could be detected by ASAN in FTL CI tests.

Change-Id: I3ab7317dd5288b9fc808fb476627213b00860eb8
Signed-off-by: default avatarWojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448566


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 51515d87
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -624,10 +624,26 @@ ftl_band_reloc_init(struct ftl_reloc *reloc, struct ftl_band_reloc *breloc,
static void
ftl_band_reloc_free(struct ftl_band_reloc *breloc)
{
	struct ftl_reloc *reloc = breloc->parent;
	struct ftl_io *io;
	size_t i, num_ios;

	if (!breloc) {
		return;
	}

	if (breloc->active) {
		num_ios = spdk_ring_dequeue(breloc->write_queue, (void **)reloc->io, reloc->max_qdepth);
		for (i = 0; i < num_ios; ++i) {
			io = reloc->io[i];
			if (io->flags & FTL_IO_INITIALIZED) {
				ftl_reloc_free_io(breloc, io);
			}
		}

		ftl_reloc_release_io(breloc);
	}

	spdk_ring_free(breloc->free_queue);
	spdk_ring_free(breloc->write_queue);
	spdk_bit_array_free(&breloc->reloc_map);