nachoparker / btrfs-du

Easily print BTRFS subvolume/snapshot disk usage
GNU General Public License v3.0
112 stars 17 forks source link

Stopped working on latest Arch Linux #29

Open clst opened 1 year ago

clst commented 1 year ago

It worked fine. Now I get this error:

Subvolume                                                         Total  Exclusive  ID
─────────────────────────────────────────────────────────────────────────────────────────
var/lib/portables                                                                   259
var/lib/machines                                                                    260
swap                                                             0Bytes     0Bytes  261
/usr/bin/btrfs-du: line 123: EXCL_TOTAL +  : syntax error: operand expected (error token is "+  ")
─────────────────────────────────────────────────────────────────────────────────────────
Total exclusive data                                                            8.00GiB

I tried enabling quota but that didn't change anything. btrfs qgroup show / works fine.

Qgroupid    Referenced    Exclusive   Path
--------    ----------    ---------   ----
0/5            9.43GiB      2.71MiB   <toplevel>
0/259         16.00KiB     16.00KiB   var/lib/portables
0/260         16.00KiB     16.00KiB   var/lib/machines
0/261          8.00GiB      8.00GiB   swap
0/267        524.00KiB    524.00KiB   .snapshots
0/268       1006.39MiB      1.00MiB   .snapshots/1/snapshot
0/270       1012.14MiB      6.69MiB   .snapshots/3/snapshot
0/1528         2.73GiB    831.82MiB   .snapshots/1216/snapshot

I looked at it briefly but I can't find an error. --raw output also looks fine:

Qgroupid    Referenced    Exclusive   Path
--------    ----------    ---------   ----
0/5        10123321344      4067328   <toplevel>
0/259            16384        16384   var/lib/portables
0/260            16384        16384   var/lib/machines
0/261       8589950976   8589950976   swap
0/267           536576       536576   .snapshots
0/268       1055277056      1052672   .snapshots/1/snapshot
0/270       1061302272      7016448   .snapshots/3/snapshot
0/1528      2928025600    872222720   .snapshots/1216/snapshot
CMSplumbear commented 1 year ago

This is because btrfs-progs now prints the qgroup path on the right column. It was not the case before, ie, for btrfs-progs version 5.17:

   ~# btrfs qgroup show /
   qgroupid         rfer         excl 
   --------         ----         ---- 
   0/5          17.08GiB    288.00KiB 
   0/279         1.09MiB      1.09MiB 
   0/4352       16.00KiB     16.00KiB 
   0/4353       16.00KiB     16.00KiB 
   . . .

This breaks the (greedy) sed command that cleans the output because of the added slashes A simple fix is to make sed "non greedy"

--- btrfs-du    2019-10-02 00:36:05.993303941 +0200
+++ btrfs-du-path   2023-01-24 12:21:31.679651959 +0100
@@ -99,7 +99,8 @@
 # data

 ## qgroup data
-OUT=$( sed '1,3d;s|^.*/||' <<< "$OUT" )
+OUT=$( sed '1,3d;s|^[^/]*/||' <<< "$OUT" )
 ID__=( $( awk '{ print $1 }' <<< "$OUT" ) )
 TOT_=( $( awk '{ print $2 }' <<< "$OUT" ) )
 EXC_=( $( awk '{ print $3 }' <<< "$OUT" ) )
clst commented 1 year ago

That worked great. I will ask the AUR maintainer to include the patch. I had to change the lines a bit and remove some whitespaces to apply it:

--- btrfs-du    2019-10-02 00:36:05.993303941 +0200
+++ btrfs-du-path   2023-01-24 12:21:31.679651959 +0100
@@ -87,7 +87,7 @@
 # data

 ## qgroup data
-OUT=$( sed '1,3d;s|^.*/||' <<< "$OUT" )
+OUT=$( sed '1,3d;s|^[^/]*/||' <<< "$OUT" )
 ID__=( $( awk '{ print $1 }' <<< "$OUT" ) )
 TOT_=( $( awk '{ print $2 }' <<< "$OUT" ) )
 EXC_=( $( awk '{ print $3 }' <<< "$OUT" ) )

EDIT: Oops, closed to early. The inclusion of the path in the official tools makes btrfs-du not as essential now however.