Allow restoring metadata with thin pool volumes.
No validation is done for this case within vgcfgrestore tool -
thus incorrect metadata may lead to destruction of pool content.
Version 2.02.99 -
===================================
+ Allow forced vgcfgrestore of lvm2 metadata with thin volumes.
Recognise STEC skd devices in filter.
Recognise Violin Memory vtms devices in filter.
Add lvm.conf thin pool defs thin_pool_{chunk_size|discards|zero}.
/* ORPHAN and VG locks held before calling this */
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
- const char *file)
+ const char *file, int force)
{
struct volume_group *vg;
int missing_pvs, r = 0;
return_0;
/* FIXME: Restore support is missing for now */
- dm_list_iterate_items(lvl, &vg->lvs)
+ dm_list_iterate_items(lvl, &vg->lvs) {
if (lv_is_thin_type(lvl->lv)) {
- log_error("Cannot restore Volume Group %s with "
- "thin logical volumes. "
- "(not yet supported).", vg->name);
- r = 0;
- goto out;
+ if (!force) {
+ log_error("Consider using option --force to restore "
+ "Volume Group %s with thin volumes.",
+ vg->name);
+ goto out;
+ } else {
+ log_warn("WARNING: Forced restore of Volume Group "
+ "%s with thin volumes.", vg->name);
+ break;
+ }
}
+ }
missing_pvs = vg_missing_pv_count(vg);
if (missing_pvs == 0)
return r;
}
-int backup_restore(struct cmd_context *cmd, const char *vg_name)
+int backup_restore(struct cmd_context *cmd, const char *vg_name, int force)
{
char path[PATH_MAX];
return 0;
}
- return backup_restore_from_file(cmd, vg_name, path);
+ return backup_restore_from_file(cmd, vg_name, path, force);
}
int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
const char *vg_name, const char *file);
int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg);
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
- const char *file);
-int backup_restore(struct cmd_context *cmd, const char *vg_name);
+ const char *file, int force);
+int backup_restore(struct cmd_context *cmd, const char *vg_name, int force);
int backup_to_file(const char *file, const char *desc, struct volume_group *vg);
.RB [ \-d | \-\-debug ]
.RB [ \-f | \-\-file
.RI < filename >]
+.RB [ \-\-force ]
.RB [ \-l [ l ]| \-\-list ]
.RB [ \-h | \-\-help ]
.RB [ \-M | \-\-metadatatype
Name of LVM metadata backup file
Specifies a metadata backup or archive file to be used for restoring
VolumeGroupName. Often this file has been created with \fBvgcfgbackup\fP.
+.TP
+.B \-\-force
+To restore metadata with thin pool volumes, user currently
+needs to use this flag. The tool DOES NOT make any validation.
+.br
+WARNING: Restoring lvm2 metadata that are not matching thin pool
+kernel metadata may lead to the destruction of the pool content.
+Use with extreme caution.
.SH REPLACING PHYSICAL VOLUMES
\fBvgdisplay \-\-partial \-\-verbose\fP will show you the UUIDs and sizes of
any PVs that are no longer present.
arg(poolmetadata_ARG, '\0', "poolmetadata", string_arg, 0)
arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0)
arg(discards_ARG, '\0', "discards", discards_arg, 0)
+arg(force_long_ARG, '\0', "force", NULL, ARG_COUNTABLE)
arg(stripes_long_ARG, '\0', "stripes", int_arg, 0)
arg(sysinit_ARG, '\0', "sysinit", NULL, 0)
arg(thinpool_ARG, '\0', "thinpool", string_arg, 0)
"vgcfgrestore " "\n"
"\t[-d|--debug] " "\n"
"\t[-f|--file filename] " "\n"
+ "\t[--force]\n"
"\t[-l[l]|--list [--list]]" "\n"
"\t[-M|--metadatatype 1|2]" "\n"
"\t[-h|--help]" "\n"
"\t[--version] " "\n"
"\tVolumeGroupName",
- file_ARG, list_ARG, metadatatype_ARG, test_ARG)
+ file_ARG, force_long_ARG, list_ARG, metadatatype_ARG, test_ARG)
xx(vgchange,
"Change volume group attributes",
if (!(arg_count(cmd, file_ARG) ?
backup_restore_from_file(cmd, vg_name,
- arg_str_value(cmd, file_ARG, "")) :
- backup_restore(cmd, vg_name))) {
+ arg_str_value(cmd, file_ARG, ""),
+ arg_count(cmd, force_long_ARG)) :
+ backup_restore(cmd, vg_name, arg_count(cmd, force_long_ARG)))) {
unlock_vg(cmd, VG_ORPHANS);
unlock_vg(cmd, vg_name);
log_error("Restore failed.");