]> git.proxmox.com Git - pve-storage.git/commitdiff
fix #1816: rbd: add support for erasure coded ec pools
authorAaron Lauterer <a.lauterer@proxmox.com>
Fri, 28 Jan 2022 11:22:41 +0000 (12:22 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 4 Feb 2022 16:51:48 +0000 (17:51 +0100)
The first step is to allocate rbd images correctly.

The metadata objects still need to be stored in a replicated pool, but
by providing the --data-pool parameter on image creation, we can place
the data objects on the erasure coded (EC) pool.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
PVE/Storage/RBDPlugin.pm

index 2607d259d1ab20f0f430ee7d0083bcd77289c2ac..efb218777f3be88a600d49387f68715905210866 100644 (file)
@@ -289,6 +289,10 @@ sub properties {
            description => "Pool.",
            type => 'string',
        },
+       'data-pool' => {
+           description => "Data Pool (for erasure coding only)",
+           type => 'string',
+       },
        namespace => {
            description => "RBD Namespace.",
            type => 'string',
@@ -318,6 +322,7 @@ sub options {
        disable => { optional => 1 },
        monhost => { optional => 1},
        pool => { optional => 1 },
+       'data-pool' => { optional => 1 },
        namespace => { optional => 1 },
        username => { optional => 1 },
        content => { optional => 1 },
@@ -492,15 +497,10 @@ sub clone_image {
     my $newvol = "$basename/$name";
     $newvol = $name if length($snapname);
 
-    my $cmd = $rbd_cmd->(
-       $scfg,
-       $storeid,
-       'clone',
-       get_rbd_path($scfg, $basename),
-       '--snap',
-       $snap,
-       get_rbd_path($scfg, $name),
-    );
+    my @options = ('clone', get_rbd_path($scfg, $basename), '--snap', $snap);
+    push @options, ('--data-pool', $scfg->{'data-pool'}) if $scfg->{'data-pool'};
+    push @options, get_rbd_path($scfg, $name);
+    my $cmd = $rbd_cmd->($scfg, $storeid, @options);
 
     run_rbd_command($cmd, errmsg => "rbd clone '$basename' error");
 
@@ -516,7 +516,10 @@ sub alloc_image {
 
     $name = $class->find_free_diskname($storeid, $scfg, $vmid) if !$name;
 
-    my $cmd = $rbd_cmd->($scfg, $storeid, 'create', '--image-format' , 2, '--size', int(($size+1023)/1024), $name);
+    my @options = ('create', '--image-format' , 2, '--size', int(($size+1023)/1024));
+    push @options, ('--data-pool', $scfg->{'data-pool'}) if $scfg->{'data-pool'};
+    push @options, $name;
+    my $cmd = $rbd_cmd->($scfg, $storeid, @options);
     run_rbd_command($cmd, errmsg => "rbd create '$name' error");
 
     return $name;