Commit 67c7e858 authored by Mike Gerdts's avatar Mike Gerdts Committed by Tomasz Zawadzki
Browse files

blobstore: use common return path in bs_create_blob()



A future commit will add to the complexity when returning with a
non-zero value. Rather than further complicating the several error
return locations, all affected error returns are handled after the error
label.

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


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
parent c1544908
Loading
Loading
Loading
Loading
+16 −24
Original line number Diff line number Diff line
@@ -5762,10 +5762,8 @@ bs_create_blob(struct spdk_blob_store *bs,

	blob = blob_alloc(bs, id);
	if (!blob) {
		spdk_bit_array_clear(bs->used_blobids, page_idx);
		bs_release_md_page(bs, page_idx);
		cb_fn(cb_arg, 0, -ENOMEM);
		return;
		rc = -ENOMEM;
		goto error;
	}

	spdk_blob_opts_init(&opts_local, sizeof(opts_local));
@@ -5785,20 +5783,12 @@ bs_create_blob(struct spdk_blob_store *bs,

	rc = blob_set_xattrs(blob, &opts_local.xattrs, false);
	if (rc < 0) {
		blob_free(blob);
		spdk_bit_array_clear(bs->used_blobids, page_idx);
		bs_release_md_page(bs, page_idx);
		cb_fn(cb_arg, 0, rc);
		return;
		goto error;
	}

	rc = blob_set_xattrs(blob, internal_xattrs, true);
	if (rc < 0) {
		blob_free(blob);
		spdk_bit_array_clear(bs->used_blobids, page_idx);
		bs_release_md_page(bs, page_idx);
		cb_fn(cb_arg, 0, rc);
		return;
		goto error;
	}

	if (opts_local.thin_provision) {
@@ -5809,11 +5799,7 @@ bs_create_blob(struct spdk_blob_store *bs,

	rc = blob_resize(blob, opts_local.num_clusters);
	if (rc < 0) {
		blob_free(blob);
		spdk_bit_array_clear(bs->used_blobids, page_idx);
		bs_release_md_page(bs, page_idx);
		cb_fn(cb_arg, 0, rc);
		return;
		goto error;
	}
	cpl.type = SPDK_BS_CPL_TYPE_BLOBID;
	cpl.u.blobid.cb_fn = cb_fn;
@@ -5822,14 +5808,20 @@ bs_create_blob(struct spdk_blob_store *bs,

	seq = bs_sequence_start(bs->md_channel, &cpl);
	if (!seq) {
		blob_free(blob);
		spdk_bit_array_clear(bs->used_blobids, page_idx);
		bs_release_md_page(bs, page_idx);
		cb_fn(cb_arg, 0, -ENOMEM);
		return;
		rc = -ENOMEM;
		goto error;
	}

	blob_persist(seq, blob, bs_create_blob_cpl, blob);
	return;

error:
	if (blob != NULL) {
		blob_free(blob);
	}
	spdk_bit_array_clear(bs->used_blobids, page_idx);
	bs_release_md_page(bs, page_idx);
	cb_fn(cb_arg, 0, rc);
}

void