lib/blob: move generation of metadata into separate function

This patch creates new _spdk_blob_persist_generate_new_md()
function that is responsible for generation of new metadata
from current state of blob.

Functionality so far is unchanged.

This is preparation for later in the series where new
extent pages will be written out to disk before metadata pages.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I84158cb8316a881a6170ac37e151a60aaa9d7369
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479848
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Tomasz Zawadzki 2020-01-08 10:28:54 -05:00
parent c879a8eed4
commit 994d4c38ba

View File

@ -1428,7 +1428,7 @@ _spdk_blob_resize(struct spdk_blob *blob, uint64_t sz)
}
static void
_spdk_blob_persist_start(struct spdk_blob_persist_ctx *ctx)
_spdk_blob_persist_generate_new_md(struct spdk_blob_persist_ctx *ctx)
{
spdk_bs_sequence_t *seq = ctx->seq;
struct spdk_blob *blob = ctx->blob;
@ -1438,16 +1438,6 @@ _spdk_blob_persist_start(struct spdk_blob_persist_ctx *ctx)
void *tmp;
int rc;
if (blob->active.num_pages == 0) {
/* This is the signal that the blob should be deleted.
* Immediately jump to the clean up routine. */
assert(blob->clean.num_pages > 0);
blob->state = SPDK_BLOB_STATE_CLEAN;
_spdk_blob_persist_zero_pages(seq, ctx, 0);
return;
}
/* Generate the new metadata */
rc = _spdk_blob_serialize(blob, &ctx->pages, &blob->active.num_pages);
if (rc < 0) {
@ -1497,6 +1487,25 @@ _spdk_blob_persist_start(struct spdk_blob_persist_ctx *ctx)
_spdk_blob_persist_write_page_chain(seq, ctx, 0);
}
static void
_spdk_blob_persist_start(struct spdk_blob_persist_ctx *ctx)
{
spdk_bs_sequence_t *seq = ctx->seq;
struct spdk_blob *blob = ctx->blob;
if (blob->active.num_pages == 0) {
/* This is the signal that the blob should be deleted.
* Immediately jump to the clean up routine. */
assert(blob->clean.num_pages > 0);
blob->state = SPDK_BLOB_STATE_CLEAN;
_spdk_blob_persist_zero_pages(seq, ctx, 0);
return;
}
_spdk_blob_persist_generate_new_md(ctx);
}
static void
_spdk_blob_persist_dirty_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
{