zfspoolplugin: activate_storage: minor cleanup

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
Stoiko Ivanov
2021-02-19 13:45:42 +01:00
committed by Thomas Lamprecht
parent e49009efd8
commit a2d747a118

View File

@ -529,22 +529,20 @@ sub activate_storage {
$pool =~ s!/.*$!!; $pool =~ s!/.*$!!;
my $pool_imported = sub { my $pool_imported = sub {
my @param = ('-o', 'name', '-H', "$pool"); my @param = ('-o', 'name', '-H', $pool);
my $res = eval { $class->zfs_request($scfg, undef, 'zpool_list', @param) }; my $res = eval { $class->zfs_request($scfg, undef, 'zpool_list', @param) };
if ($@) { warn "$@\n" if $@;
warn "$@\n";
return undef;
}
return defined($res) && $res =~ m/$pool/; return defined($res) && $res =~ m/$pool/;
}; };
if (!$pool_imported->()) { if (!$pool_imported->()) {
# import can only be done if not yet imported! # import can only be done if not yet imported!
my @param = ('-d', '/dev/disk/by-id/', '-o', 'cachefile=none', "$pool"); my @param = ('-d', '/dev/disk/by-id/', '-o', 'cachefile=none', $pool);
eval { $class->zfs_request($scfg, undef, 'zpool_import', @param) }; eval { $class->zfs_request($scfg, undef, 'zpool_import', @param) };
if (my $err = $@) { if (my $err = $@) {
# just could've raced with another import, so recheck if it is imported # just could've raced with another import, so recheck if it is imported
die "could not activate storage '$storeid', $@\n" if !$pool_imported->(); die "could not activate storage '$storeid', $err\n" if !$pool_imported->();
} }
} }
return 1; return 1;