[pve-devel] [PATCH manager v2] Factoring the wipe_disk out into CephTools

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Nov 28 10:34:30 CET 2018


Applied, although your commit messages says _nothing_ about that this
does not only factors it out to CephTools but also adds it in create OSD
after the partitioning checks deemed the disk as safe to use...

Please try to include such important details in the future.

On 11/27/18 4:02 PM, Alwin Antreich wrote:
> Signed-off-by: Alwin Antreich <a.antreich at proxmox.com>
> ---
>  PVE/API2/Ceph.pm |  9 +++------
>  PVE/CephTools.pm | 13 +++++++++++++
>  2 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
> index d74bd016..f9be80e4 100644
> --- a/PVE/API2/Ceph.pm
> +++ b/PVE/API2/Ceph.pm
> @@ -312,6 +312,7 @@ __PACKAGE__->register_method ({
>  		}
>  	    }
>  
> +	    PVE::CephTools::wipe_disk($devpath);
>  
>  	    run_command($cmd);
>  	};
> @@ -439,12 +440,8 @@ __PACKAGE__->register_method ({
>  		foreach my $part (@$partitions_to_remove) {
>  		    $remove_partition->($part);
>  		}
> -		my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M count=200 conv=fdatasync);
> -		foreach my $devpath (keys %$disks_to_wipe) {
> -		    print "wipe disk: $devpath\n";
> -		    eval { run_command([@wipe_cmd, "of=${devpath}"]) };
> -		    warn $@ if $@;
> -		}
> +
> +		PVE::CephTools::wipe_disk(keys %$disks_to_wipe);
>  	    }
>  	};
>  
> diff --git a/PVE/CephTools.pm b/PVE/CephTools.pm
> index 8ee34d14..8d445621 100644
> --- a/PVE/CephTools.pm
> +++ b/PVE/CephTools.pm
> @@ -469,4 +469,17 @@ sub destroy_mds {
>      return undef;
>  };
>  
> +# wipe the first 200 MB to clear off leftovers from previous use, otherwise a
> +# create OSD fails.
> +sub wipe_disk {

named it wipe_disk*s* again, to underline it's ability to  wipe multiple disks at once.

> +    my (@devs) = @_;
> +
> +    my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M count=200 conv=fdatasync);
> +    foreach my $devpath (values @devs) {

values is not needed for iterating a list, you get this implicit in list context.

> +        print "wipe disk: $devpath\n";
> +        eval { run_command([@wipe_cmd, "of=${devpath}"]) };
> +        warn $@ if $@;
> +    }
> +};
> +
>  1;
> 





More information about the pve-devel mailing list