avoid call to lvs when deactivating devices

Because this can be slow if there are many devices.
This commit is contained in:
Dietmar Maurer
2012-04-23 06:31:04 +02:00
parent 75d75990b4
commit 5c009b733e

View File

@ -1981,8 +1981,6 @@ sub deactivate_volumes {
return if !($vollist && scalar(@$vollist));
my $lvs = lvm_lvs ();
my @errlist = ();
foreach my $volid (@$vollist) {
my ($storeid, $volname) = parse_volume_id ($volid);
@ -1990,10 +1988,9 @@ sub deactivate_volumes {
my $scfg = storage_config ($cfg, $storeid);
if ($scfg->{type} eq 'lvm') {
my ($name) = parse_volname_lvm ($volname);
if ($lvs->{$scfg->{vgname}}->{$name}) {
my $path = path ($cfg, $volid);
next if ! -b $path;
my $cmd = ['/sbin/lvchange', '-aln', $path];
eval { run_command($cmd, errmsg => "can't deactivate LV '$volid'"); };
if (my $err = $@) {
@ -2002,7 +1999,6 @@ sub deactivate_volumes {
}
}
}
}
die "volume deativation failed: " . join(' ', @errlist)
if scalar(@errlist);