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: Mike Gerdts <mgerdts@nvidia.com> Change-Id: I56e8e338b0560f849399c085d0bb07efb7df26fb Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15983 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com> Community-CI: Mellanox Build Bot
This commit is contained in:
parent
c1544908e0
commit
67c7e85809
@ -5762,10 +5762,8 @@ bs_create_blob(struct spdk_blob_store *bs,
|
|||||||
|
|
||||||
blob = blob_alloc(bs, id);
|
blob = blob_alloc(bs, id);
|
||||||
if (!blob) {
|
if (!blob) {
|
||||||
spdk_bit_array_clear(bs->used_blobids, page_idx);
|
rc = -ENOMEM;
|
||||||
bs_release_md_page(bs, page_idx);
|
goto error;
|
||||||
cb_fn(cb_arg, 0, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spdk_blob_opts_init(&opts_local, sizeof(opts_local));
|
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);
|
rc = blob_set_xattrs(blob, &opts_local.xattrs, false);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
blob_free(blob);
|
goto error;
|
||||||
spdk_bit_array_clear(bs->used_blobids, page_idx);
|
|
||||||
bs_release_md_page(bs, page_idx);
|
|
||||||
cb_fn(cb_arg, 0, rc);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = blob_set_xattrs(blob, internal_xattrs, true);
|
rc = blob_set_xattrs(blob, internal_xattrs, true);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
blob_free(blob);
|
goto error;
|
||||||
spdk_bit_array_clear(bs->used_blobids, page_idx);
|
|
||||||
bs_release_md_page(bs, page_idx);
|
|
||||||
cb_fn(cb_arg, 0, rc);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts_local.thin_provision) {
|
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);
|
rc = blob_resize(blob, opts_local.num_clusters);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
blob_free(blob);
|
goto error;
|
||||||
spdk_bit_array_clear(bs->used_blobids, page_idx);
|
|
||||||
bs_release_md_page(bs, page_idx);
|
|
||||||
cb_fn(cb_arg, 0, rc);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
cpl.type = SPDK_BS_CPL_TYPE_BLOBID;
|
cpl.type = SPDK_BS_CPL_TYPE_BLOBID;
|
||||||
cpl.u.blobid.cb_fn = cb_fn;
|
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);
|
seq = bs_sequence_start(bs->md_channel, &cpl);
|
||||||
if (!seq) {
|
if (!seq) {
|
||||||
blob_free(blob);
|
rc = -ENOMEM;
|
||||||
spdk_bit_array_clear(bs->used_blobids, page_idx);
|
goto error;
|
||||||
bs_release_md_page(bs, page_idx);
|
|
||||||
cb_fn(cb_arg, 0, -ENOMEM);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blob_persist(seq, blob, bs_create_blob_cpl, blob);
|
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
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user