mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
cleanup: move allocation code
Allocate new memory after validation passed.
This commit is contained in:
parent
dde5b81079
commit
ba36ba8853
@ -3122,6 +3122,10 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If LV is inactive here, ensure it's not active elsewhere. */
|
||||||
|
if (!lockd_lv(cmd, lv, "ex", 0))
|
||||||
|
return 0;
|
||||||
|
|
||||||
is_active = lv_is_active(lv);
|
is_active = lv_is_active(lv);
|
||||||
|
|
||||||
activate_pool = to_thinpool && is_active;
|
activate_pool = to_thinpool && is_active;
|
||||||
@ -3129,17 +3133,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
|
/* Wipe metadata_lv by default, but allow skipping this for cache pools. */
|
||||||
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
|
zero_metadata = (to_cachepool) ? arg_int_value(cmd, zero_ARG, 1) : 1;
|
||||||
|
|
||||||
if (vg_is_shared(vg) && lv->lock_args) {
|
|
||||||
lockd_data_args = dm_pool_strdup(vg->vgmem, lv->lock_args);
|
|
||||||
lockd_data_name = dm_pool_strdup(vg->vgmem, lv->name);
|
|
||||||
lockd_data_flags = is_active ? LDLV_PERSISTENT : 0;
|
|
||||||
lockd_data_id = lv->lvid.id[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If LV is inactive here, ensure it's not active elsewhere. */
|
|
||||||
if (!lockd_lv(cmd, lv, "ex", 0))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If an existing LV is to be used as the metadata LV,
|
* If an existing LV is to be used as the metadata LV,
|
||||||
* verify that it's in a usable state. These checks are
|
* verify that it's in a usable state. These checks are
|
||||||
@ -3158,14 +3151,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* An existing LV needs to have its lock freed once it becomes a meta LV. */
|
|
||||||
if (vg_is_shared(vg) && metadata_lv->lock_args) {
|
|
||||||
lockd_meta_args = dm_pool_strdup(vg->vgmem, metadata_lv->lock_args);
|
|
||||||
lockd_meta_name = dm_pool_strdup(vg->vgmem, metadata_lv->name);
|
|
||||||
lockd_meta_flags = lv_is_active(metadata_lv) ? LDLV_PERSISTENT : 0;
|
|
||||||
lockd_meta_id = metadata_lv->lvid.id[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (metadata_lv == lv) {
|
if (metadata_lv == lv) {
|
||||||
log_error("Can't use same LV for pool data and metadata LV %s.",
|
log_error("Can't use same LV for pool data and metadata LV %s.",
|
||||||
display_lvname(metadata_lv));
|
display_lvname(metadata_lv));
|
||||||
@ -3212,6 +3197,21 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
|
|||||||
/* If LV is inactive here, ensure it's not active elsewhere. */
|
/* If LV is inactive here, ensure it's not active elsewhere. */
|
||||||
if (!lockd_lv(cmd, metadata_lv, "ex", 0))
|
if (!lockd_lv(cmd, metadata_lv, "ex", 0))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* An existing LV needs to have its lock freed once it becomes a meta LV. */
|
||||||
|
if (vg_is_shared(vg) && metadata_lv->lock_args) {
|
||||||
|
lockd_meta_args = dm_pool_strdup(vg->vgmem, metadata_lv->lock_args);
|
||||||
|
lockd_meta_name = dm_pool_strdup(vg->vgmem, metadata_lv->name);
|
||||||
|
lockd_meta_flags = lv_is_active(metadata_lv) ? LDLV_PERSISTENT : 0;
|
||||||
|
lockd_meta_id = metadata_lv->lvid.id[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vg_is_shared(vg) && lv->lock_args) {
|
||||||
|
lockd_data_args = dm_pool_strdup(vg->vgmem, lv->lock_args);
|
||||||
|
lockd_data_name = dm_pool_strdup(vg->vgmem, lv->name);
|
||||||
|
lockd_data_flags = is_active ? LDLV_PERSISTENT : 0;
|
||||||
|
lockd_data_id = lv->lvid.id[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_pool_params(cmd, pool_segtype,
|
if (!get_pool_params(cmd, pool_segtype,
|
||||||
|
Loading…
Reference in New Issue
Block a user