]> git.proxmox.com Git - pve-manager.git/commitdiff
api: check: create osd: use wipe_blockdev from the Diskmanage package
authorFabian Ebner <f.ebner@proxmox.com>
Tue, 28 Sep 2021 11:39:54 +0000 (13:39 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 30 Sep 2021 16:12:58 +0000 (18:12 +0200)
which is mostly a copy of the wipe_disks helper with the difference
that it also uses wipefs on the device and its partitions.

Remove the wipe_disks helper as no users remain.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
PVE/API2/Ceph/OSD.pm
PVE/Ceph/Tools.pm

index 83a9c9321737ea2223e903f2ba8ffc209d8e97e5..97393912e2371ca69d9484cebfbe601b557baa38 100644 (file)
@@ -473,7 +473,7 @@ __PACKAGE__->register_method ({
                push @$cmd, '--data', $devpath;
                push @$cmd, '--dmcrypt' if $param->{encrypted};
 
-               PVE::Ceph::Tools::wipe_disks($devpath);
+               PVE::Diskmanage::wipe_blockdev($devpath);
 
                run_command($cmd);
            });
@@ -590,7 +590,7 @@ __PACKAGE__->register_method ({
                my $partnum = PVE::Diskmanage::get_partnum($part);
                my $devpath = PVE::Diskmanage::get_blockdev($part);
 
-               PVE::Ceph::Tools::wipe_disks($part);
+               PVE::Diskmanage::wipe_blockdev($part);
                print "remove partition $part (disk '${devpath}', partnum $partnum)\n";
                eval { run_command(['/sbin/sgdisk', '-d', $partnum, "${devpath}"]); };
                warn $@ if $@;
index e7124074f79efa309a7f319c73aa22478b18efde..f54d837aaf322722304bf90d5f49b52114b4620b 100644 (file)
@@ -333,29 +333,6 @@ sub get_or_create_admin_keyring {
     return $pve_ckeyring_path;
 }
 
-# wipe the first 200 MB to clear off leftovers from previous use, otherwise a
-# create OSD fails.
-sub wipe_disks {
-    my (@devs) = @_;
-
-    my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M conv=fdatasync);
-
-    foreach my $devpath (@devs) {
-       my $devname = basename($devpath);
-       my $dev_size = PVE::Tools::file_get_contents("/sys/class/block/$devname/size");
-
-       ($dev_size) = $dev_size =~ m|(\d+)|; # untaint $dev_size
-       die "Coulnd't get the size of the device $devname\n" if (!defined($dev_size));
-
-       my $size = ($dev_size * 512 / 1024 / 1024);
-       my $count = ($size < 200) ? $size : 200;
-
-       print "wipe disk/partition: $devpath\n";
-       eval { run_command([@wipe_cmd, "count=$count", "of=${devpath}"]) };
-       warn $@ if $@;
-    }
-};
-
 # get ceph-volume managed osds
 sub ceph_volume_list {
     my $result = {};