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

thin: allow restore with --force

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.
This commit is contained in:
Zdenek Kabelac 2012-11-26 23:45:35 +01:00
parent c7a7fd0a12
commit 09b7ceea95
7 changed files with 33 additions and 14 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 - Version 2.02.99 -
=================================== ===================================
Allow forced vgcfgrestore of lvm2 metadata with thin volumes.
Recognise STEC skd devices in filter. Recognise STEC skd devices in filter.
Recognise Violin Memory vtms devices in filter. Recognise Violin Memory vtms devices in filter.
Add lvm.conf thin pool defs thin_pool_{chunk_size|discards|zero}. Add lvm.conf thin pool defs thin_pool_{chunk_size|discards|zero}.

View File

@ -347,7 +347,7 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
/* ORPHAN and VG locks held before calling this */ /* ORPHAN and VG locks held before calling this */
int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name, 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; struct volume_group *vg;
int missing_pvs, r = 0; int missing_pvs, r = 0;
@ -360,14 +360,20 @@ int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
return_0; return_0;
/* FIXME: Restore support is missing for now */ /* 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)) { if (lv_is_thin_type(lvl->lv)) {
log_error("Cannot restore Volume Group %s with " if (!force) {
"thin logical volumes. " log_error("Consider using option --force to restore "
"(not yet supported).", vg->name); "Volume Group %s with thin volumes.",
r = 0; vg->name);
goto out; 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); missing_pvs = vg_missing_pv_count(vg);
if (missing_pvs == 0) if (missing_pvs == 0)
@ -381,7 +387,7 @@ out:
return r; 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]; char path[PATH_MAX];
@ -391,7 +397,7 @@ int backup_restore(struct cmd_context *cmd, const char *vg_name)
return 0; 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) int backup_to_file(const char *file, const char *desc, struct volume_group *vg)

View File

@ -53,8 +53,8 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
const char *vg_name, const char *file); const char *vg_name, const char *file);
int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg); 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, int backup_restore_from_file(struct cmd_context *cmd, const char *vg_name,
const char *file); const char *file, int force);
int backup_restore(struct cmd_context *cmd, const char *vg_name); 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); int backup_to_file(const char *file, const char *desc, struct volume_group *vg);

View File

@ -6,6 +6,7 @@ vgcfgrestore \- restore volume group descriptor area
.RB [ \-d | \-\-debug ] .RB [ \-d | \-\-debug ]
.RB [ \-f | \-\-file .RB [ \-f | \-\-file
.RI < filename >] .RI < filename >]
.RB [ \-\-force ]
.RB [ \-l [ l ]| \-\-list ] .RB [ \-l [ l ]| \-\-list ]
.RB [ \-h | \-\-help ] .RB [ \-h | \-\-help ]
.RB [ \-M | \-\-metadatatype .RB [ \-M | \-\-metadatatype
@ -32,6 +33,14 @@ May be used with the \fB\-f\fP option. Does not restore \fIVolumeGroupName\fP.
Name of LVM metadata backup file Name of LVM metadata backup file
Specifies a metadata backup or archive file to be used for restoring Specifies a metadata backup or archive file to be used for restoring
VolumeGroupName. Often this file has been created with \fBvgcfgbackup\fP. 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 .SH REPLACING PHYSICAL VOLUMES
\fBvgdisplay \-\-partial \-\-verbose\fP will show you the UUIDs and sizes of \fBvgdisplay \-\-partial \-\-verbose\fP will show you the UUIDs and sizes of
any PVs that are no longer present. any PVs that are no longer present.

View File

@ -73,6 +73,7 @@ arg(poll_ARG, '\0', "poll", yes_no_arg, 0)
arg(poolmetadata_ARG, '\0', "poolmetadata", string_arg, 0) arg(poolmetadata_ARG, '\0', "poolmetadata", string_arg, 0)
arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0) arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0)
arg(discards_ARG, '\0', "discards", discards_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(stripes_long_ARG, '\0', "stripes", int_arg, 0)
arg(sysinit_ARG, '\0', "sysinit", NULL, 0) arg(sysinit_ARG, '\0', "sysinit", NULL, 0)
arg(thinpool_ARG, '\0', "thinpool", string_arg, 0) arg(thinpool_ARG, '\0', "thinpool", string_arg, 0)

View File

@ -725,6 +725,7 @@ xx(vgcfgrestore,
"vgcfgrestore " "\n" "vgcfgrestore " "\n"
"\t[-d|--debug] " "\n" "\t[-d|--debug] " "\n"
"\t[-f|--file filename] " "\n" "\t[-f|--file filename] " "\n"
"\t[--force]\n"
"\t[-l[l]|--list [--list]]" "\n" "\t[-l[l]|--list [--list]]" "\n"
"\t[-M|--metadatatype 1|2]" "\n" "\t[-M|--metadatatype 1|2]" "\n"
"\t[-h|--help]" "\n" "\t[-h|--help]" "\n"
@ -733,7 +734,7 @@ xx(vgcfgrestore,
"\t[--version] " "\n" "\t[--version] " "\n"
"\tVolumeGroupName", "\tVolumeGroupName",
file_ARG, list_ARG, metadatatype_ARG, test_ARG) file_ARG, force_long_ARG, list_ARG, metadatatype_ARG, test_ARG)
xx(vgchange, xx(vgchange,
"Change volume group attributes", "Change volume group attributes",

View File

@ -62,8 +62,9 @@ int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
if (!(arg_count(cmd, file_ARG) ? if (!(arg_count(cmd, file_ARG) ?
backup_restore_from_file(cmd, vg_name, backup_restore_from_file(cmd, vg_name,
arg_str_value(cmd, file_ARG, "")) : arg_str_value(cmd, file_ARG, ""),
backup_restore(cmd, vg_name))) { 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_ORPHANS);
unlock_vg(cmd, vg_name); unlock_vg(cmd, vg_name);
log_error("Restore failed."); log_error("Restore failed.");