From 660a0fae829f8e4daa74fa9a1d8b7ac6832857c7 Mon Sep 17 00:00:00 2001 From: Wojciech Malikowski Date: Wed, 20 Mar 2019 13:39:23 -0400 Subject: [PATCH] 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: Wojciech Malikowski Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448566 Reviewed-by: Konrad Sztyber Reviewed-by: Darek Stojaczyk Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- lib/ftl/ftl_reloc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/ftl/ftl_reloc.c b/lib/ftl/ftl_reloc.c index a4e22e4a09..cdc4a57b46 100644 --- a/lib/ftl/ftl_reloc.c +++ b/lib/ftl/ftl_reloc.c @@ -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);