From a8fe601853640b1a1820de48652d75e731ab66c9 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 27 Apr 2021 10:17:15 -0400 Subject: [PATCH] lib/blob: delay executing blob persist completions This helps in next patch in series where multiple completions will be executing. UT is adjusted since one additional poll is required. Signed-off-by: Tomasz Zawadzki Change-Id: Id72377ddef91e40cdbc2bdea6f33c23309b0ca3d Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7642 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- lib/blob/blobstore.c | 20 ++++++++++++++------ test/unit/lib/blob/blob.c/blob_ut.c | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index d7e3bbb03..225fa11db 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -1619,6 +1619,19 @@ bs_batch_clear_dev(struct spdk_blob_persist_ctx *ctx, spdk_bs_batch_t *batch, ui static void blob_persist_check_dirty(struct spdk_blob_persist_ctx *ctx); +static void +blob_persist_complete_cb(void *arg) +{ + struct spdk_blob_persist_ctx *ctx = arg; + + /* Call user callback */ + ctx->cb_fn(ctx->seq, ctx->cb_arg, 0); + + /* Free the memory */ + spdk_free(ctx->pages); + free(ctx); +} + static void blob_persist_complete(spdk_bs_sequence_t *seq, struct spdk_blob_persist_ctx *ctx, int bserrno) { @@ -1634,12 +1647,7 @@ blob_persist_complete(spdk_bs_sequence_t *seq, struct spdk_blob_persist_ctx *ctx next_persist = TAILQ_FIRST(&blob->pending_persists); - /* Call user callback */ - ctx->cb_fn(seq, ctx->cb_arg, bserrno); - - /* Free the memory */ - spdk_free(ctx->pages); - free(ctx); + spdk_thread_send_msg(spdk_get_thread(), blob_persist_complete_cb, ctx); if (next_persist != NULL) { blob->state = SPDK_BLOB_STATE_DIRTY; diff --git a/test/unit/lib/blob/blob.c/blob_ut.c b/test/unit/lib/blob/blob.c/blob_ut.c index 1494de29c..b11e002d4 100644 --- a/test/unit/lib/blob/blob.c/blob_ut.c +++ b/test/unit/lib/blob/blob.c/blob_ut.c @@ -821,7 +821,7 @@ blob_snapshot_freeze_io(void) /* This is implementation specific. * Flag 'frozen_io' is set in _spdk_bs_snapshot_freeze_cpl callback. * Four async I/O operations happen before that. */ - poll_thread_times(0, 4); + poll_thread_times(0, 5); CU_ASSERT(TAILQ_EMPTY(&bs_channel->queued_io));