Skip to content

Commit

Permalink
chore: perltidy
Browse files Browse the repository at this point in the history
  • Loading branch information
speed47 committed Apr 14, 2024
1 parent f379aeb commit 99a6cfd
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions btrfs-list
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ sub link2real {
sub pretty_print {
my ($raw, $mode) = @_;

=cut
=comment
debug("pretty_print(@_);");
my @c = caller(0);
debug(Dumper(\@c));
Expand Down Expand Up @@ -285,28 +285,28 @@ sub compute_allocatable_for_profile {

if ($profile eq 'raid1') {
last if ($devBytes{$sk[1]} <= $sliceSize); # out of space
$unallocFree += $sliceSize;
$unallocFree += $sliceSize;
$devBytes{$sk[0]} -= $sliceSize;
$devBytes{$sk[1]} -= $sliceSize;
} ## end if ($profile eq 'raid1')
elsif ($profile eq 'raid1c3') {
last if ($devBytes{$sk[2]} <= $sliceSize); # out of space
$unallocFree += $sliceSize;
$unallocFree += $sliceSize;
$devBytes{$sk[0]} -= $sliceSize;
$devBytes{$sk[1]} -= $sliceSize;
$devBytes{$sk[2]} -= $sliceSize;
} ## end elsif ($profile eq 'raid1c3')
elsif ($profile eq 'raid1c4') {
last if ($devBytes{$sk[3]} <= $sliceSize); # out of space
$unallocFree += $sliceSize;
$unallocFree += $sliceSize;
$devBytes{$sk[0]} -= $sliceSize;
$devBytes{$sk[1]} -= $sliceSize;
$devBytes{$sk[2]} -= $sliceSize;
$devBytes{$sk[3]} -= $sliceSize;
} ## end elsif ($profile eq 'raid1c4')
elsif ($profile eq 'raid10') {
last if ($devBytes{$sk[3]} <= $sliceSize); # out of space
$unallocFree += $sliceSize * 2;
$unallocFree += $sliceSize * 2;
$devBytes{$sk[0]} -= $sliceSize;
$devBytes{$sk[1]} -= $sliceSize;
$devBytes{$sk[2]} -= $sliceSize;
Expand Down Expand Up @@ -394,7 +394,7 @@ if (defined $opt_snap_max_used) {
if ($opt_color eq 'never' || ($opt_color eq 'auto' && !-t 1)) { ## no critic(InputOutput::ProhibitInteractiveTest)
$ENV{'ANSI_COLORS_DISABLED'} = 1;
}
if (!$opt_wide && !-t 1) { ## no critic(InputOutput::ProhibitInteractiveTest)
if (!$opt_wide && !-t 1) { ## no critic(InputOutput::ProhibitInteractiveTest)

# wide if STDOUT is NOT a term
$opt_wide = 1;
Expand Down Expand Up @@ -505,7 +505,7 @@ foreach my $mp (@mountPoints) {

# get filesystems list

=cut
=comment
# btrfs filesystem show
Label: 'beurre' uuid: 010705d8-430f-4f5b-9315-12df40677e97
Total devices 4 FS bytes used 18.23MiB
Expand Down Expand Up @@ -607,14 +607,14 @@ my %vol;
foreach my $fuuid (keys %filesystems) {
my $mp = $filesystems{$fuuid}{'mountpoint'};
defined $mp or next;
-d $mp or next;
-d $mp or next;

$cmd = run_cmd(silent_stderr => 1, cmd => [qw{ btrfs filesystem usage --raw }, $mp]);
if (!@{$cmd->{stdout}} || $cmd->{status}) {
$cmd = run_cmd(fatal => 1, cmd => [qw{ btrfs filesystem usage }, $mp]);
}
my ($seenUnallocated, %devFree, $profile, $mprofile);
my ($total, $fssize, $used, $freeEstimated) = (0, 0, 0, 0);
my ($total, $fssize, $used, $freeEstimated) = (0, 0, 0, 0);
foreach (@{$cmd->{stdout}}) {
if (/Device\s+size:\s*(\S+)/) {
$fssize = human2raw($1);
Expand Down Expand Up @@ -719,7 +719,7 @@ foreach my $fuuid (keys %filesystems) {
}

# ID 257 gen 17 cgen 11 parent 5 top level 5 parent_uuid - received_uuid - uuid 9bc4..fd75 path sub1 with spaces
$vol{$fuuid}{$vuuid}{puuid} = PARENT_UUID_NONE; # old btrfsprogs don't have puuid, set a sane default
$vol{$fuuid}{$vuuid}{puuid} = PARENT_UUID_NONE; # old btrfsprogs don't have puuid, set a sane default
/(\s|^)ID (\d+)/ and $vol{$fuuid}{$vuuid}{id} = $2;
/(\s|^)gen (\d+)/ and $vol{$fuuid}{$vuuid}{gen} = $2;
/(\s|^)cgen (\d+)/ and $vol{$fuuid}{$vuuid}{cgen} = $2;
Expand All @@ -729,11 +729,11 @@ foreach my $fuuid (keys %filesystems) {
/(\s|^)received_uuid (\S+)/ and $vol{$fuuid}{$vuuid}{ruuid} = $2;
/(\s|^)path (.+)/ and $vol{$fuuid}{$vuuid}{path} = $2;
$vol{$fuuid}{$vuuid}{path} =~ s/^<FS_TREE>\///;
$vol{$fuuid}{$vuuid}{type} = 'subvol'; # by default, will be overriden below if applicable
$vol{$fuuid}{$vuuid}{mode} = 'rw'; # by default, will be overriden below if applicable
$vol{$fuuid}{$vuuid}{type} = 'subvol'; # by default, will be overriden below if applicable
$vol{$fuuid}{$vuuid}{mode} = 'rw'; # by default, will be overriden below if applicable
$vol{$fuuid}{$vuuid}{rfer} = 0;
$vol{$fuuid}{$vuuid}{excl} = 0;
$vol{$fuuid}{$vuuid}{mp} = $filesystems{$fuuid}{volmp}{$vol{$fuuid}{$vuuid}{id}};
$vol{$fuuid}{$vuuid}{mp} = $filesystems{$fuuid}{volmp}{$vol{$fuuid}{$vuuid}{id}};
} ## end foreach (@{$cmd->{stdout}})

# now, list only snapshots, we also get their otime for free
Expand All @@ -744,7 +744,7 @@ foreach my $fuuid (keys %filesystems) {
my ($found, $otime);
/(\s|^)uuid ([0-9a-f-]+)/ and exists $vol{$fuuid}{$2} and $found = $2;
/(\s|^)ID ([0-9]+)/ and exists $vol{$fuuid}{$2} and $found = $2;
/(\s|^)otime (\S+ \S+)/ and $otime = $2;
/(\s|^)otime (\S+ \S+)/ and $otime = $2;
if (defined $found) {
if ($opt_hide_snapshots) {
delete $vol{$fuuid}{$found};
Expand All @@ -769,7 +769,7 @@ foreach my $fuuid (keys %filesystems) {

# v3.18 (no --raw)

=cut
=comment
WARNING: Qgroup data inconsistent, rescan recommended
qgroupid rfer excl max_rfer max_excl parent child
-------- ---- ---- -------- -------- ------ -----
Expand All @@ -779,7 +779,7 @@ qgroupid rfer excl max_rfer max_excl parent child

# v3.19+ has --raw, and additionally, since v4.1, we get 'none' instead of 0:

=cut
=comment
qgroupid rfer excl max_rfer max_excl parent child
-------- ---- ---- -------- -------- ------ -----
0/5 9848498 8015121 none none --- ---
Expand All @@ -789,7 +789,7 @@ qgroupid rfer excl max_rfer max_excl parent child
foreach my $fuuid (keys %filesystems) {
my $mp = $filesystems{$fuuid}{'mountpoint'};
defined $mp or next;
-d $mp or next;
-d $mp or next;
next if $opt_free_space;

$cmd = run_cmd(silent_stderr => 1, cmd => [qw{ btrfs quota rescan -s }, $mp]);
Expand Down Expand Up @@ -931,7 +931,7 @@ foreach my $fuuid (sort keys %filesystems) {
foreach my $orphan (sort @orphans) {
my $no_known_parent = 1;
foreach my $potential_parent (@orphans) {
next if $orphan eq $potential_parent; # skip myself
next if $orphan eq $potential_parent; # skip myself
$no_known_parent = 0 if ($potential_parent eq $vol{$fuuid}{$orphan}{puuid});
}
debug(">>> orphan loop on $orphan, no known parent: $no_known_parent");
Expand Down

0 comments on commit 99a6cfd

Please sign in to comment.