mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-19 14:04:17 +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:
parent
e6a4cc9c31
commit
597de5c807
@ -91,8 +91,6 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool,
|
|||||||
struct cmd_context *cmd = pool->vg->cmd;
|
struct cmd_context *cmd = pool->vg->cmd;
|
||||||
struct logical_volume *cache_lv;
|
struct logical_volume *cache_lv;
|
||||||
struct lv_segment *seg;
|
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)) {
|
if (!lv_is_cache_pool(pool)) {
|
||||||
log_error(INTERNAL_ERROR
|
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")))
|
if (!(segtype = get_segtype_from_string(cmd, "cache")))
|
||||||
return_NULL;
|
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;
|
cache_lv = origin;
|
||||||
if (!(origin = insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig")))
|
if (!(origin = insert_layer_for_lv(cmd, cache_lv, CACHE, "_corig")))
|
||||||
return_NULL;
|
return_NULL;
|
||||||
|
@ -5384,6 +5384,7 @@ struct logical_volume *insert_layer_for_lv(struct cmd_context *cmd,
|
|||||||
uint64_t status,
|
uint64_t status,
|
||||||
const char *layer_suffix)
|
const char *layer_suffix)
|
||||||
{
|
{
|
||||||
|
static char _suffixes[][8] = { "_tdata", "_cdata", "_corig" };
|
||||||
int r;
|
int r;
|
||||||
char *name;
|
char *name;
|
||||||
size_t len;
|
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
|
* currently supported only for thin data layer
|
||||||
* FIXME: without strcmp it breaks mirrors....
|
* 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.old = lv_where->name;
|
||||||
lv_names.new = layer_lv->name;
|
lv_names.new = layer_lv->name;
|
||||||
if (!for_each_sub_lv(layer_lv, _rename_cb, (void *) &lv_names))
|
if (!for_each_sub_lv(layer_lv, _rename_cb, (void *) &lv_names))
|
||||||
return 0;
|
return 0;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return layer_lv;
|
return layer_lv;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user