mirror of https://github.com/digint/btrbk
btrbk: rename %symlink -> %realpath_cache (returning real_path instead of real_url)
parent
7ee5778dee
commit
79caba4267
24
btrbk
24
btrbk
|
@ -171,7 +171,7 @@ my %table_formats = (
|
||||||
my %url_cache; # map URL to btr_tree node
|
my %url_cache; # map URL to btr_tree node
|
||||||
my %fstab_cache; # map HOST to btrfs mount points
|
my %fstab_cache; # map HOST to btrfs mount points
|
||||||
my %uuid_cache; # map UUID to btr_tree node
|
my %uuid_cache; # map UUID to btr_tree node
|
||||||
my %symlink; # map URL to REAL_URL (symlink target)
|
my %realpath_cache; # map URL to realpath (symlink target)
|
||||||
|
|
||||||
my $dryrun;
|
my $dryrun;
|
||||||
my $loglevel = 1;
|
my $loglevel = 1;
|
||||||
|
@ -566,7 +566,7 @@ sub btrfs_subvolume_show($)
|
||||||
$real_path = $1;
|
$real_path = $1;
|
||||||
DEBUG "Real path for subvolume \"$vol->{PRINT}\" is: $real_path" if($real_path ne $path);
|
DEBUG "Real path for subvolume \"$vol->{PRINT}\" is: $real_path" if($real_path ne $path);
|
||||||
return undef unless(check_file($real_path, { absolute => 1 }));
|
return undef unless(check_file($real_path, { absolute => 1 }));
|
||||||
$symlink{$vol->{URL}} = $vol->{URL_PREFIX} . $real_path if($real_path ne $path);
|
$realpath_cache{$vol->{URL}} = $real_path if($real_path ne $path);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$real_path = $path;
|
$real_path = $path;
|
||||||
|
@ -1148,13 +1148,10 @@ sub btrfs_mountpoint($)
|
||||||
TRACE "fstab_cache " . ($mounts ? "HIT" : "MISS") . ": $host";
|
TRACE "fstab_cache " . ($mounts ? "HIT" : "MISS") . ": $host";
|
||||||
|
|
||||||
# get real path
|
# get real path
|
||||||
my $path = $symlink{$vol->{URL}};
|
my $path = $realpath_cache{$vol->{URL}};
|
||||||
if($path) {
|
unless($path) {
|
||||||
die unless($path =~ s/^\Q$vol->{URL_PREFIX}\E//);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$path = system_realpath($vol);
|
$path = system_realpath($vol);
|
||||||
$symlink{$vol->{URL}} = $vol->{URL_PREFIX} . $path;
|
$realpath_cache{$vol->{URL}} = $path;
|
||||||
}
|
}
|
||||||
return (undef, undef, undef) unless($path);
|
return (undef, undef, undef) unless($path);
|
||||||
|
|
||||||
|
@ -1452,7 +1449,8 @@ sub vinfo_init_root($;@)
|
||||||
$tree_root = $url_cache{$vol->{URL}};
|
$tree_root = $url_cache{$vol->{URL}};
|
||||||
TRACE "url_cache " . ($tree_root ? "HIT" : "MISS") . ": URL=$vol->{URL}";
|
TRACE "url_cache " . ($tree_root ? "HIT" : "MISS") . ": URL=$vol->{URL}";
|
||||||
unless($tree_root) {
|
unless($tree_root) {
|
||||||
if(my $real_url = $symlink{$vol->{URL}}) {
|
if(my $real_path = $realpath_cache{$vol->{URL}}) {
|
||||||
|
my $real_url = $vol->{URL_PREFIX} . $real_path;
|
||||||
$tree_root = $url_cache{$real_url};
|
$tree_root = $url_cache{$real_url};
|
||||||
TRACE "url_cache " . ($tree_root ? "HIT" : "MISS") . ": REAL_URL=$real_url";
|
TRACE "url_cache " . ($tree_root ? "HIT" : "MISS") . ": REAL_URL=$real_url";
|
||||||
}
|
}
|
||||||
|
@ -1463,9 +1461,9 @@ sub vinfo_init_root($;@)
|
||||||
# url_cache miss, read the subvolume detail
|
# url_cache miss, read the subvolume detail
|
||||||
my $detail = btrfs_subvolume_show($vol);
|
my $detail = btrfs_subvolume_show($vol);
|
||||||
if($detail) {
|
if($detail) {
|
||||||
my $real_url = $symlink{$vol->{URL}};
|
my $real_path = $realpath_cache{$vol->{URL}};
|
||||||
push @fill_cache, $vol->{URL};
|
push @fill_cache, $vol->{URL};
|
||||||
push @fill_cache, $real_url if($real_url && (not $url_cache{$real_url}));
|
push @fill_cache, $vol->{URL_PREFIX} . $real_path if($real_path && (not $url_cache{$vol->{URL_PREFIX} . $real_path}));
|
||||||
|
|
||||||
# check uuid_cache
|
# check uuid_cache
|
||||||
if($detail->{uuid}) {
|
if($detail->{uuid}) {
|
||||||
|
@ -3462,7 +3460,7 @@ MAIN:
|
||||||
# check for duplicate snapshot locations
|
# check for duplicate snapshot locations
|
||||||
my $snapdir = config_key($svol, "snapshot_dir", postfix => '/') // "";
|
my $snapdir = config_key($svol, "snapshot_dir", postfix => '/') // "";
|
||||||
my $snapshot_basename = config_key($svol, "snapshot_name") // die;
|
my $snapshot_basename = config_key($svol, "snapshot_name") // die;
|
||||||
my $snapshot_target = ($symlink{$sroot->{URL}} // $sroot->{URL}) . '/' . $snapdir . $snapshot_basename;
|
my $snapshot_target = $sroot->{URL_PREFIX} . ($realpath_cache{$sroot->{URL}} // $sroot->{PATH}) . '/' . $snapdir . $snapshot_basename;
|
||||||
if(my $prev = $snapshot_check{$snapshot_target}) {
|
if(my $prev = $snapshot_check{$snapshot_target}) {
|
||||||
ERROR "Subvolume \"$prev\" and \"$svol->{PRINT}\" will create same snapshot: $snapshot_target";
|
ERROR "Subvolume \"$prev\" and \"$svol->{PRINT}\" will create same snapshot: $snapshot_target";
|
||||||
ERROR "Please fix \"snapshot_name\" configuration options!";
|
ERROR "Please fix \"snapshot_name\" configuration options!";
|
||||||
|
@ -3472,7 +3470,7 @@ MAIN:
|
||||||
|
|
||||||
foreach my $droot (vinfo_subsection($svol, 'target')) {
|
foreach my $droot (vinfo_subsection($svol, 'target')) {
|
||||||
# check for duplicate snapshot locations
|
# check for duplicate snapshot locations
|
||||||
my $snapshot_backup_target = ($symlink{$droot->{URL}} // $droot->{URL}) . '/' . $snapshot_basename;
|
my $snapshot_backup_target = $droot->{URL_PREFIX} . ($realpath_cache{$droot->{URL}} // $droot->{PATH}) . '/' . $snapshot_basename;
|
||||||
if(my $prev = $backup_check{$snapshot_backup_target}) {
|
if(my $prev = $backup_check{$snapshot_backup_target}) {
|
||||||
ERROR "Subvolume \"$prev\" and \"$svol->{PRINT}\" will create same backup target: $snapshot_backup_target";
|
ERROR "Subvolume \"$prev\" and \"$svol->{PRINT}\" will create same backup target: $snapshot_backup_target";
|
||||||
ERROR "Please fix \"snapshot_name\" or \"target\" configuration options!";
|
ERROR "Please fix \"snapshot_name\" or \"target\" configuration options!";
|
||||||
|
|
Loading…
Reference in New Issue