zfs-stats buggy ? variables uninitialized

running zfs-stats -a gives me the following errors

Code:
FreeBSD 14.0-RELEASE-p6 #0: Tue Mar 26 20:26:20 UTC 2024 root11:45AM  up 15 days,  1:44, 10 users, load averages: 2.12, 2.33, 5.21

------------------------------------------------------------------------

System Memory:

        0.58%   2.16    GiB Active,     81.02%  303.10  GiB Inact
        15.79%  59.08   GiB Wired,      0.00%   0       Bytes Cache
        2.11%   7.90    GiB Free,       0.50%   1.88    GiB Gap

        Real Installed:                         384.00  GiB
        Real Available:                 99.98%  383.93  GiB
        Real Managed:                   97.44%  374.11  GiB

        Logical Total:                          384.00  GiB
        Logical Used:                   19.01%  73.01   GiB
        Logical Free:                   80.99%  310.99  GiB

Use of uninitialized value $vdev_cache_hits in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value $vdev_cache_misses in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value $vdev_cache_delegations in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value in numeric eq (==) at /usr/local/bin/zfs-stats line 630.
Kernel Memory:                                  6.96    GiB
        Data:                           99.49%  6.92    GiB
        Text:                           0.51%   36.02   MiB

Kernel Memory Map:                              374.11  GiB
        Size:                           15.63%  58.49   GiB
        Free:                           84.37%  315.62  GiB

------------------------------------------------------------------------

it seems to be coming from zfs-stats -D

Code:
------------------------------------------------------------------------
ZFS Subsystem Report                            Sun Jun 30 11:56:49 2024
------------------------------------------------------------------------

Use of uninitialized value $vdev_cache_hits in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value $vdev_cache_misses in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value $vdev_cache_delegations in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value in numeric eq (==) at /usr/local/bin/zfs-stats line 630.
VDEV cache is disabled

------------------------------------------------------------------------

Maybe check and not try to output when the VDEV cache is disabled ?
 
… 14.0-RELEASE-p6 …

The same with CURRENT,

Code:
% uname -aKU ; zfs-stats -D
FreeBSD mowa219-gjp4-zbook-freebsd 15.0-CURRENT FreeBSD 15.0-CURRENT main-n271063-fb32ba6aa44d GENERIC-NODEBUG amd64 1500019 1500019

------------------------------------------------------------------------
ZFS Subsystem Report                            Sun Jul  7 21:03:40 2024
------------------------------------------------------------------------

Use of uninitialized value $vdev_cache_hits in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value $vdev_cache_misses in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value $vdev_cache_delegations in addition (+) at /usr/local/bin/zfs-stats line 628.
Use of uninitialized value in numeric eq (==) at /usr/local/bin/zfs-stats line 630.
VDEV cache is disabled

------------------------------------------------------------------------

%

Side note: be aware of the recent security advisory, the update to patch level 8.
 
On 13.3 with UFS, I get this output:
Code:
# zfs-stats -a

------------------------------------------------------------------------
ZFS Subsystem Report                Mon Jul  8 09:08:07 2024
------------------------------------------------------------------------

System Information:

    Kernel Version:                1303001 (osreldate)
    Hardware Platform:            amd64
    Processor Architecture:            amd64

    ZFS Storage pool Version:        5000
    ZFS Filesystem Version:            5

FreeBSD 13.3-RELEASE-p3 GENERIC 9:08AM  up 2 days, 16:53, 1 user, load averages: 0.12, 0.13, 0.09

------------------------------------------------------------------------

System Memory:

    0.10%    15.16    MiB Active,    18.79%    2.88    GiB Inact
    11.13%    1.71    GiB Wired,    0.00%    0    Bytes Cache
    71.98%    11.05    GiB Free,    -2.00%    -329428992    Bytes Gap

    Real Installed:                16.00    GiB
    Real Available:            98.79%    15.81    GiB
    Real Managed:            97.10%    15.35    GiB

    Logical Total:                16.00    GiB
    Logical Used:            12.93%    2.07    GiB
    Logical Free:            87.07%    13.93    GiB

Kernel Memory:                    132.68    MiB
    Data:                72.02%    95.55    MiB
    Text:                27.98%    37.12    MiB

Kernel Memory Map:                15.35    GiB
    Size:                3.47%    544.84    MiB
    Free:                96.53%    14.82    GiB

------------------------------------------------------------------------

ARC Summary: (HEALTHY)
    Memory Throttle Count:            0

ARC Misc:
    Deleted:                0
    Mutex Misses:                0
    Evict Skips:                0

ARC Size:                0.00%    960    Bytes
    Target Size: (Adaptive)        3.34%    505.81    MiB
    Min Size (Hard Limit):        3.34%    505.81    MiB
    Max Size (High Water):        29:1    14.81    GiB
    Compressed Data Size:            0    Bytes
    Decompressed Data Size:            0    Bytes
Illegal division by zero at /usr/local/bin/zfs-stats line 212.
It is a perl script, so should be easy to modify, but then testing & getting it committed.

For the division by zero, obviously with no ZFS at all, that rVal is going to be 0 return sprintf('%0.' . $Decimal . 'f', ($lVal / $rVal));

The reported warnings are from here:
Code:
624 sub _vdev_summary {
625         my $vdev_cache_delegations = $Kstat->{"kstat.zfs.misc.vdev_cache_stats.delegations"};
626         my $vdev_cache_misses = $Kstat->{"kstat.zfs.misc.vdev_cache_stats.misses"};
627         my $vdev_cache_hits = $Kstat->{"kstat.zfs.misc.vdev_cache_stats.hits"};
628         my $vdev_cache_total = ($vdev_cache_misses + $vdev_cache_hits + $vdev_cache_delegations);
629
630         if (($IsOpenZFS ? $Kstat->{"vfs.zfs.vdev.cache_size"} : $Kstat->{"vfs.zfs.vdev.cache.size"}) == 0) {

Code:
# sysctl -a | grep vfs.zfs.vdev.cache.size
vfs.zfs.vdev.cache_size: 0
# sysctl -a | grep vfs.zfs.vdev.cache_size
vfs.zfs.vdev.cache_size: 0
 
Back
Top