From 6320a3a111e21b456074f73df3df91a6ac38852b Mon Sep 17 00:00:00 2001 From: Michal Fox Date: Fri, 2 Oct 2026 16:15:39 +0200 Subject: [PATCH] fix #6640, #6938: api: disks: zfs: return exact error counters Without '-p', 'zpool status' shortens the READ, WRITE and CKSUM counters of a vdev to a value with a unit suffix once they reach 1024, for example 1130 read errors are shown as '1.10K'. The parser just adds zero to those values, so the API returned 1.1 read errors in that case and logged a warning like: Argument "1.10K" isn't numeric in addition (+) Request exact values with '-p'. For the non-JSON output of 'zpool status' it only affects those counters, the sizes in the scan line stay human readable. Signed-off-by: Michal Fox --- src/PVE/API2/Disks/ZFS.pm | 2 +- src/test/zfs_pool_detail_test.pm | 79 +++++++++++++++++++++++++++++++- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/src/PVE/API2/Disks/ZFS.pm b/src/PVE/API2/Disks/ZFS.pm index 7dae404..b26805a 100644 --- a/src/PVE/API2/Disks/ZFS.pm +++ b/src/PVE/API2/Disks/ZFS.pm @@ -217,7 +217,7 @@ __PACKAGE__->register_method({ die "zfsutils-linux not installed\n"; } - my $cmd = [$ZPOOL, 'status', '-P', $param->{name}]; + my $cmd = [$ZPOOL, 'status', '-P', '-p', $param->{name}]; my $pool = { lvl => 0, diff --git a/src/test/zfs_pool_detail_test.pm b/src/test/zfs_pool_detail_test.pm index a062656..00d666a 100644 --- a/src/test/zfs_pool_detail_test.pm +++ b/src/test/zfs_pool_detail_test.pm @@ -18,7 +18,7 @@ $zfs_api_module->mock( my $cmdline = join(' ', @$cmd); die "unexpected run_command call: '$cmdline'\n" - if $cmdline ne '/sbin/zpool status -P tank'; + if $cmdline ne '/sbin/zpool status -P -p tank'; $param{outfunc}->($_) for split(/\n/, $zpool_status_output); @@ -148,6 +148,83 @@ EOF ], }, }, + { + description => 'error counters above 1023', + status => <<"EOF", + pool: tank + state: ONLINE +status: One or more devices has experienced an unrecoverable error. An +\tattempt was made to correct the error. Applications are unaffected. +action: Determine if the device needs to be replaced, and clear the errors +\tusing 'zpool clear' or replace the device with 'zpool replace'. + see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P + scan: scrub repaired 1.38M in 00:41:15 with 0 errors on Sun Sep 13 01:05:15 2026 +config: + +\tNAME STATE READ WRITE CKSUM +\ttank ONLINE 0 0 0 +\t mirror-0 ONLINE 0 0 0 +\t /dev/disk/by-id/ata-DISK_A-part1 ONLINE 1130 0 0 +\t /dev/disk/by-id/ata-DISK_B-part1 ONLINE 0 0 15565 + +errors: No known data errors +EOF + expected => { + name => 'tank', + state => 'ONLINE', + status => 'One or more devices has experienced an unrecoverable error. An' + . ' attempt was made to correct the error. Applications are unaffected.', + action => 'Determine if the device needs to be replaced, and clear the errors' + . " using 'zpool clear' or replace the device with 'zpool replace'.", + see => 'https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P', + scan => + 'scrub repaired 1.38M in 00:41:15 with 0 errors on Sun Sep 13 01:05:15 2026', + errors => 'No known data errors', + leaf => 0, + children => [ + { + name => 'tank', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 0, + children => [ + { + name => 'mirror-0', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 0, + children => [ + { + name => '/dev/disk/by-id/ata-DISK_A-part1', + state => 'ONLINE', + read => 1130, + write => 0, + cksum => 0, + msg => '', + leaf => 1, + }, + { + name => '/dev/disk/by-id/ata-DISK_B-part1', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 15565, + msg => '', + leaf => 1, + }, + ], + }, + ], + }, + ], + }, + }, ]; plan tests => scalar @$tests;