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

lib/ftl: Evict valid cache entries when destroying io channel



When io channel is being destroyed some of its write
buffer entries could still be a valid cache entry.
This patch evicts all entries during io channel destroy
to keep consistent l2p table.

fixes issue #1434

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 71ccea94
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -146,8 +146,6 @@ ftl_remove_wptr(struct ftl_wptr *wptr)
	ftl_wptr_free(wptr);
}

static void ftl_evict_cache_entry(struct spdk_ftl_dev *dev, struct ftl_wbuf_entry *entry);

static struct ftl_wbuf_entry *
ftl_acquire_wbuf_entry(struct ftl_io_channel *io_channel, int io_flags)
{
@@ -910,7 +908,7 @@ ftl_cache_lba_valid(struct spdk_ftl_dev *dev, struct ftl_wbuf_entry *entry)
	return true;
}

static void
void
ftl_evict_cache_entry(struct spdk_ftl_dev *dev, struct ftl_wbuf_entry *entry)
{
	pthread_spin_lock(&entry->lock);
+1 −0
Original line number Diff line number Diff line
@@ -298,6 +298,7 @@ int ftl_nv_cache_scrub(struct ftl_nv_cache *nv_cache, spdk_bdev_io_completion_cb
			   void *cb_arg);
void	ftl_get_media_events(struct spdk_ftl_dev *dev);
int	ftl_io_channel_poll(void *arg);
void	ftl_evict_cache_entry(struct spdk_ftl_dev *dev, struct ftl_wbuf_entry *entry);
struct spdk_io_channel *ftl_get_io_channel(const struct spdk_ftl_dev *dev);
struct ftl_io_channel *ftl_io_channel_get_ctx(struct spdk_io_channel *ioch);

+6 −0
Original line number Diff line number Diff line
@@ -1207,6 +1207,7 @@ _ftl_io_channel_destroy_cb(void *ctx)
{
	struct ftl_io_channel *ioch = ctx;
	struct spdk_ftl_dev *dev = ioch->dev;
	uint32_t i;

	/* Do not destroy the channel if some of its entries are still in use */
	if (spdk_ring_count(ioch->free_queue) != ioch->num_entries) {
@@ -1214,6 +1215,11 @@ _ftl_io_channel_destroy_cb(void *ctx)
		return;
	}

	/* Evict all valid entries from cache */
	for (i = 0; i < ioch->num_entries; ++i) {
		ftl_evict_cache_entry(dev, &ioch->wbuf_entries[i]);
	}

	spdk_poller_unregister(&ioch->poller);

	spdk_put_io_channel(ioch->base_ioch);