diff --git a/ChangeLog b/ChangeLog index 6fc3eb7..5ea274c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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). diff --git a/btrbk b/btrbk index 6d84b17..f924e0f 100755 --- a/btrbk +++ b/btrbk @@ -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}) {