]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Storage/ZFSPoolPlugin.pm
add sparseinit to has_feature
[pve-storage.git] / PVE / Storage / ZFSPoolPlugin.pm
index 75704b048fa67cd86887b16c5fa7dbf25d2afc3c..7011accfe868493bd265afc926e4667214c2f8b7 100644 (file)
@@ -41,7 +41,6 @@ sub options {
        sparse => { optional => 1 },
        nodes => { optional => 1 },
        disable => { optional => 1 },
-        maxfiles => { optional => 1 },
        content => { optional => 1 },
     };
 }
@@ -296,18 +295,6 @@ sub zfs_get_pool_stats {
     return ($available, $used);
 }
 
-sub zfs_get_zvol_size {
-    my ($class, $scfg, $zvol) = @_;
-
-    my $text = $class->zfs_request($scfg, undef, 'get', '-Hp', 'volsize', "$scfg->{pool}/$zvol");
-
-    if ($text =~ /volsize\s(\d+)/) {
-       return $1;
-    }
-
-    die "Could not get zvol size";
-}
-
 sub zfs_create_zvol {
     my ($class, $scfg, $zvol, $size) = @_;
     
@@ -327,7 +314,8 @@ sub zfs_create_subvol {
 
     my $dataset = "$scfg->{pool}/$volname";
     
-    my $cmd = ['create', '-o', "refquota=${size}k", $dataset];
+    my $cmd = ['create', '-o', 'acltype=posixacl', '-o', 'xattr=sa',
+              '-o', "refquota=${size}k", $dataset];
 
     $class->zfs_request($scfg, undef, @$cmd);
 }
@@ -415,7 +403,7 @@ sub zfs_get_latest_snapshot {
 
     # abort rollback if snapshot is not the latest
     my @params = ('-t', 'snapshot', '-o', 'name', '-s', 'creation');
-    my $text = zfs_request($class, $scfg, undef, 'list', @params);
+    my $text = $class->zfs_request($scfg, undef, 'list', @params);
     my @snapshots = split(/\n/, $text);
 
     my $recentsnap;
@@ -450,7 +438,17 @@ sub status {
 sub volume_size_info {
     my ($class, $scfg, $storeid, $volname, $timeout) = @_;
 
-    return $class->zfs_get_zvol_size($scfg, $volname);
+    my (undef, undef, undef, undef, undef, undef, $format) =
+        $class->parse_volname($volname);
+
+    my $attr = $format eq 'subvol' ? 'refquota' : 'volsize';
+    my $text = $class->zfs_request($scfg, undef, 'get', '-Hp', $attr, "$scfg->{pool}/$volname");
+
+    if ($text =~ /\s$attr\s(\d+)\s/) {
+       return $1;
+    }
+
+    die "Could not get zfs volume size\n";
 }
 
 sub volume_snapshot {
@@ -462,13 +460,14 @@ sub volume_snapshot {
 sub volume_snapshot_delete {
     my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
 
+    $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
     $class->zfs_request($scfg, undef, 'destroy', "$scfg->{pool}/$volname\@$snap");
 }
 
 sub volume_snapshot_rollback {
     my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
-    zfs_request($class, $scfg, undef, 'rollback', "$scfg->{pool}/$volname\@$snap");
+    $class->zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$volname\@$snap");
 }
 
 sub volume_rollback_is_possible {
@@ -487,7 +486,7 @@ sub activate_storage {
 
     my @param = ('-o', 'name', '-H');
 
-    my $text = zfs_request($class, $scfg, undef, 'zpool_list', @param);
+    my $text = $class->zfs_request($scfg, undef, 'zpool_list', @param);
 
     # Note: $scfg->{pool} can include dataset <pool>/<dataset>
     my $pool = $scfg->{pool};
@@ -505,12 +504,12 @@ sub deactivate_storage {
 }
 
 sub activate_volume {
-    my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
     return 1;
 }
 
 sub deactivate_volume {
-    my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+    my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
     return 1;
 }
 
@@ -558,9 +557,14 @@ sub create_base {
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
 
-    my $new_size = ($size/1024);
+    my $new_size = int($size/1024);
+
+    my (undef, undef, undef, undef, undef, undef, $format) =
+        $class->parse_volname($volname);
+
+    my $attr = $format eq 'subvol' ? 'refquota' : 'volsize';
 
-    $class->zfs_request($scfg, undef, 'set', 'volsize=' . $new_size . 'k', "$scfg->{pool}/$volname");
+    $class->zfs_request($scfg, undef, 'set', "$attr=${new_size}k", "$scfg->{pool}/$volname");
 
     return $new_size;
 }
@@ -573,6 +577,7 @@ sub volume_has_feature {
        clone => { base => 1},
        template => { current => 1},
        copy => { base => 1, current => 1},
+       sparseinit => { base => 1, current => 1},
     };
 
     my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =