From f7e461942e6f14bb841d2c434684bb203fe79cbd Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 17 Dec 2018 15:18:47 -0700 Subject: [PATCH] test: Use ut_multithread framework in blob unit test Change-Id: Ibc6d3ee1881943a9327a0512ad28de9d254ac48c Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/437600 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ziye Yang Reviewed-by: Shuhei Matsumoto Reviewed-by: Darek Stojaczyk --- test/unit/lib/blob/blob.c/blob_ut.c | 635 +++++++++++++++++++++++++++- 1 file changed, 619 insertions(+), 16 deletions(-) diff --git a/test/unit/lib/blob/blob.c/blob_ut.c b/test/unit/lib/blob/blob.c/blob_ut.c index fbde97ced2..04e1f8bbfb 100644 --- a/test/unit/lib/blob/blob.c/blob_ut.c +++ b/test/unit/lib/blob/blob.c/blob_ut.c @@ -38,7 +38,7 @@ #include "spdk/string.h" #include "spdk_internal/thread.h" -#include "common/lib/test_env.c" +#include "common/lib/ut_multithread.c" #include "../bs_dev_common.c" #include "blob/blobstore.c" #include "blob/request.c" @@ -78,7 +78,6 @@ struct spdk_bs_super_block_ver1 { } __attribute__((packed)); SPDK_STATIC_ASSERT(sizeof(struct spdk_bs_super_block_ver1) == 0x1000, "Invalid super block size"); - static void _get_xattr_value(void *arg, const char *name, const void **value, size_t *value_len) @@ -167,14 +166,17 @@ blob_init(void) /* should fail for an unsupported blocklen */ dev->blocklen = 500; spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -189,31 +191,37 @@ blob_super(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; /* Get the super blob without having set one */ spdk_bs_get_super(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -ENOENT); CU_ASSERT(g_blobid == SPDK_BLOBID_INVALID); /* Create a blob */ spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; /* Set the blob as the super blob */ spdk_bs_set_super(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Get the super blob */ spdk_bs_get_super(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(blobid == g_blobid); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -229,16 +237,19 @@ blob_open(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -248,10 +259,12 @@ blob_open(void) /* Try to open file again. It should return success. */ spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(blob == g_blob); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* @@ -260,6 +273,7 @@ blob_open(void) */ blob = g_blob; spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* @@ -267,14 +281,17 @@ blob_open(void) * where the file is opened, closed, then re-opened again. */ spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -291,6 +308,7 @@ blob_create(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -301,17 +319,20 @@ blob_create(void) opts.num_clusters = 10; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; CU_ASSERT(spdk_blob_get_num_clusters(blob) == 10) spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Create blob with 0 clusters */ @@ -320,33 +341,39 @@ blob_create(void) opts.num_clusters = 0; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; CU_ASSERT(spdk_blob_get_num_clusters(blob) == 0) spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Create blob with default options (opts == NULL) */ spdk_bs_create_blob_ext(bs, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; CU_ASSERT(spdk_blob_get_num_clusters(blob) == 0) spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Try to create blob with size larger than blobstore */ @@ -355,9 +382,11 @@ blob_create(void) opts.num_clusters = bs->total_clusters + 1; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -ENOSPC); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -379,6 +408,7 @@ blob_create_internal(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -393,11 +423,13 @@ blob_create_internal(void) internal_xattrs.ctx = &g_ctx; _spdk_bs_create_blob(bs, &opts, &internal_xattrs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -430,16 +462,19 @@ blob_create_internal(void) CU_ASSERT(rc != 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Create blob with NULL internal options */ _spdk_bs_create_blob(bs, NULL, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); CU_ASSERT(TAILQ_FIRST(&g_blob->xattrs_internal) == NULL); @@ -447,9 +482,11 @@ blob_create_internal(void) blob = g_blob; spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -471,6 +508,7 @@ blob_thin_provision(void) /* Initialize a new blob store */ spdk_bs_init(dev, &bs_opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -483,11 +521,13 @@ blob_thin_provision(void) opts.num_clusters = 10; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -505,21 +545,25 @@ blob_thin_provision(void) dev = init_dev(); snprintf(bs_opts.bstype.bstype, sizeof(bs_opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, &bs_opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; CU_ASSERT(blob->invalid_flags & SPDK_BLOB_THIN_PROV); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -544,6 +588,7 @@ blob_snapshot(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -553,11 +598,13 @@ blob_snapshot(void) opts.num_clusters = 10; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -566,12 +613,14 @@ blob_snapshot(void) /* Create snapshot from blob */ CU_ASSERT_EQUAL(_get_snapshots_count(bs), 0); spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT_EQUAL(_get_snapshots_count(bs), 1); snapshotid = g_blobid; spdk_bs_open_blob(bs, snapshotid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot = g_blob; @@ -590,6 +639,7 @@ blob_snapshot(void) xattrs.count = 3; xattrs.ctx = &g_ctx; spdk_bs_create_snapshot(bs, blobid, &xattrs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT_EQUAL(_get_snapshots_count(bs), 2); @@ -634,11 +684,13 @@ blob_snapshot(void) /* Try to create snapshot from snapshot */ spdk_bs_create_snapshot(bs, snapshotid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); CU_ASSERT(g_blobid == SPDK_BLOBID_INVALID); CU_ASSERT_EQUAL(_get_snapshots_count(bs), 2); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); @@ -646,20 +698,25 @@ blob_snapshot(void) CU_ASSERT_EQUAL(_get_snapshots_count(bs), 2); spdk_blob_close(snapshot2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, snapshotid2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT_EQUAL(_get_snapshots_count(bs), 1); spdk_blob_close(snapshot, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT_EQUAL(_get_snapshots_count(bs), 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -667,6 +724,7 @@ blob_snapshot(void) static void blob_snapshot_freeze_io(void) { + struct spdk_thread *thread; struct spdk_io_channel *channel; struct spdk_bs_channel *bs_channel; struct spdk_blob_store *bs; @@ -689,6 +747,7 @@ blob_snapshot_freeze_io(void) /* Test freeze I/O during snapshot */ spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -702,27 +761,29 @@ blob_snapshot_freeze_io(void) opts.thin_provision = false; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; CU_ASSERT(spdk_blob_get_num_clusters(blob) == 10); - /* Enable explicitly calling callbacks. On each read/write to back device - * execution will stop and wait until _bs_flush_scheduler is called */ - g_scheduler_delay = true; - spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); /* This is implementation specific. * Flag 'frozen_io' is set in _spdk_bs_snapshot_freeze_cpl callback. * Four async I/O operations happen before that. */ - - _bs_flush_scheduler(4); + thread = spdk_get_thread(); + spdk_set_thread(NULL); + spdk_thread_poll(thread, 1); + spdk_thread_poll(thread, 1); + spdk_thread_poll(thread, 1); + spdk_set_thread(thread); CU_ASSERT(TAILQ_EMPTY(&bs_channel->queued_io)); @@ -738,10 +799,8 @@ blob_snapshot_freeze_io(void) CU_ASSERT(memcmp(payload_zero, &g_dev_buffer[blob->active.clusters[0]*SPDK_BS_PAGE_SIZE], SPDK_BS_PAGE_SIZE) == 0); - /* Disable scheduler delay. - * Finish all operations including spdk_bs_create_snapshot */ - g_scheduler_delay = false; - _bs_flush_scheduler(1); + /* Finish all operations including spdk_bs_create_snapshot */ + poll_threads(); /* Verify snapshot */ CU_ASSERT(g_bserrno == 0); @@ -752,15 +811,19 @@ blob_snapshot_freeze_io(void) /* Verify that postponed I/O completed successfully by comparing payload */ spdk_blob_io_read(blob, channel, payload_read, 0, num_of_pages, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, num_of_pages * SPDK_BS_PAGE_SIZE) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -781,6 +844,7 @@ blob_clone(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -791,11 +855,13 @@ blob_clone(void) opts.num_clusters = 10; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -803,11 +869,13 @@ blob_clone(void) /* Create snapshot */ spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshotid = g_blobid; spdk_bs_open_blob(bs, snapshotid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot = g_blob; @@ -816,6 +884,7 @@ blob_clone(void) CU_ASSERT(spdk_blob_get_num_clusters(snapshot) == 10); spdk_blob_close(snapshot, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Create clone from snapshot with xattrs */ @@ -825,11 +894,13 @@ blob_clone(void) xattrs.ctx = &g_ctx; spdk_bs_create_clone(bs, snapshotid, &xattrs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); cloneid = g_blobid; spdk_bs_open_blob(bs, cloneid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); clone = g_blob; @@ -857,25 +928,30 @@ blob_clone(void) spdk_blob_close(clone, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Try to create clone from not read only blob */ spdk_bs_create_clone(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); CU_ASSERT(g_blobid == SPDK_BLOBID_INVALID); /* Mark blob as read only */ spdk_blob_set_read_only(blob); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Create clone from read only blob */ spdk_bs_create_clone(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); cloneid = g_blobid; spdk_bs_open_blob(bs, cloneid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); clone = g_blob; @@ -884,12 +960,15 @@ blob_clone(void) CU_ASSERT(spdk_blob_get_num_clusters(clone) == 10); spdk_blob_close(clone, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -909,6 +988,7 @@ _blob_inflate(bool decouple_parent) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -923,11 +1003,13 @@ _blob_inflate(bool decouple_parent) opts.thin_provision = true; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -939,15 +1021,18 @@ _blob_inflate(bool decouple_parent) if (decouple_parent) { /* Decouple parent of blob with no parent (should fail) */ spdk_bs_blob_decouple_parent(bs, channel, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); } else { /* Inflate of thin blob with no parent should made it thick */ spdk_bs_inflate_blob(bs, channel, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(spdk_blob_is_thin_provisioned(blob) == false); } spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshotid = g_blobid; @@ -956,6 +1041,7 @@ _blob_inflate(bool decouple_parent) CU_ASSERT(spdk_blob_get_num_clusters(blob) == 10) spdk_bs_open_blob(bs, snapshotid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot = g_blob; @@ -964,6 +1050,7 @@ _blob_inflate(bool decouple_parent) CU_ASSERT(spdk_blob_get_num_clusters(snapshot) == 10); spdk_blob_close(snapshot, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); free_clusters = spdk_bs_free_cluster_count(bs); @@ -972,12 +1059,14 @@ _blob_inflate(bool decouple_parent) if (!decouple_parent) { /* Do full blob inflation */ spdk_bs_inflate_blob(bs, channel, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* all 10 clusters should be allocated */ CU_ASSERT(spdk_bs_free_cluster_count(bs) == free_clusters - 10); } else { /* Decouple parent of blob */ spdk_bs_blob_decouple_parent(bs, channel, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* when only parent is removed, none of the clusters should be allocated */ CU_ASSERT(spdk_bs_free_cluster_count(bs) == free_clusters); @@ -985,19 +1074,23 @@ _blob_inflate(bool decouple_parent) /* Now, it should be possible to delete snapshot */ spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(spdk_blob_get_num_clusters(blob) == 10) CU_ASSERT(spdk_blob_is_thin_provisioned(blob) == decouple_parent); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; spdk_bs_free_io_channel(channel); + poll_threads(); } static void @@ -1017,24 +1110,29 @@ blob_delete(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; /* Create a blob and then delete it. */ spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid > 0); blobid = g_blobid; spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Try to open the blob */ spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -ENOENT); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1051,18 +1149,21 @@ blob_resize(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; free_clusters = spdk_bs_free_cluster_count(bs); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -1070,11 +1171,13 @@ blob_resize(void) /* Confirm that resize fails if blob is marked read-only. */ blob->md_ro = true; spdk_blob_resize(blob, 5, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EPERM); blob->md_ro = false; /* The blob started at 0 clusters. Resize it to be 5. */ spdk_blob_resize(blob, 5, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT((free_clusters - 5) == spdk_bs_free_cluster_count(bs)); @@ -1082,31 +1185,38 @@ blob_resize(void) * the old clusters until the blob is synced. */ spdk_blob_resize(blob, 3, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Verify there are still 5 clusters in use */ CU_ASSERT((free_clusters - 5) == spdk_bs_free_cluster_count(bs)); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Now there are only 3 clusters in use */ CU_ASSERT((free_clusters - 3) == spdk_bs_free_cluster_count(bs)); /* Resize the blob to be 10 clusters. Growth takes effect immediately. */ spdk_blob_resize(blob, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT((free_clusters - 10) == spdk_bs_free_cluster_count(bs)); /* Try to resize the blob to size larger than blobstore. */ spdk_blob_resize(blob, bs->total_clusters + 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -ENOSPC); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1126,16 +1236,19 @@ blob_read_only(void) snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "TESTTYPE"); spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -1147,15 +1260,18 @@ blob_read_only(void) CU_ASSERT(blob->md_ro == false); spdk_blob_sync_md(blob, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(blob->data_ro == true); CU_ASSERT(blob->md_ro == true); CU_ASSERT(blob->data_ro_flags & SPDK_BLOB_READ_ONLY); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -1165,9 +1281,11 @@ blob_read_only(void) CU_ASSERT(blob->data_ro_flags & SPDK_BLOB_READ_ONLY); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -1177,10 +1295,12 @@ blob_read_only(void) dev = init_dev(); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -1190,9 +1310,11 @@ blob_read_only(void) CU_ASSERT(blob->data_ro_flags & SPDK_BLOB_READ_ONLY); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } @@ -1207,6 +1329,7 @@ channel_ops(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1215,8 +1338,10 @@ channel_ops(void) CU_ASSERT(channel != NULL); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1235,6 +1360,7 @@ blob_write(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1245,49 +1371,60 @@ blob_write(void) CU_ASSERT(channel != NULL); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; /* Write to a blob with 0 size */ spdk_blob_io_write(blob, channel, payload, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); /* Resize the blob */ spdk_blob_resize(blob, 5, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Confirm that write fails if blob is marked read-only. */ blob->data_ro = true; spdk_blob_io_write(blob, channel, payload, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EPERM); blob->data_ro = false; /* Write to the blob */ spdk_blob_io_write(blob, channel, payload, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Write starting beyond the end */ spdk_blob_io_write(blob, channel, payload, 5 * pages_per_cluster, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); /* Write starting at a valid location but going off the end */ spdk_blob_io_write(blob, channel, payload, 4 * pages_per_cluster, pages_per_cluster + 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1306,6 +1443,7 @@ blob_read(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1316,49 +1454,60 @@ blob_read(void) CU_ASSERT(channel != NULL); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; /* Read from a blob with 0 size */ spdk_blob_io_read(blob, channel, payload, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); /* Resize the blob */ spdk_blob_resize(blob, 5, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Confirm that read passes if blob is marked read-only. */ blob->data_ro = true; spdk_blob_io_read(blob, channel, payload, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob->data_ro = false; /* Read from the blob */ spdk_blob_io_read(blob, channel, payload, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Read starting beyond the end */ spdk_blob_io_read(blob, channel, payload, 5 * pages_per_cluster, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); /* Read starting at a valid location but going off the end */ spdk_blob_io_read(blob, channel, payload, 4 * pages_per_cluster, pages_per_cluster + 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1377,6 +1526,7 @@ blob_rw_verify(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1385,33 +1535,41 @@ blob_rw_verify(void) CU_ASSERT(channel != NULL); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; spdk_blob_resize(blob, 32, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_write, 0xE5, sizeof(payload_write)); spdk_blob_io_write(blob, channel, payload_write, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, 4 * 4096) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1434,6 +1592,7 @@ blob_rw_verify_iov(void) memset(g_dev_buffer, 0, DEV_BUFFER_SIZE); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1442,16 +1601,19 @@ blob_rw_verify_iov(void) CU_ASSERT(channel != NULL); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; spdk_blob_resize(blob, 2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* @@ -1476,6 +1638,7 @@ blob_rw_verify_iov(void) * will get written to the first cluster, the last 4 to the second cluster. */ spdk_blob_io_writev(blob, channel, iov_write, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0xAA, sizeof(payload_read)); @@ -1486,6 +1649,7 @@ blob_rw_verify_iov(void) iov_read[2].iov_base = payload_read + 7 * 4096; iov_read[2].iov_len = 3 * 4096; spdk_blob_io_readv(blob, channel, iov_read, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, 10 * 4096) == 0); @@ -1496,11 +1660,14 @@ blob_rw_verify_iov(void) free(buf); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1535,6 +1702,7 @@ blob_rw_verify_iov_nomem(void) memset(g_dev_buffer, 0, DEV_BUFFER_SIZE); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1543,16 +1711,19 @@ blob_rw_verify_iov_nomem(void) CU_ASSERT(channel != NULL); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; spdk_blob_resize(blob, 2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* @@ -1568,16 +1739,20 @@ blob_rw_verify_iov_nomem(void) MOCK_SET(calloc, NULL); req_count = bs_channel_get_req_count(channel); spdk_blob_io_writev(blob, channel, iov_write, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno = -ENOMEM); CU_ASSERT(req_count == bs_channel_get_req_count(channel)); MOCK_CLEAR(calloc); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1599,6 +1774,7 @@ blob_rw_iov_read_only(void) memset(g_dev_buffer, 0, DEV_BUFFER_SIZE); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1607,16 +1783,19 @@ blob_rw_iov_read_only(void) CU_ASSERT(channel != NULL); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; spdk_blob_resize(blob, 2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Verify that writev failed if read_only flag is set. */ @@ -1624,20 +1803,25 @@ blob_rw_iov_read_only(void) iov_write.iov_base = payload_write; iov_write.iov_len = sizeof(payload_write); spdk_blob_io_writev(blob, channel, &iov_write, 1, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EPERM); /* Verify that reads pass if data_ro flag is set. */ iov_read.iov_base = payload_read; iov_read.iov_len = sizeof(payload_read); spdk_blob_io_readv(blob, channel, &iov_read, 1, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -1655,6 +1839,7 @@ _blob_io_read_no_split(struct spdk_blob *blob, struct spdk_io_channel *channel, buf = payload; for (i = 0; i < length; i++) { spdk_blob_io_read(blob, channel, buf, i + offset, 1, blob_op_complete, NULL); + poll_threads(); if (g_bserrno != 0) { /* Pass the error code up */ break; @@ -1678,6 +1863,7 @@ _blob_io_write_no_split(struct spdk_blob *blob, struct spdk_io_channel *channel, buf = payload; for (i = 0; i < length; i++) { spdk_blob_io_write(blob, channel, buf, i + offset, 1, blob_op_complete, NULL); + poll_threads(); if (g_bserrno != 0) { /* Pass the error code up */ break; @@ -1713,6 +1899,7 @@ blob_operation_split_rw(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1747,11 +1934,13 @@ blob_operation_split_rw(void) opts.num_clusters = 5; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -1761,22 +1950,26 @@ blob_operation_split_rw(void) /* Initial read should return zeroed payload */ memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(spdk_mem_all_zero(payload_read, payload_size)); /* Fill whole blob except last page */ spdk_blob_io_write(blob, channel, payload_pattern, 0, pages_per_payload - 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Write last page with a pattern */ spdk_blob_io_write(blob, channel, payload_pattern, pages_per_payload - 1, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Read whole blob and check consistency */ memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, payload_size - page_size) == 0); CU_ASSERT(memcmp(payload_pattern, payload_read + payload_size - page_size, page_size) == 0); @@ -1784,16 +1977,19 @@ blob_operation_split_rw(void) /* Fill whole blob except first page */ spdk_blob_io_write(blob, channel, payload_pattern, 1, pages_per_payload - 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Write first page with a pattern */ spdk_blob_io_write(blob, channel, payload_pattern, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Read whole blob and check consistency */ memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read + page_size, payload_size - page_size) == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, page_size) == 0); @@ -1804,30 +2000,38 @@ blob_operation_split_rw(void) /* 1. Read test. */ _blob_io_write_no_split(blob, channel, payload_pattern, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, payload_size) == 0); /* 2. Write test. */ spdk_blob_io_write(blob, channel, payload_pattern, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0xFF, payload_size); _blob_io_read_no_split(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, payload_size) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -1866,6 +2070,7 @@ blob_operation_split_rw_iov(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -1905,11 +2110,13 @@ blob_operation_split_rw_iov(void) opts.num_clusters = 5; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -1923,6 +2130,7 @@ blob_operation_split_rw_iov(void) iov_read[1].iov_base = payload_read + cluster_size * 3; iov_read[1].iov_len = cluster_size * 2; spdk_blob_io_readv(blob, channel, iov_read, 2, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(spdk_mem_all_zero(payload_read, payload_size)); @@ -1933,6 +2141,7 @@ blob_operation_split_rw_iov(void) iov_write[1].iov_base = payload_pattern; iov_write[1].iov_len = page_size; spdk_blob_io_writev(blob, channel, iov_write, 2, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Read whole blob and check consistency */ @@ -1942,6 +2151,7 @@ blob_operation_split_rw_iov(void) iov_read[1].iov_base = payload_read + cluster_size * 2; iov_read[1].iov_len = cluster_size * 3; spdk_blob_io_readv(blob, channel, iov_read, 2, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, payload_size - page_size) == 0); CU_ASSERT(memcmp(payload_pattern, payload_read + payload_size - page_size, page_size) == 0); @@ -1953,6 +2163,7 @@ blob_operation_split_rw_iov(void) iov_write[1].iov_base = payload_pattern; iov_write[1].iov_len = payload_size - page_size; spdk_blob_io_writev(blob, channel, iov_write, 2, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Read whole blob and check consistency */ @@ -1962,6 +2173,7 @@ blob_operation_split_rw_iov(void) iov_read[1].iov_base = payload_read + cluster_size * 4; iov_read[1].iov_len = cluster_size; spdk_blob_io_readv(blob, channel, iov_read, 2, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read + page_size, payload_size - page_size) == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, page_size) == 0); @@ -1972,6 +2184,7 @@ blob_operation_split_rw_iov(void) /* 1. Read test. */ _blob_io_write_no_split(blob, channel, payload_pattern, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0xFF, payload_size); @@ -1980,6 +2193,7 @@ blob_operation_split_rw_iov(void) iov_read[1].iov_base = payload_read + cluster_size; iov_read[1].iov_len = cluster_size * 4; spdk_blob_io_readv(blob, channel, iov_read, 2, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, payload_size) == 0); @@ -1989,10 +2203,12 @@ blob_operation_split_rw_iov(void) iov_write[1].iov_base = payload_read + cluster_size * 2; iov_write[1].iov_len = cluster_size * 3; spdk_blob_io_writev(blob, channel, iov_write, 2, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0xFF, payload_size); _blob_io_read_no_split(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_pattern, payload_read, payload_size) == 0); @@ -2000,9 +2216,11 @@ blob_operation_split_rw_iov(void) CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -2028,6 +2246,7 @@ blob_unmap(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -2039,16 +2258,19 @@ blob_unmap(void) opts.num_clusters = 10; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; spdk_blob_resize(blob, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload, 0, sizeof(payload)); @@ -2067,6 +2289,7 @@ blob_unmap(void) payload[0] = 0; spdk_blob_io_read(blob, channel, &payload, i * SPDK_BLOB_OPTS_CLUSTER_SZ / 4096, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(payload[0] == 0xFF); } @@ -2080,9 +2303,11 @@ blob_unmap(void) /* Unmap clusters by resizing to 0 */ spdk_blob_resize(blob, 0, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Confirm that only 'allocated' clusters were unmapped */ @@ -2102,11 +2327,14 @@ blob_unmap(void) } spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2123,30 +2351,36 @@ blob_iter(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_iter_first(bs, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_blob == NULL); CU_ASSERT(g_bserrno == -ENOENT); spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_iter_first(bs, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_blob != NULL); CU_ASSERT(g_bserrno == 0); blob = g_blob; CU_ASSERT(spdk_blob_get_id(blob) == blobid); spdk_bs_iter_next(bs, blob, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_blob == NULL); CU_ASSERT(g_bserrno == -ENOENT); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2168,16 +2402,19 @@ blob_xattr(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -2256,19 +2493,23 @@ blob_xattr(void) SPDK_BLOB_INTERNAL_XATTR) spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); /* Check if xattrs are persisted */ dev = init_dev(); spdk_bs_load(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -2309,27 +2550,32 @@ bs_load(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Try to open a blobid that does not exist */ spdk_bs_open_blob(g_bs, 0, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -ENOENT); CU_ASSERT(g_blob == NULL); /* Create a blob */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; /* Try again to open valid blob but without the upper bit set */ spdk_bs_open_blob(g_bs, blobid & 0xFFFFFFFF, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -ENOENT); CU_ASSERT(g_blob == NULL); @@ -2343,9 +2589,11 @@ bs_load(void) /* Resize the blob */ spdk_blob_resize(blob, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob = NULL; g_blob = NULL; @@ -2353,6 +2601,7 @@ bs_load(void) /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -2365,6 +2614,7 @@ bs_load(void) dev = init_dev(); dev->blocklen = SPDK_BS_PAGE_SIZE * 2; spdk_bs_load(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); /* Load should when max_md_ops is set to zero */ @@ -2372,6 +2622,7 @@ bs_load(void) spdk_bs_opts_init(&opts); opts.max_md_ops = 0; spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); /* Load should when max_channel_ops is set to zero */ @@ -2379,6 +2630,7 @@ bs_load(void) spdk_bs_opts_init(&opts); opts.max_channel_ops = 0; spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); /* Load an existing blob store */ @@ -2386,6 +2638,7 @@ bs_load(void) spdk_bs_opts_init(&opts); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -2394,6 +2647,7 @@ bs_load(void) CU_ASSERT(super_block->size == dev->blockcnt * dev->blocklen); spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -2416,11 +2670,13 @@ bs_load(void) CU_ASSERT(spdk_blob_get_num_clusters(blob) == 10); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob = NULL; g_blob = NULL; spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -2431,6 +2687,7 @@ bs_load(void) spdk_bs_opts_init(&opts); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EILSEQ); @@ -2441,9 +2698,11 @@ bs_load(void) spdk_bs_opts_init(&opts); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); /* Test compatibility mode */ @@ -2455,11 +2714,13 @@ bs_load(void) spdk_bs_opts_init(&opts); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Create a blob */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); @@ -2468,6 +2729,7 @@ bs_load(void) CU_ASSERT(super_block->clean == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(super_block->clean == 1); g_bs = NULL; @@ -2491,6 +2753,7 @@ bs_load_custom_cluster_size(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); cluster_sz = g_bs->cluster_sz; @@ -2498,6 +2761,7 @@ bs_load_custom_cluster_size(void) /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -2511,6 +2775,7 @@ bs_load_custom_cluster_size(void) spdk_bs_opts_init(&opts); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Compare cluster size and number to one after initialization */ @@ -2522,6 +2787,7 @@ bs_load_custom_cluster_size(void) CU_ASSERT(super_block->size == dev->blockcnt * dev->blocklen); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(super_block->clean == 1); g_bs = NULL; @@ -2539,11 +2805,13 @@ bs_type(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -2553,15 +2821,18 @@ bs_type(void) dev = init_dev(); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "NONEXISTING"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); /* Load with empty blobstore type */ dev = init_dev(); memset(opts.bstype.bstype, 0, sizeof(opts.bstype.bstype)); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -2569,10 +2840,12 @@ bs_type(void) dev = init_dev(); memset(opts.bstype.bstype, 0, sizeof(opts.bstype.bstype)); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -2580,15 +2853,18 @@ bs_type(void) dev = init_dev(); snprintf(opts.bstype.bstype, sizeof(opts.bstype.bstype), "NONEXISTING"); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); /* Load with empty blobstore type */ dev = init_dev(); memset(opts.bstype.bstype, 0, sizeof(opts.bstype.bstype)); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2607,11 +2883,13 @@ bs_super_block(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -2624,6 +2902,7 @@ bs_super_block(void) dev = init_dev(); memset(opts.bstype.bstype, 0, sizeof(opts.bstype.bstype)); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); /* Create a new blob store with super block version 1 */ @@ -2646,9 +2925,11 @@ bs_super_block(void) memset(opts.bstype.bstype, 0, sizeof(opts.bstype.bstype)); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2667,6 +2948,7 @@ bs_unload(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -2674,12 +2956,14 @@ bs_unload(void) /* Create a blob and open it. */ g_bserrno = -1; spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid > 0); blobid = g_blobid; g_bserrno = -1; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -2687,16 +2971,19 @@ bs_unload(void) /* Try to unload blobstore, should fail with open blob */ g_bserrno = -1; spdk_bs_unload(bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EBUSY); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Close the blob, then successfully unload blobstore */ g_bserrno = -1; spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bserrno = -1; spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2719,6 +3006,7 @@ bs_cluster_sz(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); SPDK_CU_ASSERT_FATAL(g_bs == NULL); @@ -2732,6 +3020,7 @@ bs_cluster_sz(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -ENOMEM); SPDK_CU_ASSERT_FATAL(g_bs == NULL); @@ -2745,6 +3034,7 @@ bs_cluster_sz(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); SPDK_CU_ASSERT_FATAL(g_bs == NULL); @@ -2756,6 +3046,7 @@ bs_cluster_sz(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -2763,6 +3054,7 @@ bs_cluster_sz(void) /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -2771,12 +3063,14 @@ bs_cluster_sz(void) dev = init_dev(); /* Load an existing blob store */ spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); CU_ASSERT(spdk_bs_get_cluster_size(g_bs) == cluster_sz); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2798,6 +3092,7 @@ bs_usable_clusters(void) spdk_bs_opts_init(&opts); spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -2805,12 +3100,14 @@ bs_usable_clusters(void) /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; dev = init_dev(); /* Load an existing blob store */ spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -2821,20 +3118,24 @@ bs_usable_clusters(void) g_bserrno = -1; g_blobid = SPDK_BLOBID_INVALID; spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); g_bserrno = -1; g_blob = NULL; spdk_bs_open_blob(g_bs, g_blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); spdk_blob_resize(g_blob, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bserrno = -1; spdk_blob_close(g_blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(spdk_bs_total_data_cluster_count(g_bs) == clusters); @@ -2842,17 +3143,20 @@ bs_usable_clusters(void) /* Reload the blob store to make sure that nothing changed */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; dev = init_dev(); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); CU_ASSERT(spdk_bs_total_data_cluster_count(g_bs) == clusters); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2882,6 +3186,7 @@ bs_resize_md(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -2891,6 +3196,7 @@ bs_resize_md(void) g_bserrno = -1; g_blobid = SPDK_BLOBID_INVALID; spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobids[i] = g_blobid; @@ -2899,6 +3205,7 @@ bs_resize_md(void) /* Unload the blob store */ g_bserrno = -1; spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Load an existing blob store */ @@ -2906,6 +3213,7 @@ bs_resize_md(void) g_bs = NULL; dev = init_dev(); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -2915,14 +3223,17 @@ bs_resize_md(void) g_bserrno = -1; g_blob = NULL; spdk_bs_open_blob(g_bs, blobids[i], blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); g_bserrno = -1; spdk_blob_close(g_blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -2937,12 +3248,14 @@ bs_destroy(void) dev = init_dev(); spdk_bs_opts_init(&opts); spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Destroy the blob store */ g_bserrno = -1; spdk_bs_destroy(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Loading an non-existent blob store should fail. */ @@ -2951,6 +3264,7 @@ bs_destroy(void) g_bserrno = 0; spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); } @@ -2975,6 +3289,7 @@ blob_serialize(void) spdk_bs_opts_init(&opts); opts.cluster_sz = dev->blocklen * 8; spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -2982,12 +3297,14 @@ blob_serialize(void) /* Create and open two blobs */ for (i = 0; i < 2; i++) { spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid[i] = g_blobid; /* Open a blob */ spdk_bs_open_blob(bs, blobid[i], blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob[i] = g_blob; @@ -3009,22 +3326,26 @@ blob_serialize(void) */ for (i = 0; i < 6; i++) { spdk_blob_resize(blob[i % 2], (i / 2) + 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } for (i = 0; i < 2; i++) { spdk_blob_sync_md(blob[i], blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } /* Close the blobs */ for (i = 0; i < 2; i++) { spdk_blob_close(blob[i], blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } /* Unload the blobstore */ spdk_bs_unload(bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -3034,6 +3355,7 @@ blob_serialize(void) dev = init_dev(); /* Load an existing blob store */ spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -3042,6 +3364,7 @@ blob_serialize(void) blob[i] = NULL; spdk_bs_open_blob(bs, blobid[i], blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob[i] = g_blob; @@ -3049,10 +3372,12 @@ blob_serialize(void) CU_ASSERT(spdk_blob_get_num_clusters(blob[i]) == 3); spdk_blob_close(blob[i], blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } spdk_bs_unload(bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -3071,21 +3396,25 @@ blob_crc(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_create_blob(bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); page_num = _spdk_bs_blobid_to_page(blobid); @@ -3094,14 +3423,17 @@ blob_crc(void) page->crc = 0; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); CU_ASSERT(g_blob == NULL); g_bserrno = 0; spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -3117,10 +3449,12 @@ super_block_crc(void) spdk_bs_opts_init(&opts); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -3131,6 +3465,7 @@ super_block_crc(void) /* Load an existing blob store */ g_bserrno = 0; spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EILSEQ); } @@ -3168,16 +3503,19 @@ blob_dirty_shutdown(void) spdk_bs_opts_init(&opts); /* Initialize a new blob store */ spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Create first blob */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid1 = g_blobid; spdk_bs_open_blob(g_bs, blobid1, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3192,10 +3530,12 @@ blob_dirty_shutdown(void) /* Resize the blob */ spdk_blob_resize(blob, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Set the blob as the super blob */ spdk_bs_set_super(g_bs, blobid1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); free_clusters = spdk_bs_free_cluster_count(g_bs); @@ -3212,14 +3552,17 @@ blob_dirty_shutdown(void) dev = init_dev(); spdk_bs_opts_init(&opts); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Get the super blob */ spdk_bs_get_super(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(blobid1 == g_blobid); spdk_bs_open_blob(g_bs, blobid1, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3237,11 +3580,13 @@ blob_dirty_shutdown(void) /* Resize the blob */ spdk_blob_resize(blob, 20, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); free_clusters = spdk_bs_free_cluster_count(g_bs); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob = NULL; g_blob = NULL; @@ -3255,9 +3600,11 @@ blob_dirty_shutdown(void) spdk_bs_opts_init(&opts); /* Load an existing blob store */ spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); spdk_bs_open_blob(g_bs, blobid1, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3265,6 +3612,7 @@ blob_dirty_shutdown(void) CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs)); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob = NULL; g_blob = NULL; @@ -3272,11 +3620,13 @@ blob_dirty_shutdown(void) /* Create second blob */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid2 = g_blobid; spdk_bs_open_blob(g_bs, blobid2, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3291,6 +3641,7 @@ blob_dirty_shutdown(void) /* Resize the blob */ spdk_blob_resize(blob, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); free_clusters = spdk_bs_free_cluster_count(g_bs); @@ -3307,9 +3658,11 @@ blob_dirty_shutdown(void) dev = init_dev(); spdk_bs_opts_init(&opts); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_open_blob(g_bs, blobid2, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3325,8 +3678,10 @@ blob_dirty_shutdown(void) CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs)); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(g_bs, blobid2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); free_clusters = spdk_bs_free_cluster_count(g_bs); @@ -3337,20 +3692,25 @@ blob_dirty_shutdown(void) dev = init_dev(); spdk_bs_opts_init(&opts); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_open_blob(g_bs, blobid2, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); CU_ASSERT(g_blob == NULL); spdk_bs_open_blob(g_bs, blobid1, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs)); spdk_blob_close(g_blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -3358,21 +3718,25 @@ blob_dirty_shutdown(void) dev = init_dev(); spdk_bs_opts_init(&opts); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Create second blob */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid2 = g_blobid; /* Create third blob */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid3 = g_blobid; spdk_bs_open_blob(g_bs, blobid2, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3386,11 +3750,13 @@ blob_dirty_shutdown(void) CU_ASSERT(rc == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); blob = NULL; g_blob = NULL; g_blobid = SPDK_BLOBID_INVALID; spdk_bs_open_blob(g_bs, blobid3, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3404,6 +3770,7 @@ blob_dirty_shutdown(void) CU_ASSERT(rc == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); blob = NULL; g_blob = NULL; g_blobid = SPDK_BLOBID_INVALID; @@ -3424,13 +3791,16 @@ blob_dirty_shutdown(void) dev = init_dev(); spdk_bs_opts_init(&opts); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_open_blob(g_bs, blobid2, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); CU_ASSERT(g_blob == NULL); spdk_bs_open_blob(g_bs, blobid3, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -3443,6 +3813,7 @@ blob_dirty_shutdown(void) g_blobid = SPDK_BLOBID_INVALID; spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -3461,36 +3832,43 @@ blob_flags(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Create three blobs - one each for testing invalid, data_ro and md_ro flags. */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid_invalid = g_blobid; spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid_data_ro = g_blobid; spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid_md_ro = g_blobid; spdk_bs_open_blob(g_bs, blobid_invalid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob_invalid = g_blob; spdk_bs_open_blob(g_bs, blobid_data_ro, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob_data_ro = g_blob; spdk_bs_open_blob(g_bs, blobid_md_ro, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob_md_ro = g_blob; @@ -3498,6 +3876,7 @@ blob_flags(void) /* Change the size of blob_data_ro to check if flags are serialized * when blob has non zero number of extents */ spdk_blob_resize(blob_data_ro, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Set the xattr to check if flags are serialized @@ -3514,24 +3893,30 @@ blob_flags(void) g_bserrno = -1; spdk_blob_sync_md(blob_invalid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bserrno = -1; spdk_blob_sync_md(blob_data_ro, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bserrno = -1; spdk_blob_sync_md(blob_md_ro, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bserrno = -1; spdk_blob_close(blob_invalid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob_invalid = NULL; g_bserrno = -1; spdk_blob_close(blob_data_ro, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob_data_ro = NULL; g_bserrno = -1; spdk_blob_close(blob_md_ro, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob_md_ro = NULL; @@ -3540,24 +3925,28 @@ blob_flags(void) /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; /* Load an existing blob store */ dev = init_dev(); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); g_blob = NULL; g_bserrno = 0; spdk_bs_open_blob(g_bs, blobid_invalid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); CU_ASSERT(g_blob == NULL); g_blob = NULL; g_bserrno = -1; spdk_bs_open_blob(g_bs, blobid_data_ro, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob_data_ro = g_blob; @@ -3569,6 +3958,7 @@ blob_flags(void) g_blob = NULL; g_bserrno = -1; spdk_bs_open_blob(g_bs, blobid_md_ro, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob_md_ro = g_blob; @@ -3577,14 +3967,18 @@ blob_flags(void) g_bserrno = -1; spdk_blob_sync_md(blob_md_ro, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(blob_data_ro, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(blob_md_ro, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } @@ -3601,11 +3995,13 @@ bs_version(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -3633,6 +4029,7 @@ bs_version(void) /* Load an existing blob store */ dev = init_dev(); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); CU_ASSERT(super->clean == 1); @@ -3643,12 +4040,14 @@ bs_version(void) * were allocated. */ spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; CU_ASSERT(super->version == 2); @@ -3657,18 +4056,22 @@ bs_version(void) dev = init_dev(); spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); g_blob = NULL; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); spdk_blob_close(g_blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; CU_ASSERT(super->version == 2); @@ -3691,6 +4094,7 @@ blob_set_xattrs(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -3704,11 +4108,13 @@ blob_set_xattrs(void) opts.xattrs.ctx = &g_ctx; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -3740,6 +4146,7 @@ blob_set_xattrs(void) CU_ASSERT(rc == -ENOENT); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob = NULL; g_blob = NULL; @@ -3753,6 +4160,7 @@ blob_set_xattrs(void) opts.xattrs.ctx = &g_ctx; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); @@ -3764,9 +4172,11 @@ blob_set_xattrs(void) opts.xattrs.ctx = NULL; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == -EINVAL); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -3785,6 +4195,7 @@ blob_thin_prov_alloc(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -3795,12 +4206,14 @@ blob_thin_prov_alloc(void) opts.thin_provision = true; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -3810,6 +4223,7 @@ blob_thin_prov_alloc(void) /* The blob started at 0 clusters. Resize it to be 5, but still unallocated. */ spdk_blob_resize(blob, 5, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); CU_ASSERT(blob->active.num_clusters == 5); @@ -3817,12 +4231,14 @@ blob_thin_prov_alloc(void) /* Grow it to 1TB - still unallocated */ spdk_blob_resize(blob, 262144, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); CU_ASSERT(blob->active.num_clusters == 262144); CU_ASSERT(spdk_blob_get_num_clusters(blob) == 262144); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Sync must not change anything */ CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); @@ -3835,12 +4251,14 @@ blob_thin_prov_alloc(void) /* Shrink the blob to 3 clusters - still unallocated */ spdk_blob_resize(blob, 3, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); CU_ASSERT(blob->active.num_clusters == 3); CU_ASSERT(spdk_blob_get_num_clusters(blob) == 3); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Sync must not change anything */ CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); @@ -3848,10 +4266,12 @@ blob_thin_prov_alloc(void) CU_ASSERT(spdk_blob_get_num_clusters(blob) == 3); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -3860,12 +4280,14 @@ blob_thin_prov_alloc(void) /* Load an existing blob store */ dev = init_dev(); spdk_bs_load(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -3875,12 +4297,15 @@ blob_thin_prov_alloc(void) CU_ASSERT(blob->active.num_clusters == 3); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -3898,6 +4323,7 @@ blob_insert_cluster_msg(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -3909,12 +4335,14 @@ blob_insert_cluster_msg(void) opts.num_clusters = 4; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -3925,14 +4353,17 @@ blob_insert_cluster_msg(void) _spdk_bs_claim_cluster(bs, 0xF); _spdk_blob_insert_cluster_on_md_thread(blob, 1, 0xF, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(blob->active.clusters[1] != 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -3941,12 +4372,14 @@ blob_insert_cluster_msg(void) /* Load an existing blob store */ dev = init_dev(); spdk_bs_load(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -3954,12 +4387,15 @@ blob_insert_cluster_msg(void) CU_ASSERT(blob->active.clusters[1] != 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -3984,6 +4420,7 @@ blob_thin_prov_rw(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -3997,12 +4434,14 @@ blob_thin_prov_rw(void) opts.thin_provision = true; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -4011,11 +4450,13 @@ blob_thin_prov_rw(void) /* The blob started at 0 clusters. Resize it to be 5, but still unallocated. */ spdk_blob_resize(blob, 5, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); CU_ASSERT(blob->active.num_clusters == 5); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Sync must not change anything */ CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); @@ -4024,6 +4465,7 @@ blob_thin_prov_rw(void) /* Payload should be all zeros from unallocated clusters */ memset(payload_read, 0xFF, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(zero, payload_read, 10 * 4096) == 0); @@ -4032,6 +4474,7 @@ blob_thin_prov_rw(void) memset(payload_write, 0xE5, sizeof(payload_write)); spdk_blob_io_write(blob, channel, payload_write, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters != spdk_bs_free_cluster_count(bs)); /* For thin-provisioned blob we need to write 10 pages plus one page metadata and @@ -4040,20 +4483,25 @@ blob_thin_prov_rw(void) CU_ASSERT(g_dev_read_bytes - read_bytes == 0); spdk_blob_io_read(blob, channel, payload_read, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, 10 * 4096) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); spdk_bs_free_io_channel(channel); + poll_threads(); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -4079,6 +4527,7 @@ blob_thin_prov_rw_iov(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -4091,12 +4540,14 @@ blob_thin_prov_rw_iov(void) opts.thin_provision = true; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -4105,11 +4556,13 @@ blob_thin_prov_rw_iov(void) /* The blob started at 0 clusters. Resize it to be 5, but still unallocated. */ spdk_blob_resize(blob, 5, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); CU_ASSERT(blob->active.num_clusters == 5); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Sync must not change anything */ CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); @@ -4124,6 +4577,7 @@ blob_thin_prov_rw_iov(void) iov_read[2].iov_base = payload_read + 7 * 4096; iov_read[2].iov_len = 3 * 4096; spdk_blob_io_readv(blob, channel, iov_read, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(zero, payload_read, 10 * 4096) == 0); @@ -4136,6 +4590,7 @@ blob_thin_prov_rw_iov(void) iov_write[2].iov_len = 4 * 4096; spdk_blob_io_writev(blob, channel, iov_write, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0xAA, sizeof(payload_read)); @@ -4146,16 +4601,20 @@ blob_thin_prov_rw_iov(void) iov_read[2].iov_base = payload_read + 7 * 4096; iov_read[2].iov_len = 3 * 4096; spdk_blob_io_readv(blob, channel, iov_read, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, 10 * 4096) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -4193,6 +4652,7 @@ bs_load_iter(void) /* Initialize a new blob store */ spdk_bs_init(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -4200,6 +4660,7 @@ bs_load_iter(void) g_bserrno = -1; g_blobid = SPDK_BLOBID_INVALID; spdk_bs_create_blob(g_bs, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); iter_ctx.blobid[i] = g_blobid; @@ -4207,6 +4668,7 @@ bs_load_iter(void) g_bserrno = -1; g_blob = NULL; spdk_bs_open_blob(g_bs, g_blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -4217,14 +4679,17 @@ bs_load_iter(void) /* Resize the blob */ spdk_blob_resize(blob, i, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); } g_bserrno = -1; spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); dev = init_dev(); @@ -4235,6 +4700,7 @@ bs_load_iter(void) /* Test blob iteration during load after a clean shutdown. */ spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -4250,10 +4716,12 @@ bs_load_iter(void) /* Test blob iteration during load after a dirty shutdown. */ spdk_bs_load(dev, &opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; } @@ -4279,6 +4747,7 @@ blob_snapshot_rw(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -4294,12 +4763,14 @@ blob_snapshot_rw(void) opts.num_clusters = 5; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -4308,21 +4779,25 @@ blob_snapshot_rw(void) memset(payload_read, 0xFF, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(zero, payload_read, 10 * 4096) == 0); memset(payload_write, 0xE5, sizeof(payload_write)); spdk_blob_io_write(blob, channel, payload_write, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters != spdk_bs_free_cluster_count(bs)); /* Create snapshot from blob */ spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshotid = g_blobid; spdk_bs_open_blob(bs, snapshotid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot = g_blob; @@ -4336,6 +4811,7 @@ blob_snapshot_rw(void) memset(payload_write, 0xAA, sizeof(payload_write)); spdk_blob_io_write(blob, channel, payload_write, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters != spdk_bs_free_cluster_count(bs)); @@ -4346,31 +4822,39 @@ blob_snapshot_rw(void) CU_ASSERT(g_dev_read_bytes - read_bytes == cluster_size); spdk_blob_io_read(blob, channel, payload_read, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, 10 * 4096) == 0); /* Data on snapshot should not change after write to clone */ memset(payload_write, 0xE5, sizeof(payload_write)); spdk_blob_io_read(snapshot, channel, payload_read, 4, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, 10 * 4096) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(snapshot, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -4396,6 +4880,7 @@ blob_snapshot_rw_iov(void) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -4409,12 +4894,14 @@ blob_snapshot_rw_iov(void) opts.num_clusters = 5; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -4423,11 +4910,13 @@ blob_snapshot_rw_iov(void) /* Create snapshot from blob */ spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshotid = g_blobid; spdk_bs_open_blob(bs, snapshotid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot = g_blob; @@ -4444,6 +4933,7 @@ blob_snapshot_rw_iov(void) iov_read[2].iov_base = payload_read + 7 * 4096; iov_read[2].iov_len = 3 * 4096; spdk_blob_io_readv(blob, channel, iov_read, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(zero, payload_read, 10 * 4096) == 0); @@ -4456,6 +4946,7 @@ blob_snapshot_rw_iov(void) iov_write[2].iov_len = 4 * 4096; spdk_blob_io_writev(blob, channel, iov_write, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); memset(payload_read, 0xAA, sizeof(payload_read)); @@ -4466,19 +4957,24 @@ blob_snapshot_rw_iov(void) iov_read[2].iov_base = payload_read + 7 * 4096; iov_read[2].iov_len = 3 * 4096; spdk_blob_io_readv(blob, channel, iov_read, 3, 250, 10, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_write, payload_read, 10 * 4096) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(snapshot, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -4546,6 +5042,7 @@ _blob_inflate_rw(bool decouple_parent) dev = init_dev(); spdk_bs_init(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -4575,12 +5072,14 @@ _blob_inflate_rw(bool decouple_parent) opts.num_clusters = 5; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(bs)); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -4591,6 +5090,7 @@ _blob_inflate_rw(bool decouple_parent) memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(spdk_mem_all_zero(payload_read, payload_size)); @@ -4599,16 +5099,19 @@ _blob_inflate_rw(bool decouple_parent) memset(payload_write, 0xE5, payload_size - cluster_size); spdk_blob_io_write(blob, channel, payload_write, 0, pages_per_payload - pages_per_cluster, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(free_clusters != spdk_bs_free_cluster_count(bs)); /* 2) Create snapshot from blob (first level) */ spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshotid = g_blobid; spdk_bs_open_blob(bs, snapshotid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot = g_blob; @@ -4633,6 +5136,7 @@ _blob_inflate_rw(bool decouple_parent) for (i = 1; i < 5; i += 2) { spdk_blob_io_write(blob, channel, payload_write, i * pages_per_cluster, pages_per_cluster, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Update expected result */ @@ -4645,16 +5149,19 @@ _blob_inflate_rw(bool decouple_parent) memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_clone, payload_read, payload_size) == 0); /* 3) Create second levels snapshot from blob */ spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshot2id = g_blobid; spdk_bs_open_blob(bs, snapshot2id, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot2 = g_blob; @@ -4670,6 +5177,7 @@ _blob_inflate_rw(bool decouple_parent) * at all */ spdk_blob_io_write(blob, channel, payload_write, pages_per_cluster, pages_per_cluster, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Update expected result */ @@ -4679,18 +5187,22 @@ _blob_inflate_rw(bool decouple_parent) memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_clone, payload_read, payload_size) == 0); /* Close all blobs */ spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(snapshot2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(snapshot, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Check snapshot-clone relations */ @@ -4710,6 +5222,7 @@ _blob_inflate_rw(bool decouple_parent) if (!decouple_parent) { /* Do full blob inflation */ spdk_bs_inflate_blob(bs, channel, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* All clusters should be inflated (except one already allocated @@ -4733,6 +5246,7 @@ _blob_inflate_rw(bool decouple_parent) } else { /* Decouple parent of blob */ spdk_bs_blob_decouple_parent(bs, channel, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Only one cluster from a parent should be inflated (second one @@ -4759,16 +5273,19 @@ _blob_inflate_rw(bool decouple_parent) /* Try to delete snapshot2 (should pass) */ spdk_bs_delete_blob(bs, snapshot2id, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Try to delete base snapshot (for decouple_parent should fail while * dependency still exists) */ spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(decouple_parent || g_bserrno == 0); CU_ASSERT(!decouple_parent || g_bserrno != 0); /* Reopen blob after snapshot deletion */ spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -4779,16 +5296,20 @@ _blob_inflate_rw(bool decouple_parent) memset(payload_read, 0xFF, payload_size); spdk_blob_io_read(blob, channel, payload_read, 0, pages_per_payload, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_clone, payload_read, payload_size) == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_free_io_channel(channel); + poll_threads(); /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -4835,6 +5356,7 @@ blob_relations(void) snprintf(bs_opts.bstype.bstype, sizeof(bs_opts.bstype.bstype), "TESTTYPE"); spdk_bs_init(dev, &bs_opts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -4845,11 +5367,13 @@ blob_relations(void) opts.num_clusters = 10; spdk_bs_create_blob_ext(bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); blob = g_blob; @@ -4871,11 +5395,13 @@ blob_relations(void) /* 2. Create snapshot */ spdk_bs_create_snapshot(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshotid = g_blobid; spdk_bs_open_blob(bs, snapshotid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot = g_blob; @@ -4904,11 +5430,13 @@ blob_relations(void) /* 3. Create clone from snapshot */ spdk_bs_create_clone(bs, snapshotid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); cloneid = g_blobid; spdk_bs_open_blob(bs, cloneid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); clone = g_blob; @@ -4936,11 +5464,13 @@ blob_relations(void) /* 4. Create snapshot of the clone */ spdk_bs_create_snapshot(bs, cloneid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); snapshotid2 = g_blobid; spdk_bs_open_blob(bs, snapshotid2, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); snapshot2 = g_blob; @@ -4972,6 +5502,7 @@ blob_relations(void) /* Mark blob as read only */ spdk_blob_set_read_only(blob); spdk_blob_sync_md(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Check if previously created blob is read only clone */ @@ -4982,11 +5513,13 @@ blob_relations(void) /* Create clone from read only blob */ spdk_bs_create_clone(bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); cloneid2 = g_blobid; spdk_bs_open_blob(bs, cloneid2, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_blob != NULL); clone2 = g_blob; @@ -5008,28 +5541,36 @@ blob_relations(void) /* Close blobs */ spdk_blob_close(clone2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(clone, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(snapshot, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_blob_close(snapshot2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Try to delete snapshot with created clones */ spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); spdk_bs_delete_blob(bs, snapshotid2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); spdk_bs_unload(bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -5038,6 +5579,7 @@ blob_relations(void) snprintf(bs_opts.bstype.bstype, sizeof(bs_opts.bstype.bstype), "TESTTYPE"); spdk_bs_load(dev, NULL, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); bs = g_bs; @@ -5101,33 +5643,43 @@ blob_relations(void) /* Try to delete all blobs in the worse possible order */ spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); spdk_bs_delete_blob(bs, snapshotid2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); spdk_bs_delete_blob(bs, cloneid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, snapshotid2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno != 0); spdk_bs_delete_blob(bs, cloneid2, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_delete_blob(bs, snapshotid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); spdk_bs_unload(bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -5147,6 +5699,7 @@ test_io_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Try to perform I/O with io unit = 512 */ spdk_blob_io_write(blob, channel, payload_ff, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* If thin provisioned is set cluster should be allocated now */ @@ -5161,6 +5714,7 @@ test_io_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Verify write with offset on first page */ spdk_blob_io_write(blob, channel, payload_ff, 2, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* cluster0: [ F0F0 0000 | 0000 0000 | 0000 0000 | 0000 0000 ] */ @@ -5172,6 +5726,7 @@ test_io_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Verify write with offset on first page */ spdk_blob_io_write(blob, channel, payload_ff, 4, 4, blob_op_complete, NULL); + poll_threads(); /* cluster0: [ F0F0 FFFF | 0000 0000 | 0000 0000 | 0000 0000 ] */ CU_ASSERT(memcmp(cluster0 + 0 * 512, payload_ff, 512) == 0); @@ -5183,6 +5738,7 @@ test_io_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Verify write with offset on second page */ spdk_blob_io_write(blob, channel, payload_ff, 8, 4, blob_op_complete, NULL); + poll_threads(); /* cluster0: [ F0F0 FFFF | FFFF 0000 | 0000 0000 | 0000 0000 ] */ CU_ASSERT(memcmp(cluster0 + 0 * 512, payload_ff, 512) == 0); @@ -5194,6 +5750,7 @@ test_io_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Verify write across multiple pages */ spdk_blob_io_write(blob, channel, payload_aa, 4, 8, blob_op_complete, NULL); + poll_threads(); /* cluster0: [ F0F0 AAAA | AAAA 0000 | 0000 0000 | 0000 0000 ] */ CU_ASSERT(memcmp(cluster0 + 0 * 512, payload_ff, 512) == 0); @@ -5205,6 +5762,7 @@ test_io_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Verify write across multiple clusters */ spdk_blob_io_write(blob, channel, payload_ff, 28, 8, blob_op_complete, NULL); + poll_threads(); SPDK_CU_ASSERT_FATAL(blob->active.clusters[1] != 0); cluster1 = &g_dev_buffer[blob->active.clusters[1] * dev->blocklen]; @@ -5223,6 +5781,7 @@ test_io_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Verify write to second cluster */ spdk_blob_io_write(blob, channel, payload_ff, 32 + 12, 2, blob_op_complete, NULL); + poll_threads(); SPDK_CU_ASSERT_FATAL(blob->active.clusters[1] != 0); cluster1 = &g_dev_buffer[blob->active.clusters[1] * dev->blocklen]; @@ -5260,6 +5819,7 @@ test_io_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_cha * payload_read: F000 0000 | 0000 0000 ... */ memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 512) == 0); CU_ASSERT(memcmp(payload_read + 1 * 512, payload_00, 31 * 512) == 0); @@ -5271,6 +5831,7 @@ test_io_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_cha memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 2, 4, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 512) == 0); @@ -5285,6 +5846,7 @@ test_io_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_cha * payload_read: AAAA AAAA | 0000 0000 ... */ memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 4, 8, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_aa, 8 * 512) == 0); @@ -5296,6 +5858,7 @@ test_io_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_cha * payload_read: FFFF FFFF | 0000 0000 ... */ memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 28, 8, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 8 * 512) == 0); @@ -5307,6 +5870,7 @@ test_io_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_cha * payload_read: 00FF 0000 | 0000 0000 ... */ memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 32 + 10, 4, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_00, 2 * 512) == 0); @@ -5319,6 +5883,7 @@ test_io_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_cha * payload_read: FFFF 0000 | 0000 FF00 ... */ memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 32, 32, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 4 * 512) == 0); CU_ASSERT(memcmp(payload_read + 4 * 512, payload_00, 8 * 512) == 0); @@ -5330,6 +5895,7 @@ test_io_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_cha * cluster1: [ FFFF 0000 | 0000 FF00 | 0000 0000 | 0000 0000) ] */ memset(payload_read, 0x00, sizeof(payload_read)); spdk_blob_io_read(blob, channel, payload_read, 0, 64, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 512) == 0); @@ -5363,6 +5929,7 @@ test_io_unmap(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch /* Unmap */ spdk_blob_io_unmap(blob, channel, 0, 64, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); @@ -5387,6 +5954,7 @@ test_io_zeroes(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c /* Write zeroes */ spdk_blob_io_write_zeroes(blob, channel, 0, 64, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); @@ -5412,6 +5980,7 @@ test_iov_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c iov[0].iov_base = payload_ff; iov[0].iov_len = 1 * 512; spdk_blob_io_writev(blob, channel, iov, 1, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* If thin provisioned is set cluster should be allocated now */ @@ -5428,6 +5997,7 @@ test_iov_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c iov[0].iov_base = payload_ff; iov[0].iov_len = 1 * 512; spdk_blob_io_writev(blob, channel, iov, 1, 2, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* cluster0: [ F0F0 0000 | 0000 0000 | 0000 0000 | 0000 0000 ] */ @@ -5441,6 +6011,7 @@ test_iov_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c iov[0].iov_base = payload_ff; iov[0].iov_len = 4 * 512; spdk_blob_io_writev(blob, channel, iov, 1, 4, 4, blob_op_complete, NULL); + poll_threads(); /* cluster0: [ F0F0 FFFF | 0000 0000 | 0000 0000 | 0000 0000 ] */ CU_ASSERT(memcmp(cluster0 + 0 * 512, payload_ff, 512) == 0); @@ -5454,6 +6025,7 @@ test_iov_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c iov[0].iov_base = payload_ff; iov[0].iov_len = 4 * 512; spdk_blob_io_writev(blob, channel, iov, 1, 8, 4, blob_op_complete, NULL); + poll_threads(); /* cluster0: [ F0F0 FFFF | FFFF 0000 | 0000 0000 | 0000 0000 ] */ CU_ASSERT(memcmp(cluster0 + 0 * 512, payload_ff, 512) == 0); @@ -5467,6 +6039,7 @@ test_iov_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c iov[0].iov_base = payload_aa; iov[0].iov_len = 8 * 512; spdk_blob_io_writev(blob, channel, iov, 1, 4, 8, blob_op_complete, NULL); + poll_threads(); /* cluster0: [ F0F0 AAAA | AAAA 0000 | 0000 0000 | 0000 0000 ] */ CU_ASSERT(memcmp(cluster0 + 0 * 512, payload_ff, 512) == 0); @@ -5481,6 +6054,7 @@ test_iov_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c iov[0].iov_base = payload_ff; iov[0].iov_len = 8 * 512; spdk_blob_io_writev(blob, channel, iov, 1, 28, 8, blob_op_complete, NULL); + poll_threads(); SPDK_CU_ASSERT_FATAL(blob->active.clusters[1] != 0); cluster1 = &g_dev_buffer[blob->active.clusters[1] * dev->blocklen]; @@ -5503,6 +6077,7 @@ test_iov_write(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_c iov[0].iov_base = payload_ff; iov[0].iov_len = 2 * 512; spdk_blob_io_writev(blob, channel, iov, 1, 32 + 12, 2, blob_op_complete, NULL); + poll_threads(); SPDK_CU_ASSERT_FATAL(blob->active.clusters[1] != 0); cluster1 = &g_dev_buffer[blob->active.clusters[1] * dev->blocklen]; @@ -5543,6 +6118,7 @@ test_iov_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch iov[0].iov_base = payload_read; iov[0].iov_len = 1 * 512; spdk_blob_io_readv(blob, channel, iov, 1, 0, 1, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 512) == 0); @@ -5557,6 +6133,7 @@ test_iov_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch iov[0].iov_base = payload_read; iov[0].iov_len = 4 * 512; spdk_blob_io_readv(blob, channel, iov, 1, 2, 4, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 512) == 0); @@ -5575,6 +6152,7 @@ test_iov_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch iov[1].iov_base = payload_read + 4 * 512; iov[1].iov_len = 4 * 512; spdk_blob_io_readv(blob, channel, iov, 2, 4, 8, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_aa, 8 * 512) == 0); @@ -5594,6 +6172,7 @@ test_iov_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch iov[3].iov_base = payload_read + 6 * 512; iov[3].iov_len = 2 * 512; spdk_blob_io_readv(blob, channel, iov, 4, 28, 8, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 8 * 512) == 0); @@ -5609,6 +6188,7 @@ test_iov_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch iov[1].iov_base = payload_read + 1 * 512; iov[1].iov_len = 3 * 512; spdk_blob_io_readv(blob, channel, iov, 2, 32 + 10, 4, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_00, 2 * 512) == 0); @@ -5629,6 +6209,7 @@ test_iov_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch iov[3].iov_base = payload_read + 7 * 512; iov[3].iov_len = 25 * 512; spdk_blob_io_readv(blob, channel, iov, 4, 32, 32, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 4 * 512) == 0); CU_ASSERT(memcmp(payload_read + 4 * 512, payload_00, 8 * 512) == 0); @@ -5648,6 +6229,7 @@ test_iov_read(struct spdk_bs_dev *dev, struct spdk_blob *blob, struct spdk_io_ch iov[3].iov_base = payload_read + 25 * 512; iov[3].iov_len = 39 * 512; spdk_blob_io_readv(blob, channel, iov, 4, 0, 64, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(memcmp(payload_read + 0 * 512, payload_ff, 512) == 0); @@ -5686,6 +6268,7 @@ blob_io_unit(void) /* Initialize a new blob store */ spdk_bs_init(dev, &bsopts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -5698,12 +6281,14 @@ blob_io_unit(void) opts.num_clusters = 32; spdk_bs_create_blob_ext(g_bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -5718,6 +6303,7 @@ blob_io_unit(void) test_io_unmap(dev, blob, channel); spdk_blob_close(blob, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob = NULL; g_blob = NULL; @@ -5729,11 +6315,13 @@ blob_io_unit(void) opts.num_clusters = 32; spdk_bs_create_blob_ext(g_bs, &opts, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); blob = g_blob; @@ -5749,21 +6337,25 @@ blob_io_unit(void) /* Create snapshot */ spdk_bs_create_snapshot(g_bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); snapshot = g_blob; spdk_bs_create_clone(g_bs, blobid, NULL, blob_op_with_id_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blobid != SPDK_BLOBID_INVALID); blobid = g_blobid; spdk_bs_open_blob(g_bs, blobid, blob_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); CU_ASSERT(g_blob != NULL); clone = g_blob; @@ -5779,6 +6371,7 @@ blob_io_unit(void) /* Inflate clone */ spdk_bs_inflate_blob(g_bs, channel, blobid, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); @@ -5792,12 +6385,14 @@ blob_io_unit(void) spdk_blob_close(blob, blob_op_complete, NULL); spdk_blob_close(snapshot, blob_op_complete, NULL); spdk_blob_close(clone, blob_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); blob = NULL; g_blob = NULL; /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; g_blob = NULL; @@ -5824,6 +6419,7 @@ blob_io_unit_compatiblity(void) /* Initialize a new blob store */ spdk_bs_init(dev, &bsopts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -5831,6 +6427,7 @@ blob_io_unit_compatiblity(void) /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); /* Modify super block to behave like older version. @@ -5844,6 +6441,7 @@ blob_io_unit_compatiblity(void) dev->blockcnt = DEV_BUFFER_SIZE / dev->blocklen; spdk_bs_load(dev, &bsopts, bs_op_with_handle_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); SPDK_CU_ASSERT_FATAL(g_bs != NULL); @@ -5851,6 +6449,7 @@ blob_io_unit_compatiblity(void) /* Unload the blob store */ spdk_bs_unload(g_bs, bs_op_complete, NULL); + poll_threads(); CU_ASSERT(g_bserrno == 0); g_bs = NULL; @@ -5860,7 +6459,6 @@ blob_io_unit_compatiblity(void) int main(int argc, char **argv) { - struct spdk_thread *thread; CU_pSuite suite = NULL; unsigned int num_failures; @@ -5932,14 +6530,19 @@ int main(int argc, char **argv) return CU_get_error(); } + allocate_threads(1); + set_thread(0); + g_dev_buffer = calloc(1, DEV_BUFFER_SIZE); - thread = spdk_allocate_thread(_bs_send_msg, NULL, NULL, NULL, "thread0"); - spdk_set_thread(thread); + CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); num_failures = CU_get_number_of_failures(); CU_cleanup_registry(); - spdk_free_thread(); + free(g_dev_buffer); + + free_threads(); + return num_failures; }