[pve-devel] [PATCH pve-storage 1/2] add zfs_get_subvol_size: on container we are useing subvol.
Wolfgang Link
w.link at proxmox.com
Wed Oct 7 14:14:13 CEST 2015
---
PVE/Storage/ZFSPoolPlugin.pm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 8002dda..72dfd0f 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -308,6 +308,18 @@ sub zfs_get_zvol_size {
die "Could not get zvol size";
}
+sub zfs_get_subvol_size {
+ my ($class, $scfg, $zvol) = @_;
+
+ my $text = $class->zfs_request($scfg, undef, 'get', '-Hp', 'refquota', "$scfg->{pool}/$zvol");
+
+ if ($text =~ /refquota\s(\d+)/) {
+ return $1;
+ }
+
+ die "Could not get refquota size\n";
+}
+
sub zfs_create_zvol {
my ($class, $scfg, $zvol, $size) = @_;
@@ -449,8 +461,12 @@ sub status {
sub volume_size_info {
my ($class, $scfg, $storeid, $volname, $timeout) = @_;
-
- return $class->zfs_get_zvol_size($scfg, $volname);
+ if ($volname =~ m/^vm-\d\d\d+-disk-\d+$/) {
+ return $class->zfs_get_zvol_size($scfg, $volname);
+ } elsif ($volname =~ m/^subvol-\d\d\d+-disk-\d+$/) {
+ return $class->zfs_get_subvol_size($scfg, $volname);
+ }
+ die "Unable to identify volume type\n";
}
sub volume_snapshot {
--
2.1.4
More information about the pve-devel
mailing list