[DRBD-user] drbdmanage: howto create diskless assignments

Dietmar Maurer dietmar at proxmox.com
Thu Jun 18 13:21:43 CEST 2015

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


I have still problems with diskless assignments. I create them
with:

   ($rc, $res) = $hdl->assign($nodename, $volname, { diskless => 'true' });

which works, but I need to wait until the device is accessible. I currently do
this with a clumsy hack using 'dd':

    # wait until device is acessitble
    my $print_warning = 1;
    my $max_wait_time = 20;
    for (my $i = 0;; $i++) {
	last if system("dd if=$path of=/dev/null bs=512 count=1 >/dev/null 2>&1") == 0;
	die "aborting wait - device '$path' still not readable\n" if $i >
$max_wait_time;
	print "waiting for device '$path' to become ready...\n" if $print_warning;
	$print_warning = 0;
	sleep(1);
    }

This works, but Philipp told me to do it by querying assignment status.
So I tried this:

    # wait until device is acessible
    my $print_warning = 1;
    my $max_wait_time = 20;
    for (my $i = 0;; $i++) {
	# correct, but does not work?
	($rc, $res) = $hdl->list_assignments([$nodename], [$volname], 0, {
"cstate:deploy" => "true" }, []);
	check_drbd_res($rc);
	my $len = scalar(@$res);
	last if $len > 0;
	die "aborting wait - device '$path' still not readable\n" if $i >
$max_wait_time;
	print "waiting for device '$path' to become ready...\n" if $print_warning;
	$print_warning = 0;
	sleep(1);
    }

But it does not work. Seems I get cstate:deploy" => "true", but
the device is not ready to use?




More information about the drbd-user mailing list