From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Nicolas Frey <n.frey@proxmox.com>, pbs-devel@lists.proxmox.com
Cc: Thomas Lamprecht <t.lamprecht@proxmox.com>
Subject: Re: [PATCH proxmox-backup v2 1/2] zfs: status: add `VDevStats` struct instead of 3 optional u64s
Date: Thu, 07 May 2026 10:00:31 +0200 [thread overview]
Message-ID: <1778140433.30e1wc8usw.astroid@yuna.none> (raw)
In-Reply-To: <20260505141606.438908-2-n.frey@proxmox.com>
On May 5, 2026 4:16 pm, Nicolas Frey wrote:
> 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>,
> }
this is also duplicated/already moved to proxmox-disks, and changing it
there would be a breaking change since the struct is not only consumed
via deserialization, but crosses package/crate boundaries..
so if we do it, we should also do it there - if we want to avoid that
churn, we need to keep the actual members separate.
>
> +#[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-07 8:01 UTC|newest]
Thread overview: 8+ 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 ` [PATCH proxmox-backup v2 1/2] zfs: status: add `VDevStats` struct instead of 3 optional u64s Nicolas Frey
2026-05-07 8:00 ` Fabian Grünbichler [this message]
2026-05-07 9:16 ` Nicolas Frey
2026-05-07 9:19 ` Thomas Lamprecht
2026-05-05 14:16 ` [PATCH proxmox-backup v2 2/2] fix #7541: zfs status: account for msg directly after status in vdev parser Nicolas Frey
2026-05-07 8:00 ` Fabian Grünbichler
2026-05-07 9:03 ` 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=1778140433.30e1wc8usw.astroid@yuna.none \
--to=f.gruenbichler@proxmox.com \
--cc=n.frey@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
--cc=t.lamprecht@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