Fix circular dependency when attempting vgimport on VG with missing PVs
PATCH 1/1 Fix circular dependency when attempting vgimport on VG with missing PVs
Is there any reason why 'vgimport' should not be allowed to alter the metadata in order to import a VG with missing PVs? I can't think of any.
brassow
TOOLS: Fix inablility to vgimport VGs with missing PVs
When there are missing PVs in a volume group, most operations that alter the LVM metadata are disallowed. It turns out that 'vgimport' is one of those disallowed operations. This is bad because it creates a circular dependency. 'vgimport' will complain that the VG is inconsistent and that 'vgreduce --removemissing' must be run. However, 'vgreduce' cannot be run because it has not been imported. Therefore, 'vgimport' must be one of the operations allowed to change the metadata when PVs are missing.
tools/vgimport.c +9 -0
@@ -68,6 +68,15 @@ int vgimport(struct cmd_context *cmd, inreturn ECMD_FAILED ; } +/* +* Allow a VG to be imported even when there are missing PVs. If +* we don't, a circular dependency is created. The vgimport will +* complain that the VG is not consistent and 'vgreduce --removemissing' +* should be used. However, 'vgreduce' cannot be used because the +* VG hasn't been imported. +*/ + cmd->handles_missing_pvs =1 ; + return process_each_vg(cmd, argc, argv, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, NULL,
PATCH v2 1/1 Fix circular dependency when attempting vgimport on VG with missing PVs
This patch makes the user supply '--force' in order to import volume groups with missing PVs.
brassow
TOOLS: Fix inablility to vgimport VGs with missing PVs
When there are missing PVs in a volume group, most operations that alter the LVM metadata are disallowed. It turns out that 'vgimport' is one of those disallowed operations. This is bad because it creates a circular dependency. 'vgimport' will complain that the VG is inconsistent and that 'vgreduce --removemissing' must be run. However, 'vgreduce' cannot be run because it has not been imported. Therefore, 'vgimport' must be one of the operations allowed to change the metadata when PVs are missing.
tools/vgimport.c +17 -0
@@ -68,6 +68,23 @@ int vgimport(struct cmd_context *cmd, inreturn ECMD_FAILED ; } +if (arg_count (cmd, force_ARG)) { +/* +* The volume group cannot be repaired unless it is first +* imported. If we don't allow the user a way to import the +* VG while it is 'partial', then we will have created a +* circular dependency. +* +* The reason we don't just simply set 'handles_missing_pvs' +* by default is that we want to guard against the case +* where the user simply forgot to move one or more disks in +* the VG before running 'vgimport'. +*/ +log_print ("'--force' supplied. Volume groups with missing PVs" +" will be imported." ); + cmd->handles_missing_pvs =1 ; + } + return process_each_vg(cmd, argc, argv, READ_FOR_UPDATE | READ_ALLOW_EXPORTED, NULL,
man/vgimport.8.in +3 -0
@@ -20,6 +20,9 @@ See \fBlvm\fP(8) for common options. .TP .BR \-a ", " \-\-all Import all exported Volume Groups. +.TP +.BR \-\-force +Import exported Volume Groups even if there are missing Physical Volumes. .SH SEE ALSO .BR lvm (8), .BR pvscan (8),