public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Michal Fox <me@dualfroz.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH storage 2/3] fix #6640, #6938: api: disks: zfs: return exact error counters
Date: Sat,  3 Oct 2026 12:49:16 +0000	[thread overview]
Message-ID: <20261003124917.7-3-me@dualfroz.com> (raw)
In-Reply-To: <20261003124917.7-1-me@dualfroz.com>

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 <me@dualfroz.com>
---
 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;
-- 
2.43.0




  parent reply	other threads:[~2026-10-03 12:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-03 12:49 [PATCH storage 0/3] api: disks: zfs: fix error counters and in-use spares in pool details Michal Fox
2026-10-03 12:49 ` [PATCH storage 1/3] test: add tests for zpool status parsing of the ZFS disk API Michal Fox
2026-10-03 12:49 ` Michal Fox [this message]
2026-10-03 12:49 ` [PATCH storage 3/3] fix #6389: api: disks: zfs: parse the message of hot spares in use Michal Fox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261003124917.7-3-me@dualfroz.com \
    --to=me@dualfroz.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal