btrbk: resolve ancestors (recursive on parent_uuid chain) when searching for latest common subvolume

pull/204/head
Axel Burri 2017-10-10 13:10:33 +02:00
parent 0799820556
commit 3be65b9f67
2 changed files with 29 additions and 0 deletions

View File

@ -19,6 +19,8 @@ btrbk-current
* Do not run in "perl taint mode" by default: remove "perl -T" in
hashbang; hardcode $PATH only if taint mode is enabled.
* Remove "duration" column from transaction_log/transaction_syslog.
* Resolve ancestors (recursive on parent_uuid chain) when searching
for latest common subvolume.
* Bugfix: ssh_filter_btrbk: accept mbuffer command (stream_buffer).
* Bugfix: print correct (end-)time in transaction_log.
* Bugfix: check path when expanding wildcards (close #181).

27
btrbk
View File

@ -2842,6 +2842,33 @@ sub get_latest_common($$$;$)
}
}
# add read-only ancestors from parent chain (recursive!)
my $rnode = $svol->{node};
my $search_depth = 0;
while($rnode && ($search_depth < 16)) {
last if($rnode->{parent_uuid} eq '-');
TRACE "get_latest_common: searching parent chain (depth=$search_depth): $rnode->{uuid}";
my @parents = grep { $_->{node}{uuid} eq $rnode->{parent_uuid} } @$sroot_subvol_list;
if(scalar(@parents) == 1) {
my $parent = $parents[0];
if($parent->{node}{readonly}) {
TRACE "get_latest_common: found read-only parent (depth=$search_depth), add as candidate: $parent->{PRINT}";
push @candidate, $parent;
} else {
TRACE "get_latest_common: found read-write parent (depth=$search_depth), ignoring: $parent->{PRINT}";
}
$rnode = $parent->{node};
}
elsif(scalar(@parents) > 1) {
die "multiple parents for $rnode->{parent_uuid}";
}
else {
$rnode = undef;
}
$search_depth++;
}
# match receive targets of candidates
my $droot_subvol_list = vinfo_subvol_list($droot); # cache subvol list
foreach my $child (@candidate) {
if($child->{node}{id} == $svol->{node}{id}) {