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 54BAF1FF13F for ; Thu, 07 May 2026 10:00:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F0FACDC97; Thu, 7 May 2026 10:00:37 +0200 (CEST) Date: Thu, 07 May 2026 10:00:27 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= Subject: Re: [PATCH proxmox-backup v2 2/2] fix #7541: zfs status: account for msg directly after status in vdev parser To: Nicolas Frey , pbs-devel@lists.proxmox.com References: <20260505141606.438908-1-n.frey@proxmox.com> <20260505141606.438908-3-n.frey@proxmox.com> In-Reply-To: <20260505141606.438908-3-n.frey@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.17.0 (https://github.com/astroidmail/astroid) Message-Id: <1778140573.9y7e3sqjfm.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778140722285 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.054 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Message-ID-Hash: RGNAYVKE2Y5HZ3HF3E3LNEOQZOBQ6W2J X-Message-ID-Hash: RGNAYVKE2Y5HZ3HF3E3LNEOQZOBQ6W2J X-MailFrom: f.gruenbichler@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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On May 5, 2026 4:16 pm, Nicolas Frey wrote: > so spares that have the status `INUSE` parse correctly. >=20 > adds a line to the mock config in the `test_zpool_status_parser_spares` > test containing an example of a vdev that would be `INUSE`. >=20 > Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=3D7541 > Signed-off-by: Nicolas Frey > --- > No functional changes since v1 > src/tools/disks/zpool_status.rs | 25 +++++++++++++++---------- > 1 file changed, 15 insertions(+), 10 deletions(-) >=20 > diff --git a/src/tools/disks/zpool_status.rs b/src/tools/disks/zpool_stat= us.rs > index 9427f6d4..267fb916 100644 > --- a/src/tools/disks/zpool_status.rs > +++ b/src/tools/disks/zpool_status.rs > @@ -14,7 +14,7 @@ use nom::{ > character::complete::line_ending, > combinator::opt, > multi::{many0, many1}, > - sequence::preceded, > + sequence::{preceded, tuple}, > }; >=20 > #[derive(Debug, Serialize, Deserialize)] > @@ -68,29 +68,33 @@ fn parse_zpool_status_vdev(i: &str) -> IResult<&str, = ZFSPoolVDevState> { > } >=20 > let (i, state) =3D preceded(multispace1, notspace1)(i)?; > - if let Ok((n, _)) =3D preceded(multispace0, line_ending)(i) { > - // spares > + if let Ok((n, (read, write, cksum, msg, _))) =3D tuple(( > + preceded(multispace1, parse_u64), > + preceded(multispace1, parse_u64), > + preceded(multispace1, parse_u64), > + opt(preceded(multispace1, take_while1(|c: char| c !=3D '\n'))), > + line_ending, > + ))(i) > + { > let vdev =3D ZFSPoolVDevState { > name: vdev_name.to_string(), > lvl: indent_level, > state: Some(state.to_string()), > - stats: None, > - msg: None, > + stats: Some(VDevStats { read, write, cksum }), > + msg: msg.map(String::from), you misunderstood what I wrote as reply to v1. we can actually parse the stats optionally first. and then as next step parse the message. and then as final step parse the line ending and then have a single return statement :) basically // spares don't have stats let stats =3D opt_parse_stats(); let msg =3D opt_parse_msg(); line_ending(); return instead of if (stats and msg and line_ending) { return } msg =3D .. line_ending return the goal is to avoid the duplication of parsing the message and line ending, and making the flow more natural, as that is how lines are structured: vdev state [stat stat stat] [msg]\n > }; > return Ok((n, vdev)); > } >=20 > - let (i, read) =3D preceded(multispace1, parse_u64)(i)?; > - let (i, write) =3D preceded(multispace1, parse_u64)(i)?; > - let (i, cksum) =3D preceded(multispace1, parse_u64)(i)?; > - let (i, msg) =3D opt(preceded(multispace1, take_while(|c| c !=3D '\n= ')))(i)?; > + // spares > + let (i, msg) =3D opt(preceded(multispace1, take_while1(|c: char| c != =3D '\n')))(i)?; > let (i, _) =3D line_ending(i)?; >=20 > let vdev =3D ZFSPoolVDevState { > name: vdev_name.to_string(), > lvl: indent_level, > state: Some(state.to_string()), > - stats: Some(VDevStats { read, write, cksum }), > + stats: None, > msg: msg.map(String::from), > }; >=20 > @@ -486,6 +490,7 @@ config: > spares > /dev/sdb AVAIL > /dev/sdc AVAIL > + /dev/sdd INUSE currently in use >=20 > errors: No known data errors > "###; > -- > 2.47.3 >=20 >=20 >=20 >=20