From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id F18531FF13B for ; Wed, 03 Jun 2026 17:58:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BC8791320D; Wed, 3 Jun 2026 17:58:27 +0200 (CEST) From: Nicolas Frey To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox 1/2] disks: zpool: add `VDevStats` struct instead of 3 optional u64s Date: Wed, 3 Jun 2026 17:58:21 +0200 Message-ID: <20260603155822.370223-2-n.frey@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260603155822.370223-1-n.frey@proxmox.com> References: <20260603155822.370223-1-n.frey@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.134 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: C7Q7SVIXHRSXOTDFVQ2TF5JZB5WOURSQ X-Message-ID-Hash: C7Q7SVIXHRSXOTDFVQ2TF5JZB5WOURSQ X-MailFrom: nfrey@miso.proxmox.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: in order to reduce a bit of boilerplate. Keeps deserialization the same by flattening `stats`. No functional change intended Signed-off-by: Nicolas Frey --- Notes: was discussed in v2 of a series that specifically targeted PBS, as @Thomas mentioned this does not yet have any users and cleans up the code a bit, so I thought it would be worth keeping proxmox-disks/src/zpool_status.rs | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/proxmox-disks/src/zpool_status.rs b/proxmox-disks/src/zpool_status.rs index 92aca2c9..52776a76 100644 --- a/proxmox-disks/src/zpool_status.rs +++ b/proxmox-disks/src/zpool_status.rs @@ -22,16 +22,19 @@ pub struct ZFSPoolVDevState { pub lvl: u64, #[serde(skip_serializing_if = "Option::is_none")] pub state: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub read: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub write: Option, - #[serde(skip_serializing_if = "Option::is_none")] - pub cksum: Option, + #[serde(flatten)] + pub stats: Option, #[serde(skip_serializing_if = "Option::is_none")] pub msg: Option, } +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct VDevStats { + read: u64, + write: u64, + cksum: u64, +} + fn expand_tab_length(input: &str) -> usize { input.chars().map(|c| if c == '\t' { 8 } else { 1 }).sum() } @@ -56,9 +59,7 @@ fn parse_zpool_status_vdev(i: &str) -> IResult<&str, ZFSPoolVDevState> { name: vdev_name.to_string(), lvl: indent_level, state: None, - read: None, - write: None, - cksum: None, + stats: None, msg: None, }; return Ok((n, vdev)); @@ -71,9 +72,7 @@ fn parse_zpool_status_vdev(i: &str) -> IResult<&str, ZFSPoolVDevState> { name: vdev_name.to_string(), lvl: indent_level, state: Some(state.to_string()), - read: None, - write: None, - cksum: None, + stats: None, msg: None, }; return Ok((n, vdev)); @@ -89,9 +88,7 @@ fn parse_zpool_status_vdev(i: &str) -> IResult<&str, ZFSPoolVDevState> { name: vdev_name.to_string(), lvl: indent_level, state: Some(state.to_string()), - read: Some(read), - write: Some(write), - cksum: Some(cksum), + stats: Some(VDevStats { read, write, cksum }), msg: msg.map(String::from), }; @@ -282,9 +279,7 @@ fn test_vdev_list_to_tree() { name: String::new(), lvl: 0, state: None, - read: None, - write: None, - cksum: None, + stats: None, msg: None, }; -- 2.47.3