From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id D93431FF0A8 for ; Sat, 03 Oct 2026 14:49:55 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id BDEC021743; Sat, 03 Oct 2026 14:49:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dualfroz.com; s=dkim; t=1791031769; h=from:subject:date:message-id:to:mime-version: content-transfer-encoding:in-reply-to:references; bh=NRk474CzdVNrx/NgXHB9wunOjmWcoabeDOnHqf2xQOk=; b=Y5eiQuuDzBPSm34wWbYIBxEwVO1ZXOZAT+YoeAJUhEn8wJWYk/GHJ8vnnavlS+ODTCLl2V onp08qvdxy29Xw81qG1S9gHres1sKTBH5PpNM58PlgVamH9TI5+t9mPusndP4yUfcE4Jea N8WVMrVkPWa8Ywj1p74jniDhCTHNHmRB8VREiSVf0zIwmy1xhTsXvdoz7jQPmVhdoyRuy6 7KYtd+U5zU/0f3Sy/rDe4M7hzYuwXCs4t6eEQBPg4nhW2Nz8wcQ/Lrmomysk8qOf5gkHpl hDSY2oJjpzEoxDA6no81EhXMBWWZKzVpIsdQTMSIRhyZvd2jTiaKGpqoxnrY+Q== From: Michal Fox To: pve-devel@lists.proxmox.com Subject: [PATCH storage 3/3] fix #6389: api: disks: zfs: parse the message of hot spares in use Date: Sat, 3 Oct 2026 12:49:17 +0000 Message-ID: <20261003124917.7-4-me@dualfroz.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261003124917.7-1-me@dualfroz.com> References: <20261003124917.7-1-me@dualfroz.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.268 Adjusted score from AWL reputation of From: address DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: LXPC3KCWVNM4C7BI37MNTZRDJV5XNHKU X-Message-ID-Hash: LXPC3KCWVNM4C7BI37MNTZRDJV5XNHKU X-MailFrom: me@dualfroz.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Hot spares have no error counters in the output of 'zpool status', so a spare that is in use only has a message after its state: nvme10n1 INUSE currently in use The parser took the three words of that message as READ, WRITE and CKSUM counters, so the API returned zero for all of them and lost the message, while logging warnings like: Argument "currently" isn't numeric in addition (+) As 'zpool status' is called with '-p', the counters are always plain numbers, so only accept digits for them. This way, the message of a spare in use ends up in 'msg', like for any other vdev. Signed-off-by: Michal Fox --- src/PVE/API2/Disks/ZFS.pm | 2 +- src/test/zfs_pool_detail_test.pm | 103 +++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/Disks/ZFS.pm b/src/PVE/API2/Disks/ZFS.pm index b26805a..2215dd6 100644 --- a/src/PVE/API2/Disks/ZFS.pm +++ b/src/PVE/API2/Disks/ZFS.pm @@ -245,7 +245,7 @@ __PACKAGE__->register_method({ $config = 1; } elsif ( $config - && $line =~ m/^(\s+)(\S+)\s*(\S+)?(?:\s+(\S+)\s+(\S+)\s+(\S+))?\s*(.*)$/ + && $line =~ m/^(\s+)(\S+)\s*(\S+)?(?:\s+(\d+)\s+(\d+)\s+(\d+))?\s*(.*)$/ ) { my ($space, $name, $state, $read, $write, $cksum, $msg) = ($1, $2, $3, $4, $5, $6, $7); diff --git a/src/test/zfs_pool_detail_test.pm b/src/test/zfs_pool_detail_test.pm index 00d666a..bcca5ae 100644 --- a/src/test/zfs_pool_detail_test.pm +++ b/src/test/zfs_pool_detail_test.pm @@ -225,6 +225,109 @@ EOF ], }, }, + { + description => 'hot spare in use', + status => <<"EOF", + pool: tank + state: ONLINE + scan: resilvered 725M in 00:00:00 with 0 errors on Mon May 12 16:50:25 2025 +config: + +\tNAME STATE READ WRITE CKSUM +\ttank ONLINE 0 0 0 +\t mirror-0 ONLINE 0 0 0 +\t spare-0 ONLINE 0 0 0 +\t /dev/disk/by-id/ata-DISK_A-part1 ONLINE 0 0 0 +\t /dev/disk/by-id/ata-DISK_C-part1 ONLINE 0 0 0 +\t /dev/disk/by-id/ata-DISK_B-part1 ONLINE 0 0 0 +\tspares +\t /dev/disk/by-id/ata-DISK_C-part1 INUSE currently in use + +errors: No known data errors +EOF + expected => { + name => 'tank', + state => 'ONLINE', + scan => 'resilvered 725M in 00:00:00 with 0 errors on Mon May 12 16:50:25 2025', + 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 => 'spare-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 => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 1, + }, + { + name => '/dev/disk/by-id/ata-DISK_C-part1', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 1, + }, + ], + }, + { + name => '/dev/disk/by-id/ata-DISK_B-part1', + state => 'ONLINE', + read => 0, + write => 0, + cksum => 0, + msg => '', + leaf => 1, + }, + ], + }, + ], + }, + { + name => 'spares', + msg => '', + leaf => 0, + children => [ + { + name => '/dev/disk/by-id/ata-DISK_C-part1', + state => 'INUSE', + msg => 'currently in use', + leaf => 1, + }, + ], + }, + ], + }, + }, ]; plan tests => scalar @$tests; -- 2.43.0