ut/lvol: consolidate callbacks to op_complete()

There are three types of callbacks in lvol library:
- void(cb_arg,lvs,errno)
- void(cb_arg,lvol,errno)
- void(cb_arg,errno)
First two are used in cases where result of operation is
either lvs or lvol.
Last one is used for any operation that does not produce
either.

There is no need to keep more than one callback function
for last one, since they all are doing the same thing.

lvol_op_complete(), lvol_store_op_complete(), close_cb() and
destroy_cb() are now replaced with op_complete().

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Idd8fcf327ef56ad7d27e2e31cad9ddc44c80e5c8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1484
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Tomasz Zawadzki 2020-03-26 05:54:19 -04:00
parent b8645ac8da
commit 764cede766

View File

@ -484,12 +484,6 @@ lvol_store_op_with_handle_complete(void *cb_arg, struct spdk_lvol_store *lvol_st
g_lvserrno = lvserrno; g_lvserrno = lvserrno;
} }
static void
lvol_op_complete(void *cb_arg, int lvserrno)
{
g_lvserrno = lvserrno;
}
static void static void
lvol_op_with_handle_complete(void *cb_arg, struct spdk_lvol *lvol, int lvserrno) lvol_op_with_handle_complete(void *cb_arg, struct spdk_lvol *lvol, int lvserrno)
{ {
@ -498,19 +492,7 @@ lvol_op_with_handle_complete(void *cb_arg, struct spdk_lvol *lvol, int lvserrno)
} }
static void static void
lvol_store_op_complete(void *cb_arg, int lvserrno) op_complete(void *cb_arg, int lvserrno)
{
g_lvserrno = lvserrno;
}
static void
close_cb(void *cb_arg, int lvserrno)
{
g_lvserrno = lvserrno;
}
static void
destroy_cb(void *cb_arg, int lvserrno)
{ {
g_lvserrno = lvserrno; g_lvserrno = lvserrno;
} }
@ -543,18 +525,18 @@ lvs_init_unload_success(void)
/* Lvol store has an open lvol, this unload should fail. */ /* Lvol store has an open lvol, this unload should fail. */
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == -EBUSY); CU_ASSERT(rc == -EBUSY);
CU_ASSERT(g_lvserrno == -EBUSY); CU_ASSERT(g_lvserrno == -EBUSY);
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL); SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
CU_ASSERT(!TAILQ_EMPTY(&g_lvol_stores)); CU_ASSERT(!TAILQ_EMPTY(&g_lvol_stores));
/* Lvol has to be closed (or destroyed) before unloading lvol store. */ /* Lvol has to be closed (or destroyed) before unloading lvol store. */
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -589,18 +571,18 @@ lvs_init_destroy_success(void)
/* Lvol store contains one lvol, this destroy should fail. */ /* Lvol store contains one lvol, this destroy should fail. */
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == -EBUSY); CU_ASSERT(rc == -EBUSY);
CU_ASSERT(g_lvserrno == -EBUSY); CU_ASSERT(g_lvserrno == -EBUSY);
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL); SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -627,7 +609,7 @@ lvs_init_opts_success(void)
SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL); SPDK_CU_ASSERT_FATAL(g_lvol_store != NULL);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -641,7 +623,7 @@ lvs_unload_lvs_is_null_fail(void)
int rc = 0; int rc = 0;
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(NULL, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(NULL, op_complete, NULL);
CU_ASSERT(rc == -ENODEV); CU_ASSERT(rc == -ENODEV);
CU_ASSERT(g_lvserrno == -1); CU_ASSERT(g_lvserrno == -1);
} }
@ -702,7 +684,7 @@ lvs_names(void)
/* Now destroy lvolstore 'x' and then confirm we can create a new lvolstore with name 'x'. */ /* Now destroy lvolstore 'x' and then confirm we can create a new lvolstore with name 'x'. */
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs_x, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs_x, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -715,7 +697,7 @@ lvs_names(void)
* Unload lvolstore 'x'. Then we should be able to create another lvolstore with name 'x'. * Unload lvolstore 'x'. Then we should be able to create another lvolstore with name 'x'.
*/ */
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(lvs_x, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(lvs_x, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -731,7 +713,7 @@ lvs_names(void)
/* Destroy the second lvolstore 'x'. Then we should be able to load the first lvolstore 'x'. */ /* Destroy the second lvolstore 'x'. Then we should be able to load the first lvolstore 'x'. */
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs_x2, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs_x2, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
@ -741,12 +723,12 @@ lvs_names(void)
lvs_x = g_lvol_store; lvs_x = g_lvol_store;
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs_x, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs_x, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs_y, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs_y, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
} }
@ -774,13 +756,13 @@ lvol_create_destroy_success(void)
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -824,7 +806,7 @@ lvol_create_fail(void)
CU_ASSERT(g_lvol == NULL); CU_ASSERT(g_lvol == NULL);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -854,9 +836,9 @@ lvol_destroy_fail(void)
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_create(g_lvol_store, "lvol", 10, false, LVOL_CLEAR_WITH_DEFAULT, spdk_lvol_create(g_lvol_store, "lvol", 10, false, LVOL_CLEAR_WITH_DEFAULT,
@ -864,17 +846,17 @@ lvol_destroy_fail(void)
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_remove_rc = -1; g_remove_rc = -1;
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
CU_ASSERT(TAILQ_EMPTY(&g_lvol_store->lvols)); CU_ASSERT(TAILQ_EMPTY(&g_lvol_store->lvols));
g_remove_rc = 0; g_remove_rc = 0;
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -904,11 +886,11 @@ lvol_close_fail(void)
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -939,11 +921,11 @@ lvol_close_success(void)
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -976,41 +958,41 @@ lvol_resize(void)
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
/* Resize to same size */ /* Resize to same size */
spdk_lvol_resize(g_lvol, 10, lvol_store_op_complete, NULL); spdk_lvol_resize(g_lvol, 10, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
/* Resize to smaller size */ /* Resize to smaller size */
spdk_lvol_resize(g_lvol, 5, lvol_store_op_complete, NULL); spdk_lvol_resize(g_lvol, 5, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
/* Resize to bigger size */ /* Resize to bigger size */
spdk_lvol_resize(g_lvol, 15, lvol_store_op_complete, NULL); spdk_lvol_resize(g_lvol, 15, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
/* Resize to size = 0 */ /* Resize to size = 0 */
spdk_lvol_resize(g_lvol, 0, lvol_store_op_complete, NULL); spdk_lvol_resize(g_lvol, 0, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
/* Resize to bigger size than available */ /* Resize to bigger size than available */
g_lvserrno = 0; g_lvserrno = 0;
spdk_lvol_resize(g_lvol, 0xFFFFFFFF, lvol_store_op_complete, NULL); spdk_lvol_resize(g_lvol, 0xFFFFFFFF, op_complete, NULL);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
/* Fail resize */ /* Fail resize */
g_resize_rc = -1; g_resize_rc = -1;
g_lvserrno = 0; g_lvserrno = 0;
spdk_lvol_resize(g_lvol, 10, lvol_store_op_complete, NULL); spdk_lvol_resize(g_lvol, 10, op_complete, NULL);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
g_resize_rc = 0; g_resize_rc = 0;
g_resize_rc = 0; g_resize_rc = 0;
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1044,7 +1026,7 @@ lvol_set_read_only(void)
lvol = g_lvol; lvol = g_lvol;
/* Set lvol as read only */ /* Set lvol as read only */
spdk_lvol_set_read_only(lvol, lvol_op_complete, NULL); spdk_lvol_set_read_only(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
/* Create lvol clone from read only lvol */ /* Create lvol clone from read only lvol */
@ -1054,13 +1036,13 @@ lvol_set_read_only(void)
CU_ASSERT_STRING_EQUAL(g_lvol->name, "clone"); CU_ASSERT_STRING_EQUAL(g_lvol->name, "clone");
clone = g_lvol; clone = g_lvol;
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_close(clone, close_cb, NULL); spdk_lvol_close(clone, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1155,7 +1137,7 @@ lvs_load(void)
CU_ASSERT(!TAILQ_EMPTY(&g_lvol_stores)); CU_ASSERT(!TAILQ_EMPTY(&g_lvol_stores));
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
CU_ASSERT(TAILQ_EMPTY(&g_lvol_stores)); CU_ASSERT(TAILQ_EMPTY(&g_lvol_stores));
@ -1221,7 +1203,7 @@ lvols_load(void)
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
@ -1259,7 +1241,7 @@ lvols_load(void)
CU_ASSERT(!TAILQ_EMPTY(&g_lvol_store->lvols)); CU_ASSERT(!TAILQ_EMPTY(&g_lvol_store->lvols));
g_lvserrno = -1; g_lvserrno = -1;
/* rc = */ spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); /* rc = */ spdk_lvs_unload(g_lvol_store, op_complete, NULL);
/* /*
* Disable these two asserts for now. lvolstore should allow unload as long * Disable these two asserts for now. lvolstore should allow unload as long
* as the lvols were not opened - but this is coming a future patch. * as the lvols were not opened - but this is coming a future patch.
@ -1354,12 +1336,12 @@ lvol_open(void)
/* Close all lvols */ /* Close all lvols */
TAILQ_FOREACH_SAFE(lvol, &g_lvol_store->lvols, link, tmp) { TAILQ_FOREACH_SAFE(lvol, &g_lvol_store->lvols, link, tmp) {
spdk_lvol_close(lvol, lvol_op_complete, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
} }
g_lvserrno = -1; g_lvserrno = -1;
spdk_lvs_destroy(g_lvol_store, lvol_store_op_complete, NULL); spdk_lvs_destroy(g_lvol_store, op_complete, NULL);
free(req); free(req);
free(blob1); free(blob1);
@ -1399,15 +1381,15 @@ lvol_snapshot(void)
CU_ASSERT_STRING_EQUAL(g_lvol->name, "snap"); CU_ASSERT_STRING_EQUAL(g_lvol->name, "snap");
/* Lvol has to be closed (or destroyed) before unloading lvol store. */ /* Lvol has to be closed (or destroyed) before unloading lvol store. */
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1463,15 +1445,15 @@ lvol_snapshot_fail(void)
spdk_lvol_create_snapshot(lvol, "snap", lvol_op_with_handle_complete, NULL); spdk_lvol_create_snapshot(lvol, "snap", lvol_op_with_handle_complete, NULL);
CU_ASSERT(g_lvserrno < 0); CU_ASSERT(g_lvserrno < 0);
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
spdk_lvol_close(snap, close_cb, NULL); spdk_lvol_close(snap, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1519,19 +1501,19 @@ lvol_clone(void)
CU_ASSERT_STRING_EQUAL(g_lvol->name, "clone"); CU_ASSERT_STRING_EQUAL(g_lvol->name, "clone");
/* Lvol has to be closed (or destroyed) before unloading lvol store. */ /* Lvol has to be closed (or destroyed) before unloading lvol store. */
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
spdk_lvol_close(snap, close_cb, NULL); spdk_lvol_close(snap, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1594,19 +1576,19 @@ lvol_clone_fail(void)
CU_ASSERT(g_lvserrno < 0); CU_ASSERT(g_lvserrno < 0);
/* Lvol has to be closed (or destroyed) before unloading lvol store. */ /* Lvol has to be closed (or destroyed) before unloading lvol store. */
spdk_lvol_close(clone, close_cb, NULL); spdk_lvol_close(clone, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
spdk_lvol_close(snap, close_cb, NULL); spdk_lvol_close(snap, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1670,8 +1652,8 @@ lvol_names(void)
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
lvol2 = g_lvol; lvol2 = g_lvol;
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
spdk_lvol_destroy(lvol, lvol_op_complete, NULL); spdk_lvol_destroy(lvol, op_complete, NULL);
g_lvserrno = -1; g_lvserrno = -1;
g_lvol = NULL; g_lvol = NULL;
@ -1682,11 +1664,11 @@ lvol_names(void)
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
lvol = g_lvol; lvol = g_lvol;
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
spdk_lvol_destroy(lvol, destroy_cb, NULL); spdk_lvol_destroy(lvol, op_complete, NULL);
spdk_lvol_close(lvol2, close_cb, NULL); spdk_lvol_close(lvol2, op_complete, NULL);
spdk_lvol_destroy(lvol2, destroy_cb, NULL); spdk_lvol_destroy(lvol2, op_complete, NULL);
/* Simulate creating two lvols with same name simultaneously. */ /* Simulate creating two lvols with same name simultaneously. */
lvol = calloc(1, sizeof(*lvol)); lvol = calloc(1, sizeof(*lvol));
@ -1708,11 +1690,11 @@ lvol_names(void)
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
lvol = g_lvol; lvol = g_lvol;
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
spdk_lvol_destroy(lvol, destroy_cb, NULL); spdk_lvol_destroy(lvol, op_complete, NULL);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1768,23 +1750,23 @@ lvol_rename(void)
lvol2 = g_lvol; lvol2 = g_lvol;
/* Trying to rename lvol with not existing name */ /* Trying to rename lvol with not existing name */
spdk_lvol_rename(lvol, "lvol_new", lvol_op_complete, NULL); spdk_lvol_rename(lvol, "lvol_new", op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
CU_ASSERT_STRING_EQUAL(lvol->name, "lvol_new"); CU_ASSERT_STRING_EQUAL(lvol->name, "lvol_new");
/* Trying to rename lvol with other lvol name */ /* Trying to rename lvol with other lvol name */
spdk_lvol_rename(lvol2, "lvol_new", lvol_op_complete, NULL); spdk_lvol_rename(lvol2, "lvol_new", op_complete, NULL);
CU_ASSERT(g_lvserrno == -EEXIST); CU_ASSERT(g_lvserrno == -EEXIST);
CU_ASSERT_STRING_NOT_EQUAL(lvol2->name, "lvol_new"); CU_ASSERT_STRING_NOT_EQUAL(lvol2->name, "lvol_new");
spdk_lvol_close(lvol, close_cb, NULL); spdk_lvol_close(lvol, op_complete, NULL);
spdk_lvol_destroy(lvol, lvol_op_complete, NULL); spdk_lvol_destroy(lvol, op_complete, NULL);
spdk_lvol_close(lvol2, close_cb, NULL); spdk_lvol_close(lvol2, op_complete, NULL);
spdk_lvol_destroy(lvol2, lvol_op_complete, NULL); spdk_lvol_destroy(lvol2, op_complete, NULL);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1821,17 +1803,17 @@ lvs_rename(void)
lvs2 = g_lvol_store; lvs2 = g_lvol_store;
/* Trying to rename lvs with new name */ /* Trying to rename lvs with new name */
spdk_lvs_rename(lvs, "new_lvs_name", lvol_store_op_complete, NULL); spdk_lvs_rename(lvs, "new_lvs_name", op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name"); CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name");
/* Trying to rename lvs with name lvs already has */ /* Trying to rename lvs with name lvs already has */
spdk_lvs_rename(lvs, "new_lvs_name", lvol_store_op_complete, NULL); spdk_lvs_rename(lvs, "new_lvs_name", op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name"); CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name");
/* Trying to rename lvs with name already existing */ /* Trying to rename lvs with name already existing */
spdk_lvs_rename(lvs2, "new_lvs_name", lvol_store_op_complete, NULL); spdk_lvs_rename(lvs2, "new_lvs_name", op_complete, NULL);
CU_ASSERT(g_lvserrno == -EEXIST); CU_ASSERT(g_lvserrno == -EEXIST);
CU_ASSERT_STRING_EQUAL(lvs2->name, "unimportant_lvs_name"); CU_ASSERT_STRING_EQUAL(lvs2->name, "unimportant_lvs_name");
@ -1840,7 +1822,7 @@ lvs_rename(void)
snprintf(lvs2->new_name, sizeof(lvs2->new_name), "another_new_lvs_name"); snprintf(lvs2->new_name, sizeof(lvs2->new_name), "another_new_lvs_name");
CU_ASSERT_STRING_EQUAL(lvs2->new_name, "another_new_lvs_name"); CU_ASSERT_STRING_EQUAL(lvs2->new_name, "another_new_lvs_name");
/* Start second process */ /* Start second process */
spdk_lvs_rename(lvs, "another_new_lvs_name", lvol_store_op_complete, NULL); spdk_lvs_rename(lvs, "another_new_lvs_name", op_complete, NULL);
CU_ASSERT(g_lvserrno == -EEXIST); CU_ASSERT(g_lvserrno == -EEXIST);
CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name"); CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name");
/* reverting lvs2 new name to proper value */ /* reverting lvs2 new name to proper value */
@ -1849,20 +1831,20 @@ lvs_rename(void)
/* Simulate error while lvs rename */ /* Simulate error while lvs rename */
g_lvs_rename_blob_open_error = true; g_lvs_rename_blob_open_error = true;
spdk_lvs_rename(lvs, "complete_new_lvs_name", lvol_store_op_complete, NULL); spdk_lvs_rename(lvs, "complete_new_lvs_name", op_complete, NULL);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name"); CU_ASSERT_STRING_EQUAL(lvs->name, "new_lvs_name");
CU_ASSERT_STRING_EQUAL(lvs->new_name, "new_lvs_name"); CU_ASSERT_STRING_EQUAL(lvs->new_name, "new_lvs_name");
g_lvs_rename_blob_open_error = false; g_lvs_rename_blob_open_error = false;
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_destroy(lvs2, lvol_store_op_complete, NULL); rc = spdk_lvs_destroy(lvs2, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1899,24 +1881,24 @@ static void lvol_refcnt(void)
CU_ASSERT(lvol->ref_count == 2); CU_ASSERT(lvol->ref_count == 2);
/* Trying to destroy lvol while its open should fail */ /* Trying to destroy lvol while its open should fail */
spdk_lvol_destroy(lvol, lvol_op_complete, NULL); spdk_lvol_destroy(lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
spdk_lvol_close(lvol, lvol_op_complete, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(lvol->ref_count == 1); CU_ASSERT(lvol->ref_count == 1);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_close(lvol, lvol_op_complete, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(lvol->ref_count == 0); CU_ASSERT(lvol->ref_count == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
/* Try to close already closed lvol */ /* Try to close already closed lvol */
spdk_lvol_close(lvol, lvol_op_complete, NULL); spdk_lvol_close(lvol, op_complete, NULL);
CU_ASSERT(lvol->ref_count == 0); CU_ASSERT(lvol->ref_count == 0);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -1953,9 +1935,9 @@ lvol_create_thin_provisioned(void)
CU_ASSERT(g_lvol->blob->thin_provisioned == false); CU_ASSERT(g_lvol->blob->thin_provisioned == false);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_create(g_lvol_store, "lvol", 10, true, LVOL_CLEAR_WITH_DEFAULT, spdk_lvol_create(g_lvol_store, "lvol", 10, true, LVOL_CLEAR_WITH_DEFAULT,
@ -1965,13 +1947,13 @@ lvol_create_thin_provisioned(void)
CU_ASSERT(g_lvol->blob->thin_provisioned == true); CU_ASSERT(g_lvol->blob->thin_provisioned == true);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -2003,20 +1985,20 @@ lvol_inflate(void)
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
g_inflate_rc = -1; g_inflate_rc = -1;
spdk_lvol_inflate(g_lvol, lvol_op_complete, NULL); spdk_lvol_inflate(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
g_inflate_rc = 0; g_inflate_rc = 0;
spdk_lvol_inflate(g_lvol, lvol_op_complete, NULL); spdk_lvol_inflate(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;
@ -2053,20 +2035,20 @@ lvol_decouple_parent(void)
SPDK_CU_ASSERT_FATAL(g_lvol != NULL); SPDK_CU_ASSERT_FATAL(g_lvol != NULL);
g_inflate_rc = -1; g_inflate_rc = -1;
spdk_lvol_decouple_parent(g_lvol, lvol_op_complete, NULL); spdk_lvol_decouple_parent(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno != 0); CU_ASSERT(g_lvserrno != 0);
g_inflate_rc = 0; g_inflate_rc = 0;
spdk_lvol_decouple_parent(g_lvol, lvol_op_complete, NULL); spdk_lvol_decouple_parent(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_close(g_lvol, close_cb, NULL); spdk_lvol_close(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
spdk_lvol_destroy(g_lvol, destroy_cb, NULL); spdk_lvol_destroy(g_lvol, op_complete, NULL);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvserrno = -1; g_lvserrno = -1;
rc = spdk_lvs_unload(g_lvol_store, lvol_store_op_complete, NULL); rc = spdk_lvs_unload(g_lvol_store, op_complete, NULL);
CU_ASSERT(rc == 0); CU_ASSERT(rc == 0);
CU_ASSERT(g_lvserrno == 0); CU_ASSERT(g_lvserrno == 0);
g_lvol_store = NULL; g_lvol_store = NULL;