lvol: move name to old_name
There are some upcoming changes which will deprecate the old lvsuuid_blobid name in favor of an lvs_name/lvol_name name where these names are user-specified. In preparation for this change, rename the previous lvol->name to lvol->old_name. This will allow us to add a new lvol->name but keep the original old_name during the transition. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: I10deb219097fa8726c146ab2427ee7373933b97d Reviewed-on: https://review.gerrithub.io/383534 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
08ac0074ce
commit
c6f1d12930
@ -96,7 +96,7 @@ struct spdk_lvol {
|
||||
struct spdk_blob *blob;
|
||||
uint64_t num_clusters;
|
||||
spdk_blob_id blob_id;
|
||||
char *name;
|
||||
char *old_name;
|
||||
bool close_only;
|
||||
struct spdk_bdev *bdev;
|
||||
int ref_count;
|
||||
|
@ -283,7 +283,7 @@ vbdev_get_lvol_by_name(const char *name)
|
||||
|
||||
TAILQ_FOREACH_SAFE(lvs_bdev, &g_spdk_lvol_pairs, lvol_stores, tmp_lvs_bdev) {
|
||||
TAILQ_FOREACH_SAFE(lvol, &lvs_bdev->lvs->lvols, link, tmp_lvol) {
|
||||
if (!strcmp(lvol->name, name)) {
|
||||
if (!strcmp(lvol->old_name, name)) {
|
||||
return lvol;
|
||||
}
|
||||
}
|
||||
@ -324,7 +324,7 @@ _vbdev_lvol_destroy_after_close_cb(void *cb_arg, int lvserrno)
|
||||
{
|
||||
struct spdk_lvol *lvol = cb_arg;
|
||||
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Lvol %s closed, begin destroying\n", lvol->name);
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Lvol %s closed, begin destroying\n", lvol->old_name);
|
||||
spdk_lvol_destroy(lvol, _vbdev_lvol_destroy_cb, NULL);
|
||||
}
|
||||
|
||||
@ -513,13 +513,13 @@ _create_lvol_disk(struct spdk_lvol *lvol)
|
||||
struct lvol_store_bdev *lvs_bdev;
|
||||
uint64_t total_size;
|
||||
|
||||
if (!lvol->name) {
|
||||
if (!lvol->old_name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lvs_bdev = vbdev_get_lvs_bdev_by_lvs(lvol->lvol_store);
|
||||
if (lvs_bdev == NULL) {
|
||||
SPDK_ERRLOG("No spdk lvs-bdev pair found for lvol %s\n", lvol->name);
|
||||
SPDK_ERRLOG("No spdk lvs-bdev pair found for lvol %s\n", lvol->old_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -529,7 +529,7 @@ _create_lvol_disk(struct spdk_lvol *lvol)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bdev->name = lvol->name;
|
||||
bdev->name = lvol->old_name;
|
||||
bdev->product_name = "Logical Volume";
|
||||
bdev->write_cache = 1;
|
||||
bdev->blocklen = spdk_bs_get_page_size(lvol->lvol_store->blobstore);
|
||||
@ -677,29 +677,29 @@ _vbdev_lvs_examine_finish(void *cb_arg, struct spdk_lvol *lvol, int lvolerrno)
|
||||
struct spdk_bdev *bdev;
|
||||
|
||||
if (lvolerrno != 0) {
|
||||
SPDK_ERRLOG("Error opening lvol %s\n", lvol->name);
|
||||
SPDK_ERRLOG("Error opening lvol %s\n", lvol->old_name);
|
||||
TAILQ_REMOVE(&lvs->lvols, lvol, link);
|
||||
lvs->lvol_count--;
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
goto end;
|
||||
}
|
||||
|
||||
bdev = _create_lvol_disk(lvol);
|
||||
if (bdev == NULL) {
|
||||
SPDK_ERRLOG("Cannot create bdev for lvol %s\n", lvol->name);
|
||||
SPDK_ERRLOG("Cannot create bdev for lvol %s\n", lvol->old_name);
|
||||
TAILQ_REMOVE(&lvs->lvols, lvol, link);
|
||||
lvs->lvol_count--;
|
||||
spdk_bs_md_close_blob(&lvol->blob, _vbdev_lvol_close_cb, lvs);
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Opening lvol %s failed\n", lvol->name);
|
||||
free(lvol->name);
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Opening lvol %s failed\n", lvol->old_name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
return;
|
||||
}
|
||||
|
||||
lvol->bdev = bdev;
|
||||
lvs->lvols_opened++;
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Opening lvol %s succeeded\n", lvol->name);
|
||||
SPDK_INFOLOG(SPDK_TRACE_VBDEV_LVOL, "Opening lvol %s succeeded\n", lvol->old_name);
|
||||
|
||||
end:
|
||||
|
||||
|
@ -247,7 +247,7 @@ _spdk_rpc_construct_lvol_bdev_cb(void *cb_arg, struct spdk_lvol *lvol, int lvole
|
||||
}
|
||||
|
||||
spdk_json_write_array_begin(w);
|
||||
spdk_json_write_string(w, lvol->name);
|
||||
spdk_json_write_string(w, lvol->old_name);
|
||||
spdk_json_write_array_end(w);
|
||||
spdk_jsonrpc_end_result(request, w);
|
||||
return;
|
||||
|
@ -88,7 +88,7 @@ _spdk_lvol_open_cb(void *cb_arg, struct spdk_blob *blob, int lvolerrno)
|
||||
struct spdk_lvol *lvol = req->lvol;
|
||||
|
||||
if (lvolerrno != 0) {
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Failed to open lvol %s\n", lvol->name);
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Failed to open lvol %s\n", lvol->old_name);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ _spdk_load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno)
|
||||
} else if (lvolerrno < 0) {
|
||||
TAILQ_FOREACH_SAFE(lvol, &lvs->lvols, link, tmp) {
|
||||
TAILQ_REMOVE(&lvs->lvols, lvol, link);
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
}
|
||||
SPDK_ERRLOG("Failed to fetch blobs list\n");
|
||||
@ -182,8 +182,8 @@ _spdk_load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno)
|
||||
lvol->num_clusters = spdk_blob_get_num_clusters(blob);
|
||||
lvol->close_only = false;
|
||||
uuid_unparse(lvol->lvol_store->uuid, uuid);
|
||||
lvol->name = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id);
|
||||
if (!lvol->name) {
|
||||
lvol->old_name = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id);
|
||||
if (!lvol->old_name) {
|
||||
SPDK_ERRLOG("Cannot assign lvol name\n");
|
||||
req->cb_fn(req->cb_arg, lvs, -ENOMEM);
|
||||
free(req);
|
||||
@ -195,7 +195,7 @@ _spdk_load_next_lvol(void *cb_arg, struct spdk_blob *blob, int lvolerrno)
|
||||
|
||||
lvs->lvol_count++;
|
||||
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "added lvol %s\n", lvol->name);
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "added lvol %s\n", lvol->old_name);
|
||||
|
||||
spdk_bs_md_iter_next(bs, &blob, _spdk_load_next_lvol, req);
|
||||
}
|
||||
@ -610,7 +610,7 @@ spdk_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn,
|
||||
|
||||
TAILQ_FOREACH_SAFE(lvol, &lvs->lvols, link, tmp) {
|
||||
TAILQ_REMOVE(&lvs->lvols, lvol, link);
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
}
|
||||
|
||||
@ -686,7 +686,7 @@ spdk_lvs_destroy(struct spdk_lvol_store *lvs, bool unmap_device, spdk_lvs_op_com
|
||||
}
|
||||
|
||||
TAILQ_FOREACH_SAFE(iter_lvol, &lvs->lvols, link, tmp) {
|
||||
free(iter_lvol->name);
|
||||
free(iter_lvol->old_name);
|
||||
free(iter_lvol);
|
||||
}
|
||||
|
||||
@ -717,7 +717,7 @@ _spdk_lvol_close_blob_cb(void *cb_arg, int lvolerrno)
|
||||
|
||||
if (lvolerrno < 0) {
|
||||
SPDK_ERRLOG("Could not close blob on lvol\n");
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
goto end;
|
||||
}
|
||||
@ -730,7 +730,7 @@ _spdk_lvol_close_blob_cb(void *cb_arg, int lvolerrno)
|
||||
}
|
||||
}
|
||||
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Lvol %s closed\n", lvol->name) ;
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Lvol %s closed\n", lvol->old_name) ;
|
||||
|
||||
if (lvol->lvol_store->destruct_req && all_lvols_closed == true) {
|
||||
spdk_lvs_unload(lvol->lvol_store, _spdk_lvs_destruct_cb, lvol->lvol_store->destruct_req);
|
||||
@ -750,7 +750,7 @@ _spdk_lvol_delete_blob_cb(void *cb_arg, int lvolerrno)
|
||||
|
||||
if (lvolerrno < 0) {
|
||||
SPDK_ERRLOG("Could not delete blob on lvol\n");
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
goto end;
|
||||
}
|
||||
@ -759,9 +759,9 @@ _spdk_lvol_delete_blob_cb(void *cb_arg, int lvolerrno)
|
||||
spdk_lvs_unload(lvol->lvol_store, _spdk_lvs_destruct_cb, lvol->lvol_store->destruct_req);
|
||||
}
|
||||
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Lvol %s deleted\n", lvol->name);
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Lvol %s deleted\n", lvol->old_name);
|
||||
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
|
||||
end:
|
||||
@ -780,14 +780,14 @@ _spdk_lvol_destroy_cb(void *cb_arg, int lvolerrno)
|
||||
|
||||
if (lvolerrno < 0) {
|
||||
SPDK_ERRLOG("Could not delete blob on lvol\n");
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
lvol_req->cb_fn(lvol_req->cb_arg, lvolerrno);
|
||||
free(lvol_req);
|
||||
free(req);
|
||||
return;
|
||||
}
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Blob closed on lvol %s\n", lvol->name);
|
||||
SPDK_INFOLOG(SPDK_TRACE_LVOL, "Blob closed on lvol %s\n", lvol->old_name);
|
||||
|
||||
spdk_bs_md_delete_blob(bs, lvol->blob_id, _spdk_lvol_delete_blob_cb, req);
|
||||
}
|
||||
@ -827,8 +827,8 @@ _spdk_lvol_create_open_cb(void *cb_arg, struct spdk_blob *blob, int lvolerrno)
|
||||
lvol->blob_id = blob_id;
|
||||
|
||||
uuid_unparse(lvol->lvol_store->uuid, uuid);
|
||||
lvol->name = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id);
|
||||
if (!lvol->name) {
|
||||
lvol->old_name = spdk_sprintf_alloc("%s_%"PRIu64, uuid, (uint64_t)blob_id);
|
||||
if (!lvol->old_name) {
|
||||
spdk_bs_md_close_blob(&blob, _spdk_lvol_delete_blob_cb, lvol);
|
||||
SPDK_ERRLOG("Cannot alloc memory for lvol name\n");
|
||||
lvolerrno = -ENOMEM;
|
||||
@ -994,7 +994,7 @@ spdk_lvol_destroy(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_
|
||||
}
|
||||
|
||||
if (lvol->ref_count != 0) {
|
||||
SPDK_ERRLOG("Cannot destroy lvol %s because it is still open\n", lvol->name);
|
||||
SPDK_ERRLOG("Cannot destroy lvol %s because it is still open\n", lvol->old_name);
|
||||
cb_fn(cb_arg, -EBUSY);
|
||||
return;
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ spdk_lvs_unload(struct spdk_lvol_store *lvs, spdk_lvs_op_complete cb_fn, void *c
|
||||
while (!TAILQ_EMPTY(&lvs->lvols)) {
|
||||
lvol = TAILQ_FIRST(&lvs->lvols);
|
||||
TAILQ_REMOVE(&lvs->lvols, lvol, link);
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
}
|
||||
|
||||
@ -251,7 +251,7 @@ void
|
||||
spdk_lvol_destroy(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg)
|
||||
{
|
||||
TAILQ_REMOVE(&lvol->lvol_store->lvols, lvol, link);
|
||||
free(lvol->name);
|
||||
free(lvol->old_name);
|
||||
free(lvol);
|
||||
g_lvol = NULL;
|
||||
|
||||
@ -372,8 +372,8 @@ _lvol_create(struct spdk_lvol_store *lvs)
|
||||
|
||||
lvol->lvol_store = lvs;
|
||||
lvol->ref_count++;
|
||||
lvol->name = spdk_sprintf_alloc("%s", "UNIT_TEST_UUID");
|
||||
SPDK_CU_ASSERT_FATAL(lvol->name != NULL);
|
||||
lvol->old_name = spdk_sprintf_alloc("%s", "UNIT_TEST_UUID");
|
||||
SPDK_CU_ASSERT_FATAL(lvol->old_name != NULL);
|
||||
|
||||
TAILQ_INSERT_TAIL(&lvol->lvol_store->lvols, lvol, link);
|
||||
|
||||
@ -638,11 +638,11 @@ ut_lvol_resize(void)
|
||||
|
||||
g_base_bdev->ctxt = g_lvol;
|
||||
|
||||
g_base_bdev->name = spdk_sprintf_alloc("%s", g_lvol->name);
|
||||
g_base_bdev->name = spdk_sprintf_alloc("%s", g_lvol->old_name);
|
||||
SPDK_CU_ASSERT_FATAL(g_base_bdev->name != NULL);
|
||||
|
||||
/* Successful lvol resize */
|
||||
rc = vbdev_lvol_resize(g_lvol->name, 20, vbdev_lvol_resize_complete, NULL);
|
||||
rc = vbdev_lvol_resize(g_lvol->old_name, 20, vbdev_lvol_resize_complete, NULL);
|
||||
CU_ASSERT(rc == 0);
|
||||
CU_ASSERT(g_base_bdev->blockcnt == 20 * g_cluster_size / g_base_bdev->blocklen);
|
||||
|
||||
@ -651,9 +651,9 @@ ut_lvol_resize(void)
|
||||
CU_ASSERT(rc != 0);
|
||||
|
||||
/* Resize with correct bdev name, but wrong lvol name */
|
||||
free(g_lvol->name);
|
||||
g_lvol->name = strdup("wrong name");
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol->name != NULL);
|
||||
free(g_lvol->old_name);
|
||||
g_lvol->old_name = strdup("wrong name");
|
||||
SPDK_CU_ASSERT_FATAL(g_lvol->old_name != NULL);
|
||||
rc = vbdev_lvol_resize(g_base_bdev->name, 20, vbdev_lvol_resize_complete, NULL);
|
||||
CU_ASSERT(rc != 0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user