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: Wojciech Malikowski <wojciech.malikowski@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2964
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
Wojciech Malikowski 2020-06-17 12:47:47 -04:00 committed by Jim Harris
parent 71ccea94ce
commit c10c9bf767
3 changed files with 8 additions and 3 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);