mirror of https://github.com/digint/btrbk
btrbk: print snapdir and targets for action "usage"
parent
7603e03aad
commit
b658fba08c
42
btrbk
42
btrbk
|
@ -262,9 +262,9 @@ my %table_formats = (
|
||||||
},
|
},
|
||||||
|
|
||||||
usage => {
|
usage => {
|
||||||
table => [ qw( -host -port path size used free ) ],
|
table => [ qw( -host -port mount_source path size used free ) ],
|
||||||
long => [ qw( type -host -port path size used device_size device_allocated device_unallocated device_missing device_used free free_min data_ratio metadata_ratio global_reserve global_reserve_used ) ],
|
long => [ qw( type -host -port mount_source path size used device_size device_allocated device_unallocated device_missing device_used free free_min data_ratio metadata_ratio global_reserve global_reserve_used ) ],
|
||||||
raw => [ qw( type host port path size used device_size device_allocated device_unallocated device_missing device_used free free_min data_ratio metadata_ratio global_reserve global_reserve_used ) ],
|
raw => [ qw( type host port mount_source path size used device_size device_allocated device_unallocated device_missing device_used free free_min data_ratio metadata_ratio global_reserve global_reserve_used ) ],
|
||||||
RALIGN => { size=>1, used=>1, device_size=>1, device_allocated=>1, device_unallocated=>1, device_missing=>1, device_used=>1, free=>1, free_min=>1, data_ratio=>1, metadata_ratio=>1, global_reserve=>1, global_reserve_used=>1 },
|
RALIGN => { size=>1, used=>1, device_size=>1, device_allocated=>1, device_unallocated=>1, device_missing=>1, device_used=>1, free=>1, free_min=>1, data_ratio=>1, metadata_ratio=>1, global_reserve=>1, global_reserve_used=>1 },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -6503,32 +6503,30 @@ MAIN:
|
||||||
# print filesystem information
|
# print filesystem information
|
||||||
#
|
#
|
||||||
my @data;
|
my @data;
|
||||||
|
my %usage_cache;
|
||||||
my %processed;
|
my %processed;
|
||||||
foreach my $sroot (vinfo_subsection($config, 'volume')) {
|
my $push_data = sub {
|
||||||
unless($processed{$sroot->{URL}}) {
|
my ($vol, $type) = @_;
|
||||||
my $usage = btrfs_filesystem_usage($sroot) // {};
|
return if $processed{$vol->{URL}};
|
||||||
push @data, { %$usage,
|
my (undef, undef, undef, $mount_source, undef) = btrfs_mountpoint($vol);
|
||||||
type => "source",
|
my $mid = $vol->{MACHINE_ID} . $mount_source;
|
||||||
vinfo_prefixed_keys("", $sroot),
|
$usage_cache{$mid} //= btrfs_filesystem_usage($vol);
|
||||||
};
|
push @data, { %{$usage_cache{$mid}},
|
||||||
$processed{$sroot->{URL}} = 1;
|
type => $type,
|
||||||
}
|
mount_source => $mount_source,
|
||||||
}
|
vinfo_prefixed_keys("", $vol),
|
||||||
|
};
|
||||||
|
$processed{$vol->{URL}} = 1;
|
||||||
|
};
|
||||||
foreach my $sroot (vinfo_subsection($config, 'volume')) {
|
foreach my $sroot (vinfo_subsection($config, 'volume')) {
|
||||||
foreach my $svol (vinfo_subsection($sroot, 'subvolume')) {
|
foreach my $svol (vinfo_subsection($sroot, 'subvolume')) {
|
||||||
|
$push_data->(vinfo_snapshot_root($svol), "source");
|
||||||
foreach my $droot (vinfo_subsection($svol, 'target')) {
|
foreach my $droot (vinfo_subsection($svol, 'target')) {
|
||||||
unless($processed{$droot->{URL}}) {
|
$push_data->(vinfo_snapshot_root($droot), "target");
|
||||||
my $usage = btrfs_filesystem_usage($droot) // {};
|
|
||||||
push @data, { %$usage,
|
|
||||||
type => "target",
|
|
||||||
vinfo_prefixed_keys("", $droot),
|
|
||||||
};
|
|
||||||
$processed{$droot->{URL}} = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@data = sort { $a->{type} cmp $b->{type} || $a->{url} cmp $b->{url} } @data;
|
||||||
print_formatted("usage", \@data);
|
print_formatted("usage", \@data);
|
||||||
exit exit_status($config);
|
exit exit_status($config);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue