all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Nicolas Frey <n.frey@proxmox.com>
To: "Fabian Grünbichler" <f.gruenbichler@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, 7 May 2026 11:16:16 +0200	[thread overview]
Message-ID: <fa5da821-e64d-42b4-b4a2-83f443bdbfbe@proxmox.com> (raw)
In-Reply-To: <1778140433.30e1wc8usw.astroid@yuna.none>


On 5/7/26 9:58 AM, Fabian Grünbichler wrote:
> 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.
> 

Ah thanks! I was unaware that this code was duplicated to
proxmox-disks. I reckon the place to fix the parsing would rather be
there then? Or should it be fixed on both sides, until PBS uses
proxmox-disks?

I don't believe we gain much from pulling this out into a separate
struct here after thinking about it (especially with what you
mentioned here), I'll drop it in the next version

>>
>> +#[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
>>
>>
>>
>>





  reply	other threads:[~2026-05-07  9:16 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
2026-05-07  9:16     ` Nicolas Frey [this message]
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=fa5da821-e64d-42b4-b4a2-83f443bdbfbe@proxmox.com \
    --to=n.frey@proxmox.com \
    --cc=f.gruenbichler@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal