fixed ordering of snapshots with the same creation timestamp
This commit is contained in:
parent
8d8df7e533
commit
522bdecd53
21
syncoid
21
syncoid
|
@ -1393,6 +1393,8 @@ sub getsnaps() {
|
||||||
# this is a little obnoxious. get guid,creation returns guid,creation on two separate lines
|
# this is a little obnoxious. get guid,creation returns guid,creation on two separate lines
|
||||||
# as though each were an entirely separate get command.
|
# as though each were an entirely separate get command.
|
||||||
|
|
||||||
|
my %creationtimes=();
|
||||||
|
|
||||||
foreach my $line (@rawsnaps) {
|
foreach my $line (@rawsnaps) {
|
||||||
# only import snap guids from the specified filesystem
|
# only import snap guids from the specified filesystem
|
||||||
if ($line =~ /\Q$fs\E\@.*guid/) {
|
if ($line =~ /\Q$fs\E\@.*guid/) {
|
||||||
|
@ -1413,7 +1415,24 @@ sub getsnaps() {
|
||||||
$creation =~ s/^.*\tcreation\t*(\d*).*/$1/;
|
$creation =~ s/^.*\tcreation\t*(\d*).*/$1/;
|
||||||
my $snap = $line;
|
my $snap = $line;
|
||||||
$snap =~ s/^.*\@(.*)\tcreation.*$/$1/;
|
$snap =~ s/^.*\@(.*)\tcreation.*$/$1/;
|
||||||
$snaps{$type}{$snap}{'creation'}=$creation;
|
|
||||||
|
# the accuracy of the creation timestamp is only for a second, but
|
||||||
|
# snapshots in the same second are highly likely. The list command
|
||||||
|
# has an ordered output so we append another three digit running number
|
||||||
|
# to the creation timestamp and make sure those are ordered correctly
|
||||||
|
# for snapshot with the same creation timestamp
|
||||||
|
my $counter = 0;
|
||||||
|
my $creationsuffix;
|
||||||
|
while ($counter < 999) {
|
||||||
|
$creationsuffix = sprintf("%s%03d", $creation, $counter);
|
||||||
|
if (!defined $creationtimes{$creationsuffix}) {
|
||||||
|
$creationtimes{$creationsuffix} = 1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
$counter += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$snaps{$type}{$snap}{'creation'}=$creationsuffix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue