diff --git a/lib/ftl/ftl_core.c b/lib/ftl/ftl_core.c index b12e7a88a..d78b85b54 100644 --- a/lib/ftl/ftl_core.c +++ b/lib/ftl/ftl_core.c @@ -805,10 +805,20 @@ ftl_stats_crc_error(struct spdk_ftl_dev *dev, enum ftl_stats_type type) struct ftl_get_stats_ctx { struct spdk_ftl_dev *dev; struct ftl_stats *stats; + struct spdk_thread *thread; spdk_ftl_stats_fn cb_fn; void *cb_arg; }; +static void +_ftl_get_stats_cb(void *_ctx) +{ + struct ftl_get_stats_ctx *stats_ctx = _ctx; + + stats_ctx->cb_fn(stats_ctx->stats, stats_ctx->cb_arg); + free(stats_ctx); +} + static void _ftl_get_stats(void *_ctx) { @@ -816,8 +826,9 @@ _ftl_get_stats(void *_ctx) *stats_ctx->stats = stats_ctx->dev->stats; - stats_ctx->cb_fn(stats_ctx->stats, stats_ctx->cb_arg); - free(stats_ctx); + if (spdk_thread_send_msg(stats_ctx->thread, _ftl_get_stats_cb, stats_ctx)) { + ftl_abort(); + } } int @@ -836,6 +847,7 @@ spdk_ftl_get_stats(struct spdk_ftl_dev *dev, struct ftl_stats *stats, spdk_ftl_s stats_ctx->stats = stats; stats_ctx->cb_fn = cb_fn; stats_ctx->cb_arg = cb_arg; + stats_ctx->thread = spdk_get_thread(); rc = spdk_thread_send_msg(dev->core_thread, _ftl_get_stats, stats_ctx); if (rc) { diff --git a/lib/ftl/mngt/ftl_mngt_startup.c b/lib/ftl/mngt/ftl_mngt_startup.c index 8e9d24dcd..51904cb87 100644 --- a/lib/ftl/mngt/ftl_mngt_startup.c +++ b/lib/ftl/mngt/ftl_mngt_startup.c @@ -295,6 +295,8 @@ struct ftl_unmap_ctx { uint64_t num_blocks; spdk_ftl_fn cb_fn; void *cb_arg; + struct spdk_thread *thread; + int status; }; static void @@ -343,15 +345,25 @@ static const struct ftl_mngt_process_desc g_desc_unmap = { }; static void -ftl_mngt_unmap_cb(struct spdk_ftl_dev *dev, void *_ctx, int status) +unmap_user_cb(void *_ctx) { struct ftl_unmap_ctx *ctx = _ctx; - ctx->cb_fn(ctx->cb_arg, status); - + ctx->cb_fn(ctx->cb_arg, ctx->status); free(ctx); } +static void +ftl_mngt_unmap_cb(struct spdk_ftl_dev *dev, void *_ctx, int status) +{ + struct ftl_unmap_ctx *ctx = _ctx; + ctx->status = status; + + if (spdk_thread_send_msg(ctx->thread, unmap_user_cb, ctx)) { + ftl_abort(); + } +} + int ftl_mngt_unmap(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks, spdk_ftl_fn cb, void *cb_cntx) @@ -367,6 +379,7 @@ ftl_mngt_unmap(struct spdk_ftl_dev *dev, uint64_t lba, uint64_t num_blocks, spdk ctx->num_blocks = num_blocks; ctx->cb_fn = cb; ctx->cb_arg = cb_cntx; + ctx->thread = spdk_get_thread(); return ftl_mngt_process_execute(dev, &g_desc_unmap, ftl_mngt_unmap_cb, ctx); }