[pve-devel] [PATCH 08/09] When resizing a disk also resize the LUN.

mir at datanom.net mir at datanom.net
Mon Aug 12 19:55:34 CEST 2013


From: Michael Rasmussen <mir at datanom.net>

Signed-off-by: Michael Rasmussen <mir at datanom.net>
---
 PVE/Storage/ZFSPlugin.pm | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index a562635..c5bf8c4 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -33,6 +33,7 @@ sub zfs_request {
 			create_lu	=> 'create-lu',
 			delete_lu	=> 'delete-lu',
 			import_lu	=> 'import-lu',
+			modify_lu	=> 'modify-lu',
 			add_view	=> 'add-view',
 			list_view	=> 'list-view',
 		};
@@ -251,6 +252,15 @@ sub zfs_import_lu {
     zfs_request($scfg, 'import_lu', "/dev/zvol/rdsk/$scfg->{pool}/$zvol");
 }
 
+sub zfs_resize_lu {
+	my ($scfg, $zvol, $size) = @_;
+
+	my $luns = zfs_list_lun_mapping_entries($scfg, $zvol);
+	die "Could not find any LUN's" if (! defined($luns));
+
+	zfs_request($scfg, 'modify_lu', '-s', "${size}K", @$luns[0]->{lun});
+}
+
 sub zfs_create_zvol {
     my ($scfg, $zvol, $size) = @_;
 
@@ -605,8 +615,10 @@ sub volume_size_info {
 
 sub volume_resize {
     my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
-
-    zfs_request($scfg, 'set', 'volsize=' . ($size/1024) . 'k', "$scfg->{pool}/$volname");
+	my $new_size = ($size/1024);
+	
+    zfs_request($scfg, 'set', 'volsize=' . $new_size . 'k', "$scfg->{pool}/$volname");
+	zfs_resize_lu($scfg, $volname, $new_size);
 }
 
 sub volume_snapshot {
-- 
1.8.4.rc2




More information about the pve-devel mailing list