[pve-devel] r6358 - in pve-storage/pve2: . PVE PVE/API2/Storage

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Jul 25 07:33:28 CEST 2011


Author: dietmar
Date: 2011-07-25 07:33:28 +0200 (Mon, 25 Jul 2011)
New Revision: 6358

Modified:
   pve-storage/pve2/ChangeLog
   pve-storage/pve2/Makefile
   pve-storage/pve2/PVE/API2/Storage/Scan.pm
   pve-storage/pve2/PVE/Storage.pm
   pve-storage/pve2/changelog.Debian
Log:
backport fixes (multipath, cache) from stable


Modified: pve-storage/pve2/ChangeLog
===================================================================
--- pve-storage/pve2/ChangeLog	2011-07-22 11:48:40 UTC (rev 6357)
+++ pve-storage/pve2/ChangeLog	2011-07-25 05:33:28 UTC (rev 6358)
@@ -1,3 +1,24 @@
+2010-11-08  Proxmox Support Team  <support at proxmox.com>
+
+	* Storage.pm (iscsi_login): multipath fixes: try to log in to all
+	portals (backport from stable)
+
+2010-10-28  Proxmox Support Team  <support at proxmox.com>
+
+	* Storage.pm (iscsi_session_list): allow several sessions per
+	target (multipath)(backport from stable). 
+	(iscsi_session_rescan): rescan all sessions (backport from stable)
+
+2010-09-13  Proxmox Support Team  <support at proxmox.com>
+
+	* Storage.pm (storage_info): cache VGs, mountdata and iSCSI
+	session list (backport from stable)
+
+2010-05-06  Proxmox Support Team  <support at proxmox.com>
+
+	* Storage.pm (storage_migrate): use --sparse and --whole-file,
+	this alsocreates sparse files (backport from stable)
+
 2011-07-22  Proxmox Support Team  <support at proxmox.com>
 
 	* PVE/API2/Storage/Scan.pm: split scan into three different

Modified: pve-storage/pve2/Makefile
===================================================================
--- pve-storage/pve2/Makefile	2011-07-22 11:48:40 UTC (rev 6357)
+++ pve-storage/pve2/Makefile	2011-07-25 05:33:28 UTC (rev 6358)
@@ -2,7 +2,7 @@
 
 VERSION=2.0
 PACKAGE=libpve-storage-perl
-PKGREL=1
+PKGREL=2
 
 DESTDIR=
 PREFIX=/usr

Modified: pve-storage/pve2/PVE/API2/Storage/Scan.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Scan.pm	2011-07-22 11:48:40 UTC (rev 6357)
+++ pve-storage/pve2/PVE/API2/Storage/Scan.pm	2011-07-25 05:33:28 UTC (rev 6358)
@@ -112,7 +112,7 @@
 
 	my $data = [];
 	foreach my $k (keys %$res) {
-	    push @$data, { target => $k, portal => $res->{$k} };
+	    push @$data, { target => $k, portal => join(',', @{$res->{$k}}) };
 	}
 
 	return $data;

Modified: pve-storage/pve2/PVE/Storage.pm
===================================================================
--- pve-storage/pve2/PVE/Storage.pm	2011-07-22 11:48:40 UTC (rev 6357)
+++ pve-storage/pve2/PVE/Storage.pm	2011-07-25 05:33:28 UTC (rev 6358)
@@ -715,7 +715,9 @@
 
 	if ($line =~ m/^tcp:\s+\[(\S+)\]\s+\S+\s+(\S+)\s*$/) {
 	    my ($session, $target) = ($1, $2);
-	    $res->{$target} = $session;
+	    # there can be several sessions per target (multipath)
+	    push @{$res->{$target}}, $session;
+
 	}
     });
 
@@ -737,7 +739,8 @@
 	if ($line =~ m/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+)\,\S+\s+(\S+)\s*$/) {
 	    my $portal = $1;
 	    my $target = $2;
-	    $res->{$target} = $portal;
+	    # one target can have more than one portal (multipath).
+	    push @{$res->{$target}}, $portal;
 	}
     });
 
@@ -745,15 +748,20 @@
 }
 
 sub iscsi_login {
-    my ($target, $portal) = @_;
+    my ($target, $portal_in) = @_;
 
     check_iscsi_support ();
 
-    iscsi_discovery ($portal);
+    my $res = iscsi_discovery ($portal_in);
 
-    my $cmd = [$ISCSIADM, '--mode', 'node', '--portal', $portal, 
-	       '--targetname',  $target, '--login'];
-    run_command ($cmd);
+    my $success = 0;
+    foreach my $portal (@{$res->{$target}}) {
+	my $cmd = [$ISCSIADM, '--mode', 'node', '--portal', $portal, 
+		   '--targetname',  $target, '--login'];
+	eval { run_command ($cmd); $success = 1; };
+	warn $@ if $@;
+    }
+    die "iscsi login failed\n" if !$success;
 }
 
 sub iscsi_logout {
@@ -769,7 +777,7 @@
 my $rescan_filename = "/var/run/pve-iscsi-rescan.lock";
 
 sub iscsi_session_rescan {
-    my $session = shift;
+    my $session_list = shift;
 
     check_iscsi_support ();
 
@@ -788,9 +796,11 @@
 	utime undef, undef, $rescan_filename;
     }
 
-    my $cmd = [$ISCSIADM, '--mode', 'session', '-r', $session, '-R'];
-    eval { run_command ($cmd, outfunc => sub {}); };
-    warn $@ if $@;
+    foreach my $session (@$session_list) {
+	my $cmd = [$ISCSIADM, '--mode', 'session', '-r', $session, '-R'];
+	eval { run_command ($cmd, outfunc => sub {}); };
+	warn $@ if $@;
+    }
 }
 
 sub iscsi_device_list {
@@ -824,6 +834,12 @@
 	    }
 	    return if !$bdev;
 
+	    #check multipath           
+	    if (-d "/sys/block/$bdev/holders") { 
+		my $multipathdev = dir_glob_regex ("/sys/block/$bdev/holders", '[A-Za-z]\S*');
+		$bdev = $multipathdev if $multipathdev;
+	    }
+
 	    my $blockdev = $stable_paths->{$bdev};
 	    return if !$blockdev;
 
@@ -1080,7 +1096,17 @@
 		run_command (['/usr/bin/ssh', "root\@${target_host}", 
 			      '/bin/mkdir', '-p', $dirname]);
 
-		my $cmd = ['/usr/bin/rsync', '--progress', '--inplace', '--no-whole-file', 
+		# we use rsync with --sparse, so we can't use --inplace,
+		# so we remove file on the target if it already exists to
+		# save space
+		my ($size, $format) = file_size_info($src);
+		if ($format && ($format eq 'raw') && $size) {
+		    run_command (['/usr/bin/ssh', "root\@${target_host}", 
+				  'rm', '-f', $dst],
+				 outfunc => sub {});
+		}
+
+		my $cmd = ['/usr/bin/rsync', '--progress', '--sparse', '--whole-file', 
 			   $src, "root\@${target_host}:$dst"];
 
 		my $percent = -1;
@@ -1989,6 +2015,7 @@
     my $mountdata = '';
     my $iscsi_sessions = {};
     my $vgs = {};
+
     if ($stypes->{lvm}) {
 	$session->{vgs} = lvm_vgs();
 	$vgs = $session->{vgs};
@@ -2002,10 +2029,7 @@
 	$session->{iscsi_sessions} = $iscsi_sessions;
     } 
  
-    foreach my $storeid (@$slist) {
-	eval { __activate_storage_full ($cfg, $storeid, $session); };
-	warn $@ if $@;
-    }
+    eval { activate_storage_list ($cfg, $slist, $session); };
 
     foreach my $storeid (keys %$ids) {
 	my $scfg = $ids->{$storeid};

Modified: pve-storage/pve2/changelog.Debian
===================================================================
--- pve-storage/pve2/changelog.Debian	2011-07-22 11:48:40 UTC (rev 6357)
+++ pve-storage/pve2/changelog.Debian	2011-07-25 05:33:28 UTC (rev 6358)
@@ -1,3 +1,9 @@
+libpve-storage-perl (2.0-2) unstable; urgency=low
+
+  * backport fixes (multipath, cache) from stable
+
+ -- Proxmox Support Team <support at proxmox.com>  Mon, 25 Jul 2011 07:02:06 +0200
+
 libpve-storage-perl (2.0-1) unstable; urgency=low
 
   * change copyright to AGPL




More information about the pve-devel mailing list