blobstore: always destroy bs_dev during spdk_bs_init()
Now bs_dev is destroyed only in two instances: - within spdk_bs_init() on failure path - vbdev_lvs_create() if spdk_lvs_init() errors out, before even calling spdk_bs_init() Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I7b8af39fbe83907b0c47797f0f55ca3b941729d9 Reviewed-on: https://review.gerrithub.io/379848 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
52207d7800
commit
9a58c40eba
@ -47,14 +47,12 @@ static void
|
|||||||
_vbdev_lvs_create_cb(void *cb_arg, struct spdk_lvol_store *lvs, int lvserrno)
|
_vbdev_lvs_create_cb(void *cb_arg, struct spdk_lvol_store *lvs, int lvserrno)
|
||||||
{
|
{
|
||||||
struct spdk_lvs_with_handle_req *req = cb_arg;
|
struct spdk_lvs_with_handle_req *req = cb_arg;
|
||||||
struct spdk_bs_dev *bs_dev = req->bs_dev;
|
|
||||||
struct lvol_store_bdev *lvs_bdev;
|
struct lvol_store_bdev *lvs_bdev;
|
||||||
struct spdk_bdev *bdev = req->base_bdev;
|
struct spdk_bdev *bdev = req->base_bdev;
|
||||||
|
|
||||||
if (lvserrno != 0) {
|
if (lvserrno != 0) {
|
||||||
assert(lvs == NULL);
|
assert(lvs == NULL);
|
||||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Cannot create lvol store bdev\n");
|
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Cannot create lvol store bdev\n");
|
||||||
bs_dev->destroy(bs_dev);
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +60,6 @@ _vbdev_lvs_create_cb(void *cb_arg, struct spdk_lvol_store *lvs, int lvserrno)
|
|||||||
|
|
||||||
lvs_bdev = calloc(1, sizeof(*lvs_bdev));
|
lvs_bdev = calloc(1, sizeof(*lvs_bdev));
|
||||||
if (!lvs_bdev) {
|
if (!lvs_bdev) {
|
||||||
bs_dev->destroy(bs_dev);
|
|
||||||
lvserrno = -ENOMEM;
|
lvserrno = -ENOMEM;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
@ -1707,6 +1707,7 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
|
|||||||
if ((SPDK_BS_PAGE_SIZE % dev->blocklen) != 0) {
|
if ((SPDK_BS_PAGE_SIZE % dev->blocklen) != 0) {
|
||||||
SPDK_ERRLOG("unsupported dev block length of %d\n",
|
SPDK_ERRLOG("unsupported dev block length of %d\n",
|
||||||
dev->blocklen);
|
dev->blocklen);
|
||||||
|
dev->destroy(dev);
|
||||||
cb_fn(cb_arg, NULL, -EINVAL);
|
cb_fn(cb_arg, NULL, -EINVAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1719,6 +1720,7 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o,
|
|||||||
|
|
||||||
bs = _spdk_bs_alloc(dev, &opts);
|
bs = _spdk_bs_alloc(dev, &opts);
|
||||||
if (!bs) {
|
if (!bs) {
|
||||||
|
dev->destroy(dev);
|
||||||
cb_fn(cb_arg, NULL, -ENOMEM);
|
cb_fn(cb_arg, NULL, -ENOMEM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,7 @@ spdk_lvs_init(struct spdk_bs_dev *bs_dev, spdk_lvs_op_with_handle_complete cb_fn
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (lvol_store_initialize_cb_fail) {
|
if (lvol_store_initialize_cb_fail) {
|
||||||
|
bs_dev->destroy(bs_dev);
|
||||||
lvs = NULL;
|
lvs = NULL;
|
||||||
error = -1;
|
error = -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -131,13 +131,6 @@ blob_init(void)
|
|||||||
dev->blocklen = 500;
|
dev->blocklen = 500;
|
||||||
spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL);
|
spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL);
|
||||||
CU_ASSERT(g_bserrno == -EINVAL);
|
CU_ASSERT(g_bserrno == -EINVAL);
|
||||||
/*
|
|
||||||
* Normally dev gets deleted as part of the dev->destroy callback. But
|
|
||||||
* that doesn't get invoked when init() fails. So manually free it here
|
|
||||||
* instead. Probably blobstore should still destroy the dev when init
|
|
||||||
* fails, but we'll do that in a separate patch.
|
|
||||||
*/
|
|
||||||
free(dev);
|
|
||||||
|
|
||||||
dev = init_dev();
|
dev = init_dev();
|
||||||
spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL);
|
spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user