FTL: close ftl bdev in original thread
spdk_bdev_close should be called on the caller thread. Saving the thread now for both unmap and get stats, and executing the close in the appropriate context. Signed-off-by: Kozlowski Mateusz <mateusz.kozlowski@intel.com> Change-Id: I82192817d6012b0d41bbe2078fbd3f7dc01a7282 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14597 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
691504a314
commit
be61c92a6d
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user