lib/blob: move starting persist to separate function

_spdk_blob_persist_check_dirty() function will be
called in subsequent patch at the end of persist
in _spdk_blob_persist_complete() to proceed
with any queued up persists.
Please see following patch for this.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ieeb334e23cde329743647f728e70dd60333c224a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/872
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Tomasz Zawadzki 2020-02-12 09:15:58 -05:00
parent 248fbf2aec
commit dd80edb2b4

View File

@ -2060,6 +2060,25 @@ _spdk_blob_persist_dirty(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
_spdk_bs_write_super(seq, ctx->blob->bs, ctx->super, _spdk_blob_persist_dirty_cpl, ctx);
}
static void
_spdk_blob_persist_check_dirty(struct spdk_blob_persist_ctx *ctx)
{
if (ctx->blob->bs->clean) {
ctx->super = spdk_zmalloc(sizeof(*ctx->super), 0x1000, NULL,
SPDK_ENV_SOCKET_ID_ANY, SPDK_MALLOC_DMA);
if (!ctx->super) {
ctx->cb_fn(ctx->seq, ctx->cb_arg, -ENOMEM);
free(ctx);
return;
}
spdk_bs_sequence_read_dev(ctx->seq, ctx->super, _spdk_bs_page_to_lba(ctx->blob->bs, 0),
_spdk_bs_byte_to_lba(ctx->blob->bs, sizeof(*ctx->super)),
_spdk_blob_persist_dirty, ctx);
} else {
_spdk_blob_persist_start(ctx);
}
}
/* Write a blob to disk */
static void
@ -2086,21 +2105,7 @@ _spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob *blob,
ctx->cb_arg = cb_arg;
ctx->next_extent_page = 0;
if (blob->bs->clean) {
ctx->super = spdk_zmalloc(sizeof(*ctx->super), 0x1000, NULL,
SPDK_ENV_SOCKET_ID_ANY, SPDK_MALLOC_DMA);
if (!ctx->super) {
cb_fn(seq, cb_arg, -ENOMEM);
free(ctx);
return;
}
spdk_bs_sequence_read_dev(seq, ctx->super, _spdk_bs_page_to_lba(blob->bs, 0),
_spdk_bs_byte_to_lba(blob->bs, sizeof(*ctx->super)),
_spdk_blob_persist_dirty, ctx);
} else {
_spdk_blob_persist_start(ctx);
}
_spdk_blob_persist_check_dirty(ctx);
}
struct spdk_blob_copy_cluster_ctx {