From 6703353bb8f28c298624d74281f95dabfa28aa91 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 25 Nov 2011 07:27:25 +0100 Subject: [PATCH] do not activate LVM volumes with vgchange -aly --- Makefile | 2 +- PVE/Storage.pm | 28 ++++++++++++++++++++-------- changelog.Debian | 8 ++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 4e34d47..362065c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ RELEASE=2.0 VERSION=2.0 PACKAGE=libpve-storage-perl -PKGREL=6 +PKGREL=7 DESTDIR= PREFIX=/usr diff --git a/PVE/Storage.pm b/PVE/Storage.pm index 6b73557..6d3a1c7 100755 --- a/PVE/Storage.pm +++ b/PVE/Storage.pm @@ -1877,8 +1877,8 @@ sub __activate_storage_full { warn $@ if $@; } - my $cmd = ['/sbin/vgchange', '-aly', $scfg->{vgname}]; - run_command ($cmd, outfunc => sub {}); + # we do not acticate any volumes here ('vgchange -aly') + # instead, volumes are activate individually later } elsif ($type eq 'iscsi') { @@ -1931,7 +1931,11 @@ sub activate_storage { } sub activate_volumes { - my ($cfg, $vollist) = @_; + my ($cfg, $vollist, $exclusive) = @_; + + return if !($vollist && scalar(@$vollist)); + + my $lvm_activate_mode = $exclusive ? 'ey' : 'ly'; my $storagehash = {}; foreach my $volid (@$vollist) { @@ -1949,9 +1953,8 @@ sub activate_volumes { my $path = path ($cfg, $volid); if ($scfg->{type} eq 'lvm') { - my $cmd = ['/sbin/lvchange', '-aly', $path]; - eval { run_command ($cmd); }; - warn $@ if $@; + my $cmd = ['/sbin/lvchange', "-a$lvm_activate_mode", $path]; + run_command($cmd, errmsg => "can't activate LV '$volid'"); } # check is volume exists @@ -1966,8 +1969,11 @@ sub activate_volumes { sub deactivate_volumes { my ($cfg, $vollist) = @_; + return if !($vollist && scalar(@$vollist)); + my $lvs = lvm_lvs (); + my @errlist = (); foreach my $volid (@$vollist) { my ($storeid, $volname) = parse_volume_id ($volid); @@ -1979,11 +1985,17 @@ sub deactivate_volumes { if ($lvs->{$scfg->{vgname}}->{$name}) { my $path = path ($cfg, $volid); my $cmd = ['/sbin/lvchange', '-aln', $path]; - eval { run_command ($cmd); }; - warn $@ if $@; + eval { run_command ($cmd, errmsg => "can't deactivate LV '$volid'"); }; + if (my $err = $@) { + warn $err; + push @errlist, $volid; + } } } } + + die "volume deativation failed: " . join(' ', @errlist) + if scalar(@errlist); } sub deactivate_storage { diff --git a/changelog.Debian b/changelog.Debian index 419f6b9..eeda735 100644 --- a/changelog.Debian +++ b/changelog.Debian @@ -1,3 +1,11 @@ +libpve-storage-perl (2.0-7) unstable; urgency=low + + * improve error messages + + * do not activate LVM volumes with 'vgchange -aly' + + -- Proxmox Support Team Fri, 25 Nov 2011 07:25:58 +0100 + libpve-storage-perl (2.0-6) unstable; urgency=low * improved container support