[pve-devel] [PATCH] ZFSPoolPlugin: Added the ability to use nested ZVOLs

Pablo Ruiz pablo.ruiz at gmail.com
Thu Feb 12 20:33:02 CET 2015


Hi,

AFAIK having a setting to control wether auto-import of pool is desirable
would be a plus. As in some situations the import/export of the pool is
controlled by any other means, and an accidental pool of the pool may be a
destructive action (ie. when the pool maybe from a shared medium like
iscsi, and thus should not be mounted by two nodes at the same time).

Regards

On Thu, Feb 12, 2015 at 8:27 PM, Adrian Costin <adrian at goat.fish> wrote:

> - Moved the zpool_import method of zfs_request() to it's own pool_request
> function
> - activate_storage() is now using "zfs list" to check if the zpool is
> imported
> - pool import only the configured pool, not all the accessible pools
>
> Signed-off-by: Adrian Costin <adrian at goat.fish>
> ---
>  PVE/Storage/ZFSPoolPlugin.pm | 39 +++++++++++++++++++++++++++------------
>  1 file changed, 27 insertions(+), 12 deletions(-)
>
> diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
> index 5cbd1b2..3fc2978 100644
> --- a/PVE/Storage/ZFSPoolPlugin.pm
> +++ b/PVE/Storage/ZFSPoolPlugin.pm
> @@ -149,16 +149,27 @@ sub zfs_request {
>
>      $timeout = 5 if !$timeout;
>
> -    my $cmd = [];
> +    my $cmd = ['zfs', $method, @params];
>
> -    if ($method eq 'zpool_list') {
> -       push @$cmd, 'zpool', 'list';
> -    } else {
> -       push @$cmd, 'zfs', $method;
> -    }
> +    my $msg = '';
> +
> +    my $output = sub {
> +        my $line = shift;
> +        $msg .= "$line\n";
> +    };
> +
> +    run_command($cmd, outfunc => $output, timeout => $timeout);
> +
> +    return $msg;
> +}
> +
> +sub zpool_request {
> +    my ($class, $scfg, $timeout, $method, @params) = @_;
> +
> +    $timeout = 5 if !$timeout;
> +
> +    my $cmd = ['zpool', $method, @params];
>
> -    push @$cmd, @params;
> -
>      my $msg = '';
>
>      my $output = sub {
> @@ -428,12 +439,16 @@ sub volume_rollback_is_possible {
>  sub activate_storage {
>      my ($class, $storeid, $scfg, $cache) = @_;
>
> -    my @param = ('-o', 'name', '-H');
> +    my @param = ('-o', 'name', '-H', $scfg->{'pool'});
> +
> +    my $text = zfs_request($class, $scfg, undef, 'list', @param);
>
> -    my $text = zfs_request($class, $scfg, undef, 'zpool_list', @param);
> -
>      if ($text !~ $scfg->{pool}) {
> -       run_command("zpool import -d /dev/disk/by-id/ -a");
> +       my ($pool_name) = $scfg->{pool} =~ /([^\/]+)/;
> +
> +       my @import_params = ('-d', '/dev/disk/by-id/', $pool_name);
> +
> +       zpool_request($class, $scfg, undef, 'import', @import_params);
>      }
>      return 1;
>  }
> --
> 1.9.3 (Apple Git-50)
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.proxmox.com/pipermail/pve-devel/attachments/20150212/b6a3cefa/attachment.htm>


More information about the pve-devel mailing list