public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Nicolas Frey <n.frey@proxmox.com>
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	[thread overview]
Message-ID: <20260603155822.370223-2-n.frey@proxmox.com> (raw)
In-Reply-To: <20260603155822.370223-1-n.frey@proxmox.com>

in order to reduce a bit of boilerplate. Keeps deserialization the
same by flattening `stats`. No functional change intended

Signed-off-by: Nicolas Frey <n.frey@proxmox.com>
---

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<String>,
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub read: Option<u64>,
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub write: Option<u64>,
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub cksum: Option<u64>,
+    #[serde(flatten)]
+    pub stats: Option<VDevStats>,
     #[serde(skip_serializing_if = "Option::is_none")]
     pub msg: Option<String>,
 }
 
+#[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




  reply	other threads:[~2026-06-03 15:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 15:58 [PATCH proxmox 0/2] fix #7541: zfs status: account for msg directly after status in vdev parser Nicolas Frey
2026-06-03 15:58 ` Nicolas Frey [this message]
2026-06-03 15:58 ` [PATCH proxmox 2/2] " Nicolas Frey
2026-06-03 16:01 ` [PATCH proxmox 0/2] " Nicolas Frey

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=20260603155822.370223-2-n.frey@proxmox.com \
    --to=n.frey@proxmox.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