[pve-devel] [PATCH] zfs: fixV2 wait by alloc_image

Wolfgang Link w.link at proxmox.com
Wed Jan 28 10:37:58 CET 2015


Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
 PVE/Storage/ZFSPlugin.pm     |    9 ++++++++-
 PVE/Storage/ZFSPoolPlugin.pm |    7 +++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 581ef6c..d8acce9 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -265,7 +265,14 @@ sub clone_image {
 sub alloc_image {
     my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
     
-    my $volname = $class->SUPER::alloc_image($storeid, $scfg, $vmid, $fmt, $name, $size);
+    die "unsupported format '$fmt'" if $fmt ne 'raw';
+
+    die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
+    if $name && $name !~ m/^vm-$vmid-/;
+
+    my $volname = $class->zfs_find_free_diskname($storeid, $scfg, $vmid) if !$name;
+    
+    $class->zfs_create_zvol($scfg, $name, $size);
  
     my $guid = $class->zfs_create_lu($scfg, $volname);
     $class->zfs_add_lun_mapping_entry($scfg, $volname, $guid);
diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 10da7f7..490b61c 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -184,6 +184,13 @@ sub alloc_image {
     $name = $class->zfs_find_free_diskname($storeid, $scfg, $vmid) if !$name;
     
     $class->zfs_create_zvol($scfg, $name, $size);
+    run_command ("udevadm trigger --subsystem-match block");
+    run_command ("udevadm settle --timeout 5");
+    
+    for (1..10) {
+       last if -e "/dev/zvol/$scfg->{pool}/$name" ;
+       Time::HiRes::usleep(100);
+    }
 
     return $name;
 }
-- 
1.7.10.4




More information about the pve-devel mailing list