Commit 2948183f authored by Mike Gerdts's avatar Mike Gerdts Committed by Konrad Sztyber
Browse files

blob: prepare sequences for esnap channels



When a sequence is used to perform IO on an esnap clone, differenent
channels will be needed for the blobstore device and the esnap device.
No special esnap handling is required when a sequence is used to perform
IO directly on the blobstore device.

This commit splits bs_sequence_start() into bs_sequence_start_bs() and
bs_sequence_start_blob() to handle these two scenarios. A later commit
introduces special handling of ensap clone blobs.

Signed-off-by: default avatarMike Gerdts <mgerdts@nvidia.com>
Change-Id: I3a6f46640cdb7fdc380bf557736638f1b39f05e3
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17172


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
parent 31c2852b
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -2619,7 +2619,7 @@ bs_allocate_and_copy_cluster(struct spdk_blob *blob,
	cpl.u.blob_basic.cb_fn = blob_allocate_and_copy_cluster_cpl;
	cpl.u.blob_basic.cb_arg = ctx;

	ctx->seq = bs_sequence_start(_ch, &cpl);
	ctx->seq = bs_sequence_start_blob(_ch, &cpl, blob);
	if (!ctx->seq) {
		spdk_spin_lock(&blob->bs->used_lock);
		bs_release_cluster(blob->bs, ctx->new_cluster);
@@ -2806,7 +2806,7 @@ blob_request_submit_op_split(struct spdk_io_channel *ch, struct spdk_blob *blob,
	cpl.u.blob_basic.cb_fn = cb_fn;
	cpl.u.blob_basic.cb_arg = cb_arg;

	seq = bs_sequence_start(ch, &cpl);
	seq = bs_sequence_start_blob(ch, &cpl, blob);
	if (!seq) {
		free(ctx);
		cb_fn(cb_arg, -ENOMEM);
@@ -3134,7 +3134,7 @@ blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_chan
		if (read) {
			spdk_bs_sequence_t *seq;

			seq = bs_sequence_start(_channel, &cpl);
			seq = bs_sequence_start_blob(_channel, &cpl, blob);
			if (!seq) {
				cb_fn(cb_arg, -ENOMEM);
				return;
@@ -3152,7 +3152,7 @@ blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_chan
			if (is_allocated) {
				spdk_bs_sequence_t *seq;

				seq = bs_sequence_start(_channel, &cpl);
				seq = bs_sequence_start_blob(_channel, &cpl, blob);
				if (!seq) {
					cb_fn(cb_arg, -ENOMEM);
					return;
@@ -4743,7 +4743,7 @@ spdk_bs_load(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
	cpl.u.bs_handle.cb_arg = cb_arg;
	cpl.u.bs_handle.bs = bs;

	ctx->seq = bs_sequence_start(bs->md_channel, &cpl);
	ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!ctx->seq) {
		spdk_free(ctx->super);
		free(ctx);
@@ -5123,7 +5123,7 @@ spdk_bs_dump(struct spdk_bs_dev *dev, FILE *fp, spdk_bs_dump_print_xattr print_x
	cpl.u.bs_basic.cb_fn = cb_fn;
	cpl.u.bs_basic.cb_arg = cb_arg;

	ctx->seq = bs_sequence_start(bs->md_channel, &cpl);
	ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!ctx->seq) {
		spdk_free(ctx->super);
		free(ctx);
@@ -5340,7 +5340,7 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
	cpl.u.bs_handle.cb_arg = cb_arg;
	cpl.u.bs_handle.bs = bs;

	seq = bs_sequence_start(bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!seq) {
		spdk_free(ctx->super);
		free(ctx);
@@ -5425,7 +5425,7 @@ spdk_bs_destroy(struct spdk_blob_store *bs, spdk_bs_op_complete cb_fn,

	ctx->bs = bs;

	seq = bs_sequence_start(bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!seq) {
		free(ctx);
		cb_fn(cb_arg, -ENOMEM);
@@ -5568,7 +5568,7 @@ spdk_bs_unload(struct spdk_blob_store *bs, spdk_bs_op_complete cb_fn, void *cb_a
	cpl.u.bs_basic.cb_fn = cb_fn;
	cpl.u.bs_basic.cb_arg = cb_arg;

	ctx->seq = bs_sequence_start(bs->md_channel, &cpl);
	ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!ctx->seq) {
		spdk_free(ctx->super);
		free(ctx);
@@ -5653,7 +5653,7 @@ spdk_bs_set_super(struct spdk_blob_store *bs, spdk_blob_id blobid,
	cpl.u.bs_basic.cb_fn = cb_fn;
	cpl.u.bs_basic.cb_arg = cb_arg;

	seq = bs_sequence_start(bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!seq) {
		spdk_free(ctx->super);
		free(ctx);
@@ -5963,7 +5963,7 @@ bs_create_blob(struct spdk_blob_store *bs,
	cpl.u.blobid.cb_arg = cb_arg;
	cpl.u.blobid.blobid = blob->id;

	seq = bs_sequence_start(bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!seq) {
		rc = -ENOMEM;
		goto error;
@@ -7370,7 +7370,7 @@ spdk_bs_delete_blob(struct spdk_blob_store *bs, spdk_blob_id blobid,
	cpl.u.blob_basic.cb_fn = cb_fn;
	cpl.u.blob_basic.cb_arg = cb_arg;

	seq = bs_sequence_start(bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!seq) {
		cb_fn(cb_arg, -ENOMEM);
		return;
@@ -7486,7 +7486,7 @@ bs_open_blob(struct spdk_blob_store *bs,
	cpl.u.blob_handle.blob = blob;
	cpl.u.blob_handle.esnap_ctx = opts_local.esnap_ctx;

	seq = bs_sequence_start(bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!seq) {
		blob_free(blob);
		cb_fn(cb_arg, NULL, -ENOMEM);
@@ -7550,7 +7550,7 @@ blob_sync_md(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb_arg)
	cpl.u.blob_basic.cb_fn = cb_fn;
	cpl.u.blob_basic.cb_arg = cb_arg;

	seq = bs_sequence_start(blob->bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(blob->bs->md_channel, &cpl);
	if (!seq) {
		cb_fn(cb_arg, -ENOMEM);
		return;
@@ -7670,7 +7670,7 @@ blob_write_extent_page(struct spdk_blob *blob, uint32_t extent, uint64_t cluster
	cpl.u.blob_basic.cb_fn = cb_fn;
	cpl.u.blob_basic.cb_arg = cb_arg;

	seq = bs_sequence_start(blob->bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(blob->bs->md_channel, &cpl);
	if (!seq) {
		free(ctx);
		cb_fn(cb_arg, -ENOMEM);
@@ -7807,7 +7807,7 @@ spdk_blob_close(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb_ar
	cpl.u.blob_basic.cb_fn = cb_fn;
	cpl.u.blob_basic.cb_arg = cb_arg;

	seq = bs_sequence_start(blob->bs->md_channel, &cpl);
	seq = bs_sequence_start_bs(blob->bs->md_channel, &cpl);
	if (!seq) {
		cb_fn(cb_arg, -ENOMEM);
		return;
@@ -8543,7 +8543,7 @@ spdk_bs_grow(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
	cpl.u.bs_handle.cb_arg = cb_arg;
	cpl.u.bs_handle.bs = bs;

	ctx->seq = bs_sequence_start(bs->md_channel, &cpl);
	ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl);
	if (!ctx->seq) {
		spdk_free(ctx->super);
		free(ctx);
+16 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ bs_sequence_completion(struct spdk_io_channel *channel, void *cb_arg, int bserrn
	set->u.sequence.cb_fn((spdk_bs_sequence_t *)set, set->u.sequence.cb_arg, bserrno);
}

spdk_bs_sequence_t *
static spdk_bs_sequence_t *
bs_sequence_start(struct spdk_io_channel *_channel,
		  struct spdk_bs_cpl *cpl)
{
@@ -100,6 +100,21 @@ bs_sequence_start(struct spdk_io_channel *_channel,
	return (spdk_bs_sequence_t *)set;
}

/* Use when performing IO directly on the blobstore (e.g. metadata - not a blob). */
spdk_bs_sequence_t *
bs_sequence_start_bs(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl)
{
	return bs_sequence_start(_channel, cpl);
}

/* Use when performing IO on a blob. */
spdk_bs_sequence_t *
bs_sequence_start_blob(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl,
		       struct spdk_blob *blob)
{
	return bs_sequence_start(_channel, cpl);
}

void
bs_sequence_read_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev,
			void *payload, uint64_t lba, uint32_t lba_count,
+5 −2
Original line number Diff line number Diff line
@@ -129,9 +129,12 @@ struct spdk_bs_request_set {

void bs_call_cpl(struct spdk_bs_cpl *cpl, int bserrno);

spdk_bs_sequence_t *bs_sequence_start(struct spdk_io_channel *channel,
spdk_bs_sequence_t *bs_sequence_start_bs(struct spdk_io_channel *channel,
		struct spdk_bs_cpl *cpl);

spdk_bs_sequence_t *bs_sequence_start_blob(struct spdk_io_channel *channel,
		struct spdk_bs_cpl *cpl, struct spdk_blob *blob);

void bs_sequence_read_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev,
			     void *payload, uint64_t lba, uint32_t lba_count,
			     spdk_bs_sequence_cpl cb_fn, void *cb_arg);