[pve-devel] [PATCH manager] Move wipe_disks to Diskmanage

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jan 27 15:56:52 CET 2020


On January 27, 2020 1:38 pm, Dominic Jäger wrote:
> This function is not only required by Ceph.
> 
> Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
> ---
obvious with such small patch series, but still a good idea to mention 
that this needs a versioned depends on libpve-storage-perl where this 
got moved to.


>  PVE/API2/Ceph/OSD.pm |  4 ++--
>  PVE/Ceph/Tools.pm    | 22 ----------------------
>  2 files changed, 2 insertions(+), 24 deletions(-)
> 
> diff --git a/PVE/API2/Ceph/OSD.pm b/PVE/API2/Ceph/OSD.pm
> index e1b0d807..53288fec 100644
> --- a/PVE/API2/Ceph/OSD.pm
> +++ b/PVE/API2/Ceph/OSD.pm
> @@ -460,7 +460,7 @@ __PACKAGE__->register_method ({
>  		push @$cmd, '--data', $devpath;
>  		push @$cmd, '--dmcrypt' if $param->{encrypted};
>  
> -		PVE::Ceph::Tools::wipe_disks($devpath);
> +		PVE::Diskmanage::wipe_disks($devpath);
>  
>  		run_command($cmd);
>  	    });
> @@ -549,7 +549,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_disks($part);

hmm.. so here we call it with a partition, but the actual method is 
working on disks?

>  		print "remove partition $part (disk '${devpath}', partnum $partnum)\n";
>  		eval { run_command(['/sbin/sgdisk', '-d', $partnum, "${devpath}"]); };
>  		warn $@ if $@;
> diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
> index e6225b78..7d2e8469 100644
> --- a/PVE/Ceph/Tools.pm
> +++ b/PVE/Ceph/Tools.pm
> @@ -270,28 +270,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 {
> -- 
> 2.20.1
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>



More information about the pve-devel mailing list