LVM: Add '--refresh' when activating volumes
From `man 8 lvchange`:
--refresh
If the logical volume is active, reload its metadata. This is not
necessary in normal operation, but may be useful ... if you're doing
clustering manually without a clustered lock manager.
Fixes migration in a shared LVM (iscsi) setup, where a disk gets resized on one
node A and the guest is afterwards migrated to another node B: B still presents
the old size to the guest, leading to data corruption.
It is necessary to run `lvchange` twice because the options `-ay` and
`--refresh` are mutually exclusive.
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
955c1f2cf7
commit
628a921a94
@ -362,6 +362,8 @@ sub free_image {
|
|||||||
|
|
||||||
my $cmd = ['/sbin/lvchange', '-aly', "$vg/$volname"];
|
my $cmd = ['/sbin/lvchange', '-aly', "$vg/$volname"];
|
||||||
run_command($cmd, errmsg => "can't activate LV '$vg/$volname' to zero-out its data");
|
run_command($cmd, errmsg => "can't activate LV '$vg/$volname' to zero-out its data");
|
||||||
|
$cmd = ['/sbin/lvchange', '--refresh', "$vg/$volname"];
|
||||||
|
run_command($cmd, errmsg => "can't refresh LV '$vg/$volname' to zero-out its data");
|
||||||
|
|
||||||
if ($scfg->{saferemove}) {
|
if ($scfg->{saferemove}) {
|
||||||
# avoid long running task, so we only rename here
|
# avoid long running task, so we only rename here
|
||||||
@ -472,6 +474,8 @@ sub activate_volume {
|
|||||||
|
|
||||||
my $cmd = ['/sbin/lvchange', "-a$lvm_activate_mode", $path];
|
my $cmd = ['/sbin/lvchange', "-a$lvm_activate_mode", $path];
|
||||||
run_command($cmd, errmsg => "can't activate LV '$path'");
|
run_command($cmd, errmsg => "can't activate LV '$path'");
|
||||||
|
$cmd = ['/sbin/lvchange', '--refresh', $path];
|
||||||
|
run_command($cmd, errmsg => "can't refresh LV '$path' for activation");
|
||||||
}
|
}
|
||||||
|
|
||||||
sub deactivate_volume {
|
sub deactivate_volume {
|
||||||
|
|||||||
Reference in New Issue
Block a user