From 758a42f69268d396871832a1a9e6387e80780f94 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Fri, 23 Feb 2018 09:04:28 -0700 Subject: [PATCH] blob: add _spdk_blob_persist_start No functional change - this just separates out the code that creates the persist ctx from the code that actually performs the persist operation. Part of series to enable queuing persist operations - this will be useful for starting a previously queued persist operation. Signed-off-by: Jim Harris Change-Id: Ie1966ff2a477f3075c36f90560010d036658f803 Reviewed-on: https://review.gerrithub.io/401255 Tested-by: SPDK Automated Test System Reviewed-by: Maciej Szwed Reviewed-by: Daniel Verkamp Reviewed-by: Changpeng Liu Reviewed-by: Shuhei Matsumoto --- lib/blob/blobstore.c | 57 +++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 3643e6049..c523c43e9 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -883,6 +883,7 @@ struct spdk_blob_persist_ctx { uint64_t idx; + spdk_bs_sequence_t *seq; spdk_bs_sequence_cpl cb_fn; void *cb_arg; }; @@ -1194,34 +1195,15 @@ _spdk_resize_blob(struct spdk_blob *blob, uint64_t sz) return 0; } -/* Write a blob to disk */ static void -_spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob *blob, - spdk_bs_sequence_cpl cb_fn, void *cb_arg) +_spdk_blob_persist_start(struct spdk_blob_persist_ctx *ctx) { - struct spdk_blob_persist_ctx *ctx; - int rc; + spdk_bs_sequence_t *seq = ctx->seq; + struct spdk_blob *blob = ctx->blob; + struct spdk_blob_store *bs = blob->bs; uint64_t i; uint32_t page_num; - struct spdk_blob_store *bs; - - _spdk_blob_verify_md_op(blob); - - if (blob->state == SPDK_BLOB_STATE_CLEAN) { - cb_fn(seq, cb_arg, 0); - return; - } - - bs = blob->bs; - - ctx = calloc(1, sizeof(*ctx)); - if (!ctx) { - cb_fn(seq, cb_arg, -ENOMEM); - return; - } - ctx->blob = blob; - ctx->cb_fn = cb_fn; - ctx->cb_arg = cb_arg; + int rc; if (blob->active.num_pages == 0) { /* This is the signal that the blob should be deleted. @@ -1284,6 +1266,33 @@ _spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob *blob, _spdk_blob_persist_write_page_chain(seq, ctx, 0); } +/* Write a blob to disk */ +static void +_spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob *blob, + spdk_bs_sequence_cpl cb_fn, void *cb_arg) +{ + struct spdk_blob_persist_ctx *ctx; + + _spdk_blob_verify_md_op(blob); + + if (blob->state == SPDK_BLOB_STATE_CLEAN) { + cb_fn(seq, cb_arg, 0); + return; + } + + ctx = calloc(1, sizeof(*ctx)); + if (!ctx) { + cb_fn(seq, cb_arg, -ENOMEM); + return; + } + ctx->blob = blob; + ctx->seq = seq; + ctx->cb_fn = cb_fn; + ctx->cb_arg = cb_arg; + + _spdk_blob_persist_start(ctx); +} + struct spdk_blob_copy_cluster_ctx { struct spdk_blob *blob; uint8_t *buf;