1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

cleanup: use insert_layer_for_lv implicit rename

There is implicit rename for certain layered device.
Do it now for _tdata, _cdata and _corig.

TODO: use better API here...
This commit is contained in:
Zdenek Kabelac 2014-06-18 14:58:09 +02:00
parent e6a4cc9c31
commit 597de5c807
2 changed files with 9 additions and 23 deletions

View File

@ -91,8 +91,6 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool,
struct cmd_context *cmd = pool->vg->cmd;
struct logical_volume *cache_lv;
struct lv_segment *seg;
int origin_name_len = strlen(origin->name);
char origin_name[origin_name_len + 7]; /* + "_corig" and NULL */
if (!lv_is_cache_pool(pool)) {
log_error(INTERNAL_ERROR
@ -124,21 +122,6 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool,
if (!(segtype = get_segtype_from_string(cmd, "cache")))
return_NULL;
/*
* insert_layer_for_lv does not rename the sub-LVs when adding
* the suffix. So, we rename everything here and then change
* only the top-level LV back before adding the layer.
*/
sprintf(origin_name, "%s_corig", origin->name);
if (!lv_rename_update(cmd, origin, origin_name, 0)) {
log_error("Failed to rename origin LV, %s", origin->name);
return NULL;
}
origin_name[origin_name_len] = '\0';
if (!(origin->name = dm_pool_strdup(origin->vg->vgmem, origin_name)))
return_0;
cache_lv = origin;
if (!(origin = insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig")))
return_NULL;

View File

@ -5384,6 +5384,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
uint64_t status,
const char *layer_suffix)
{
static char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
int r;
char *name;
size_t len;
@ -5493,11 +5494,13 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
* currently supported only for thin data layer
* FIXME: without strcmp it breaks mirrors....
*/
if (strcmp(layer_suffix, "_tdata") == 0) {
for (r = 0; r < DM_ARRAY_SIZE(_suffixes); ++r)
if (strcmp(layer_suffix, _suffixes[r]) == 0) {
lv_names.old = lv_where->name;
lv_names.new = layer_lv->name;
if (!for_each_sub_lv(layer_lv, _rename_cb, (void *) &lv_names))
return 0;
break;
}
return layer_lv;