From f871eb9514bd79c39e673b8a5635cbf31c83ac45 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Fri, 6 Nov 2020 08:06:57 +0100 Subject: [PATCH] marsadm: safeguard deletion of last logfile --- userspace/marsadm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/userspace/marsadm b/userspace/marsadm index 43441e24..4f7233d4 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -5125,9 +5125,12 @@ sub logdelete_res { } my $nr = 0; + my $first = shift(@paths); for (;;) { - my $first = shift(@paths); last unless $first; + my $next = shift(@paths); + # never delete the very last logfile + last unless $next; $nr = $first; $nr =~ s/^.*log-([0-9]+)-.+$/$1/; next unless $nr < $max_deletable; @@ -5135,6 +5138,7 @@ sub logdelete_res { lprint "chosen '$first' for deletion\n" if $verbose; _create_delete($first); + $first = $next; } # Determine whether a parallel join-resource is ongoing my $transient_join = 0;