Fixed LV cleaning function. saferemove_throughput parameter added.
Signed-off-by: Pawel Boguslawski <pawel.boguslawski@ib.pl>
This commit is contained in:
committed by
Dietmar Maurer
parent
a8176f5458
commit
399ab2b605
@ -595,7 +595,7 @@ sub vdisk_free {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $cleanup_worker = $plugin->free_image($storeid, $scfg, $volname, $isBase);
|
$cleanup_worker = $plugin->free_image($storeid, $scfg, $volname, $isBase);
|
||||||
});
|
});
|
||||||
|
|
||||||
return if !$cleanup_worker;
|
return if !$cleanup_worker;
|
||||||
|
|||||||
@ -193,6 +193,10 @@ sub properties {
|
|||||||
description => "Zero-out data when removing LVs.",
|
description => "Zero-out data when removing LVs.",
|
||||||
type => 'boolean',
|
type => 'boolean',
|
||||||
},
|
},
|
||||||
|
saferemove_throughput => {
|
||||||
|
description => "Wipe throughput (cstream -t parameter value).",
|
||||||
|
type => 'string',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,6 +207,7 @@ sub options {
|
|||||||
shared => { optional => 1 },
|
shared => { optional => 1 },
|
||||||
disable => { optional => 1 },
|
disable => { optional => 1 },
|
||||||
saferemove => { optional => 1 },
|
saferemove => { optional => 1 },
|
||||||
|
saferemove_throughput => { optional => 1 },
|
||||||
content => { optional => 1 },
|
content => { optional => 1 },
|
||||||
base => { fixed => 1, optional => 1 },
|
base => { fixed => 1, optional => 1 },
|
||||||
};
|
};
|
||||||
@ -295,26 +300,44 @@ sub free_image {
|
|||||||
# and to allow thin provisioning
|
# and to allow thin provisioning
|
||||||
|
|
||||||
my $zero_out_worker = sub {
|
my $zero_out_worker = sub {
|
||||||
print "zero-out data on image $volname\n";
|
print "zero-out data on image $volname (/dev/$vg/del-$volname)\n";
|
||||||
my $cmd = ['dd', "if=/dev/zero", "of=/dev/$vg/del-$volname", "bs=1M"];
|
|
||||||
eval { run_command($cmd, errmsg => "zero out failed"); };
|
# wipe throughput up to 10MB/s by default; may be overwritten with saferemove_throughput
|
||||||
|
my $throughput = '-10485760';
|
||||||
|
if ($scfg->{saferemove_throughput}) {
|
||||||
|
$throughput = $scfg->{saferemove_throughput};
|
||||||
|
}
|
||||||
|
|
||||||
|
my $cmd = [
|
||||||
|
'/usr/bin/cstream',
|
||||||
|
'-i', '/dev/zero',
|
||||||
|
'-o', "/dev/$vg/del-$volname",
|
||||||
|
'-T', '10',
|
||||||
|
'-v', '1',
|
||||||
|
'-b', '1048576',
|
||||||
|
'-t', "$throughput"
|
||||||
|
];
|
||||||
|
eval { run_command($cmd, errmsg => "zero out finished (note: 'No space left on device' is ok here)"); };
|
||||||
warn $@ if $@;
|
warn $@ if $@;
|
||||||
|
|
||||||
$class->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
|
$class->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
|
||||||
my $cmd = ['/sbin/lvremove', '-f', "$vg/del-$volname"];
|
my $cmd = ['/sbin/lvremove', '-f', "$vg/del-$volname"];
|
||||||
run_command($cmd, errmsg => "lvremove '$vg/del-$volname' error");
|
run_command($cmd, errmsg => "lvremove '$vg/del-$volname' error");
|
||||||
});
|
});
|
||||||
print "successfully removed volume $volname\n";
|
print "successfully removed volume $volname ($vg/del-$volname)\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my $cmd = ['/sbin/lvchange', '-aly', "$vg/$volname"];
|
||||||
|
run_command($cmd, errmsg => "can't activate LV '$vg/$volname' to zero-out its data");
|
||||||
|
|
||||||
if ($scfg->{saferemove}) {
|
if ($scfg->{saferemove}) {
|
||||||
# avoid long running task, so we only rename here
|
# avoid long running task, so we only rename here
|
||||||
my $cmd = ['/sbin/lvrename', $vg, $volname, "del-$volname"];
|
$cmd = ['/sbin/lvrename', $vg, $volname, "del-$volname"];
|
||||||
run_command($cmd, errmsg => "lvrename '$vg/$volname' error");
|
run_command($cmd, errmsg => "lvrename '$vg/$volname' error");
|
||||||
return $zero_out_worker;
|
return $zero_out_worker;
|
||||||
} else {
|
} else {
|
||||||
my $tmpvg = $scfg->{vgname};
|
my $tmpvg = $scfg->{vgname};
|
||||||
my $cmd = ['/sbin/lvremove', '-f', "$tmpvg/$volname"];
|
$cmd = ['/sbin/lvremove', '-f', "$tmpvg/$volname"];
|
||||||
run_command($cmd, errmsg => "lvremove '$tmpvg/$volname' error");
|
run_command($cmd, errmsg => "lvremove '$tmpvg/$volname' error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user