Commit dd80edb2 authored by Tomasz Zawadzki's avatar Tomasz Zawadzki
Browse files

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: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ieeb334e23cde329743647f728e70dd60333c224a
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/872


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 248fbf2a
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -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 {