lv_where->le_count = layer_lv->le_count;
lv_where->size = (uint64_t) lv_where->le_count * lv_where->vg->extent_size;
+ if (lv_where->vg->fid->fmt->features & FMT_CONFIG_PROFILE)
+ lv_where->profile = lv_where->vg->cmd->profile_params->global_metadata_profile;
+
/*
* recuresively rename sub LVs
* currently supported only for thin data layer
}
if (seg_is_vdo_pool(lp)) {
- if (!convert_vdo_pool_lv(lv, &lp->vdo_params, &lp->virtual_extents)) {
+ if (!convert_vdo_pool_lv(lv, &lp->vdo_params, &lp->virtual_extents, 1)) {
stack;
goto deactivate_and_revert_new_lv;
}
const char *params, struct lv_status_vdo *status);
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
const struct dm_vdo_target_params *vtp,
- uint32_t *virtual_extents);
+ uint32_t *virtual_extents,
+ int format);
int set_vdo_write_policy(enum dm_vdo_write_policy *vwp, const char *policy);
int fill_vdo_target_params(struct cmd_context *cmd,
struct dm_vdo_target_params *vtp,
*/
struct logical_volume *convert_vdo_pool_lv(struct logical_volume *data_lv,
const struct dm_vdo_target_params *vtp,
- uint32_t *virtual_extents)
+ uint32_t *virtual_extents,
+ int format)
{
const uint64_t header_size = DEFAULT_VDO_POOL_HEADER_SIZE;
const uint32_t extent_size = data_lv->vg->extent_size;
return_0;
/* Format data LV as VDO volume */
- if (!_format_vdo_pool_data_lv(data_lv, vtp, &vdo_logical_size)) {
- log_error("Cannot format VDO pool volume %s.", display_lvname(data_lv));
- return NULL;
+ if (format) {
+ if (!_format_vdo_pool_data_lv(data_lv, vtp, &vdo_logical_size)) {
+ log_error("Cannot format VDO pool volume %s.", display_lvname(data_lv));
+ return NULL;
+ }
+ } else {
+ log_verbose("Skiping VDO formating %s.", display_lvname(data_lv));
+ /* TODO: parse existing VDO data and retrieve vdo_logical_size */
+ vdo_logical_size = data_lv->size;
}
if (!deactivate_lv(data_lv->vg->cmd, data_lv)) {
--cachemode CacheMode, --cachepolicy String,
--cachesettings String, --zero Bool
+OO_LVCONVERT_VDO: --metadataprofile String --readahead Readahead,
+--compression Bool, --deduplication Bool
+--zero Bool
+
OO_LVCONVERT: --alloc Alloc, --background, --force, --noudevsync
---
---
lvconvert --type vdo-pool LV_linear_striped_raid_cache
-OO: --name LV_new, --virtualsize SizeMB, --compression Bool, --deduplication Bool, OO_LVCONVERT
+OO: --name LV_new, --virtualsize SizeMB, OO_LVCONVERT_VDO, OO_LVCONVERT
ID: lvconvert_to_vdopool
DESC: Convert LV to type vdopool.
RULE: all and lv_is_visible
RULE: all not lv_is_locked lv_is_origin lv_is_merging_origin lv_is_external_origin lv_is_virtual lv_is_raid_with_integrity
lvconvert --vdopool LV_linear_striped_raid_cache
-OO: --type vdo-pool, OO_LVCONVERT,
---name LV_new, --virtualsize SizeMB, --compression Bool, --deduplication Bool
+OO: --type vdo-pool, OO_LVCONVERT_VDO, OO_LVCONVERT
+--name LV_new, --virtualsize SizeMB,
ID: lvconvert_to_vdopool_param
DESC: Convert LV to type vdopool.
RULE: all and lv_is_visible
struct processing_handle *handle)
{
const char *vg_name = NULL;
+ unsigned int zero_vdopool;
struct volume_group *vg = lv->vg;
struct logical_volume *vdo_lv;
struct dm_vdo_target_params vdo_params; /* vdo */
.permission = LVM_READ | LVM_WRITE,
.pool_name = lv->name,
.pvh = &vg->pvs,
- .read_ahead = DM_READ_AHEAD_AUTO,
+ .read_ahead = arg_uint_value(cmd, readahead_ARG, DM_READ_AHEAD_AUTO),
.stripes = 1,
.lv_name = arg_str_value(cmd, name_ARG, NULL),
};
goto out;
}
- if (!fill_vdo_target_params(cmd, &vdo_params, NULL))
+ if (!fill_vdo_target_params(cmd, &vdo_params, vg->profile))
goto_out;
if (arg_is_set(cmd, compression_ARG))
goto out;
}
- log_warn("WARNING: Converting logical volume %s to VDO pool volume.",
- lv->name);
- log_warn("THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)");
+ zero_vdopool = arg_int_value(cmd, zero_ARG, 1);
+
+ log_warn("WARNING: Converting logical volume %s to VDO pool volume %s formating.",
+ display_lvname(lv), zero_vdopool ? "with" : "WITHOUT");
+
+ if (zero_vdopool)
+ log_warn("THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)");
+ else
+ log_warn("WARNING: Using invalid VDO pool data MAY DESTROY YOUR DATA!");
if (!arg_count(cmd, yes_ARG) &&
yes_no_prompt("Do you really want to convert %s? [y/n]: ",
- lv->name) == 'n') {
+ display_lvname(lv)) == 'n') {
log_error("Conversion aborted.");
goto out;
}
- if (!wipe_lv(lv, (struct wipe_params) { .do_zero = 1, .do_wipe_signatures = 1,
- .yes = arg_count(cmd, yes_ARG),
- .force = arg_count(cmd, force_ARG)})) {
- log_error("Aborting. Failed to wipe VDO data store.");
- goto out;
+ if (zero_vdopool) {
+ if (!wipe_lv(lv, (struct wipe_params) { .do_zero = 1, .do_wipe_signatures = 1,
+ .yes = arg_count(cmd, yes_ARG),
+ .force = arg_count(cmd, force_ARG)})) {
+ log_error("Aborting. Failed to wipe VDO data store.");
+ goto out;
+ }
}
if (!archive(vg))
goto_out;
- if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents))
+ if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents, zero_vdopool))
goto_out;
dm_list_init(&lvc.tags);
* The --commandprofile is assumed otherwise.
*/
if (!strcmp(cmd->command->name, "lvcreate") ||
+ !strcmp(cmd->command->name, "lvconvert") ||
!strcmp(cmd->command->name, "vgcreate") ||
!strcmp(cmd->command->name, "lvchange") ||
!strcmp(cmd->command->name, "vgchange")) {