ut/blob: test cluster selection using _spdk_bs_allocate_cluster()
Previously blob_insert_cluster_msg UT specified the cluster which will be used to store LBA. So for blob the cluster [1], was always stored as cluster 0xF in blobstore. This patch changes _spdk_bs_claim_cluster() with preselected cluster in blobstore to _spdk_bs_allocate_cluster() that will choose first free one in the map. It will help in further patches that add more logic on extent table and extent pages in _spdk_bs_allocate_cluster(). Otherwise this patch 'hard coded' values might get more complex than needed. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I238329b2191e7ebd3f73c1fe85d7e1da0249979e Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475493 Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
0d1aa0252d
commit
8b21bab265
@ -4487,6 +4487,8 @@ blob_insert_cluster_msg(void)
|
||||
struct spdk_blob_opts opts;
|
||||
spdk_blob_id blobid;
|
||||
uint64_t free_clusters;
|
||||
uint64_t new_cluster = 0;
|
||||
uint32_t cluster_num = 3;
|
||||
|
||||
dev = init_dev();
|
||||
|
||||
@ -4517,13 +4519,18 @@ blob_insert_cluster_msg(void)
|
||||
|
||||
CU_ASSERT(blob->active.num_clusters == 4);
|
||||
CU_ASSERT(spdk_blob_get_num_clusters(blob) == 4);
|
||||
CU_ASSERT(blob->active.clusters[1] == 0);
|
||||
CU_ASSERT(blob->active.clusters[cluster_num] == 0);
|
||||
|
||||
_spdk_bs_claim_cluster(bs, 0xF);
|
||||
_spdk_blob_insert_cluster_on_md_thread(blob, 1, 0xF, blob_op_complete, NULL);
|
||||
/* Specify cluster_num to allocate and new_cluster will be returned to insert on md_thread.
|
||||
* This is to simulate behaviour when cluster is allocated after blob creation.
|
||||
* Such as _spdk_bs_allocate_and_copy_cluster(). */
|
||||
_spdk_bs_allocate_cluster(blob, cluster_num, &new_cluster, false);
|
||||
CU_ASSERT(blob->active.clusters[cluster_num] == 0);
|
||||
|
||||
_spdk_blob_insert_cluster_on_md_thread(blob, cluster_num, new_cluster, blob_op_complete, NULL);
|
||||
poll_threads();
|
||||
|
||||
CU_ASSERT(blob->active.clusters[1] != 0);
|
||||
CU_ASSERT(blob->active.clusters[cluster_num] != 0);
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
poll_threads();
|
||||
@ -4552,7 +4559,7 @@ blob_insert_cluster_msg(void)
|
||||
SPDK_CU_ASSERT_FATAL(g_blob != NULL);
|
||||
blob = g_blob;
|
||||
|
||||
CU_ASSERT(blob->active.clusters[1] != 0);
|
||||
CU_ASSERT(blob->active.clusters[cluster_num] != 0);
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
poll_threads();
|
||||
|
Loading…
Reference in New Issue
Block a user