From e6d46e8a02385aef303a19de2a1ec00fc99d641e Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Tue, 22 Mar 2016 19:30:12 +0100 Subject: [PATCH] btrbk: fix regression: correctly handle previously received subvolumes in get_latest_common() regression from: 8819c67502501a7f921272ea8b3d8500af5ae7ac --- btrbk | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/btrbk b/btrbk index 39f6025..3000b05 100755 --- a/btrbk +++ b/btrbk @@ -1487,13 +1487,12 @@ sub get_latest_common($$$;$) my $debug_src = $svol->{URL}; $debug_src .= "#" . $threshold_gen if($threshold_gen); - # prefer latest received subvolume as latest common + # keep track of already received subvolumes + my %receive_target_present; if($droot->{SUBVOL_RECEIVED}) { - foreach(reverse @{$droot->{SUBVOL_RECEIVED}}) { - TRACE "get_latest_common: checking previously received subvolume: $_->{source}->{PRINT}"; + foreach(@{$droot->{SUBVOL_RECEIVED}}) { next if($_->{ERROR}); - DEBUG("Latest common subvolumes for: $debug_src: src=$_->{source}->{PRINT} target=$_->{received_subvolume}->{PRINT} (previously received)"); - return ($_->{source}, $_->{received_subvolume}); + $receive_target_present{$_->{source}->{node}{uuid}} = $_->{received_subvolume}; } } @@ -1505,6 +1504,12 @@ sub get_latest_common($$$;$) next; } + if(my $received_subvol = $receive_target_present{$child->{node}{uuid}}) { + # subvolume has been previously received + DEBUG("Latest common subvolumes for: $debug_src: src=$child->{PRINT} target=$received_subvol->{PRINT} (previously received)"); + return ($child, $received_subvol); + } + foreach (get_receive_targets($droot, $child)) { DEBUG("Latest common subvolumes for: $debug_src: src=$child->{PRINT} target=$_->{PRINT}"); return ($child, $_);