From: Nicolas Frey <n.frey@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup v2 1/2] zfs: status: add `VDevStats` struct instead of 3 optional u64s
Date: Tue, 5 May 2026 16:16:05 +0200 [thread overview]
Message-ID: <20260505141606.438908-2-n.frey@proxmox.com> (raw)
In-Reply-To: <20260505141606.438908-1-n.frey@proxmox.com>
in order to reduce a bit of boilerplate. Keeps (de)serialization the
same by flattening `stats`. No functional change intended
Suggested-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Signed-off-by: Nicolas Frey <n.frey@proxmox.com>
---
New in v2
src/tools/disks/zpool_status.rs | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/src/tools/disks/zpool_status.rs b/src/tools/disks/zpool_status.rs
index 05ef5d80..9427f6d4 100644
--- a/src/tools/disks/zpool_status.rs
+++ b/src/tools/disks/zpool_status.rs
@@ -24,15 +24,19 @@ pub struct ZFSPoolVDevState {
#[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(Debug, 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()
}
@@ -57,9 +61,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));
@@ -72,9 +74,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));
@@ -90,9 +90,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),
};
@@ -283,9 +281,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
next prev parent reply other threads:[~2026-05-05 14:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-05 14:16 [PATCH proxmox-backup v2 0/2] fix #7541: zfs status: account for msg directly after status in vdev parser Nicolas Frey
2026-05-05 14:16 ` Nicolas Frey [this message]
2026-05-05 14:16 ` [PATCH proxmox-backup v2 2/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=20260505141606.438908-2-n.frey@proxmox.com \
--to=n.frey@proxmox.com \
--cc=pbs-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