[pve-devel] [PATCH pve-manager 1/2] Fix parsing block device.

Wolfgang Link w.link at proxmox.com
Mon Dec 19 12:41:26 CET 2016


Get the partition num and block device from sysfs.
This ensure different block device types will work.
---
 PVE/API2/Ceph.pm | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index b0c9ddc..c218fd2 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -329,22 +329,15 @@ __PACKAGE__->register_method ({
 	    my $mountpoint = "/var/lib/ceph/osd/ceph-$osdid";
 
 	    my $remove_partition = sub {
-		my ($disklist, $part) = @_;
+		my ($part) = @_;
 
 		return if !$part || (! -b $part );
-		   
-		foreach my $real_dev (keys %$disklist) {
-		    my $diskinfo = $disklist->{$real_dev};
-		    my $devpath = $diskinfo->{devpath};
-		    next if !$diskinfo->{gpt};
-		    if ($part =~ m|^${devpath}(\d+)$|) {
-			my $partnum = $1;
-			print "remove partition $part (disk '${devpath}', partnum $partnum)\n";
-			eval { run_command(['/sbin/sgdisk', '-d', $partnum, "${devpath}"]); };
-			warn $@ if $@;
-			last;
-		    }
-		}
+		my $partnum = PVE::Diskmanage::get_partnum($part);
+		my $devpath = PVE::Diskmanage::get_blockdev($part);
+
+		print "remove partition $part (disk '${devpath}', partnum $partnum)\n";
+		eval { run_command(['/sbin/sgdisk', '-d', $partnum, "${devpath}"]); };
+		warn $@ if $@;
 	    };
 
 	    my $journal_part;
@@ -369,13 +362,12 @@ __PACKAGE__->register_method ({
 	    }
 
 	    print "Unmount OSD $osdsection from  $mountpoint\n";
-	    eval { run_command(['umount', $mountpoint]); };
+	    eval { run_command(['/bin/umount', $mountpoint]); };
 	    if (my $err = $@) {
 		warn $err;
 	    } elsif ($param->{cleanup}) {
-		my $disklist = PVE::Diskmanage::get_disks(undef, 1);
-		&$remove_partition($disklist, $journal_part);
-		&$remove_partition($disklist, $data_part);
+		&$remove_partition($journal_part);
+		&$remove_partition($data_part);
 	    }
 	};
 
-- 
2.1.4





More information about the pve-devel mailing list