blobstore: destroy bs_dev on spdk_bs_load fail

Some error paths before _spdk_bs_alloc did not
destroy bs_dev.

After succesfull _spdk_bs_alloc, destroying is done
in _spdk_bs_free.

Change-Id: Ib69ae9707e12a646af80f7892af49cc4f79c199e
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/405223
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Tomasz Zawadzki 2018-03-26 04:21:35 -04:00 committed by Daniel Verkamp
parent ea3a17fb55
commit 56cfdb1daa
2 changed files with 17 additions and 0 deletions

View File

@ -2825,12 +2825,14 @@ spdk_bs_load(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
}
if (opts.max_md_ops == 0 || opts.max_channel_ops == 0) {
dev->destroy(dev);
cb_fn(cb_arg, NULL, -EINVAL);
return;
}
bs = _spdk_bs_alloc(dev, &opts);
if (!bs) {
dev->destroy(dev);
cb_fn(cb_arg, NULL, -ENOMEM);
return;
}

View File

@ -1547,8 +1547,23 @@ bs_load(void)
spdk_bs_load(dev, NULL, bs_op_with_handle_complete, NULL);
CU_ASSERT(g_bserrno == -EINVAL);
/* Load should when max_md_ops is set to zero */
dev = init_dev();
spdk_bs_opts_init(&opts);
opts.max_md_ops = 0;
spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL);
CU_ASSERT(g_bserrno == -EINVAL);
/* Load should when max_channel_ops is set to zero */
dev = init_dev();
spdk_bs_opts_init(&opts);
opts.max_channel_ops = 0;
spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL);
CU_ASSERT(g_bserrno == -EINVAL);
/* Load an existing blob store */
dev = init_dev();
spdk_bs_opts_init(&opts);
strncpy(opts.bstype.bstype, "TESTTYPE", SPDK_BLOBSTORE_TYPE_LENGTH);
spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL);
CU_ASSERT(g_bserrno == 0);