marsadm: log-delete-all left-over version symlinks (ITOPWPT-241)

This commit is contained in:
Thomas Schoebel-Theuer 2012-09-03 11:29:41 +02:00 committed by Thomas Schoebel-Theuer
parent a78094c799
commit 51307fe7a6

View File

@ -602,27 +602,30 @@ sub logdelete_res {
my $check_max = $max - 1;
$check_max = 0 if $check_max < 0;
check_splitbrain($res, "", $check_max) if ($cmd eq "log-delete-all" && !$force);
my $nr;
do {
my $nr = 0;
for (;;) {
my $first = shift(@paths);
last unless $first;
print "chosen '$first' for deletion\n";
$nr = $first;
$nr =~ s/^.*log-([0-9]+)-.+$/$1/;
die "only logfile sequence numbers truly smaller than $max are allowed to be deleted\n" unless $nr < $max;
last unless $nr < $max;
print "chosen '$first' for deletion\n";
# is there any splitbrain up to $nr?
check_splitbrain($res, "", $nr) unless $cmd eq "log-delete-all";
_create_delete($first);
if($nr > 1) {
foreach my $peer (get_peers($res)) {
my $versionlink = sprintf("$mars/resource-$res/version-%09d-$peer", $nr - 1);
_create_delete($versionlink);
}
}
} while($cmd eq "log-delete-all" && $nr + 1 < $max);
last unless $cmd eq "log-delete-all" && $nr + 1 < $max;
}
print "removing left-over version symlinks...\n";
foreach my $versionlink (glob("$mars/resource-$res/version-*")) {
my $nrv = $versionlink;
$nrv =~ s/^.*\/version-([0-9]+)-.+$/$1/;
next unless $nrv < $nr;
_create_delete($versionlink);
}
}
sub attach_res {