From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 91A581FF0AF for ; Thu, 08 Oct 2026 12:29:32 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 319BD214C9; Thu, 08 Oct 2026 12:29:30 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 08 Oct 2026 12:29:25 +0200 Message-Id: From: "Elias Huhsovitz" To: "Fiona Ebner" , Subject: Re: [PATCH storage] plugins: better document how volname_for_format() validates the name X-Mailer: aerc 0.20.0 References: <20261005110650.91260-1-f.ebner@proxmox.com> <119ff822-2794-4dff-be99-4c0e6f813542@proxmox.com> In-Reply-To: <119ff822-2794-4dff-be99-4c0e6f813542@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1791455365170 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.529 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 6JD4A3MA5LTYDZPYRLXLBQ6YJH5QQA2G X-Message-ID-Hash: 6JD4A3MA5LTYDZPYRLXLBQ6YJH5QQA2G X-MailFrom: e.huhsovitz@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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed Oct 7, 2026 at 3:12 PM CEST, Fiona Ebner wrote: > Am 07.10.26 um 2:51 PM schrieb Elias Huhsovitz: >> I think the comments here are fine, but I would prefer this should be >> documented in the POD for the respective subroutines. >>=20 >> Both parse_name_dir & (espeically) parse_volname would also benefit=20 >> from a proper POD. > > Yes, but that is out-of-scope for this patch. Max has been working on > documenting the storage plugin interface properly.=20 Ok, then I do not mind the comments. I was just afraid that the documentation might end at the comments ;D. LGTM! > This patch is for > better documenting how the volname_for_format() implementations achieve > validation, and even if parse_{name_dir,volname} had proper POD, the > added comments inline are better suited for making it explicit/readable > how validation is achieved here IMHO. > >>=20 >> See small comments inlinde. >>=20 >> On Mon Oct 5, 2026 at 1:04 PM CEST, Fiona Ebner wrote: >>> In particular, there is a requirement for get_parsed_format() to >>> return a format only if it validated the name. Mention it explicitly. >>> >>> Signed-off-by: Fiona Ebner >>> --- >>> src/PVE/Storage/Plugin.pm | 5 +++-- >>> src/PVE/Storage/ZFSPoolPlugin.pm | 3 ++- >>> 2 files changed, 5 insertions(+), 3 deletions(-) >>> >>> diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm >>> index 8318a68..e2025f8 100644 >>> --- a/src/PVE/Storage/Plugin.pm >>> +++ b/src/PVE/Storage/Plugin.pm >>> @@ -851,7 +851,7 @@ sub parse_volname { >>> =3Dhead3 get_parsed_format >>> =20 >>> Return the disk format encoded in the given volume name, or C i= f the name does not spell one >>> -out. >>> +out. If a format is returned, the name must have been validated. >>> =20 >>> This is an extension point for plugins whose volume names encode the f= ormat differently. ZFS >>> derives it from the name prefix via C, while LVM and RB= D take it from a known file >>> @@ -866,7 +866,7 @@ sub get_parsed_format { >>> =20 >>> return undef if $name !~ m/\.[^.]+$/; # no extension, so no format= is spelled out >>> =20 >>> - return (parse_name_dir($name))[1]; >>> + return (parse_name_dir($name))[1]; # dies for invalid volume file = names >>=20 >> We could add this information inside the POD of the function.=20 >>=20 >> Similarly to how javadoc has the @throws annonation. >>=20 >>> } >>> =20 >>> sub is_valid_format { >>> @@ -904,6 +904,7 @@ sub volname_for_format { >>> =20 >>> my $parsed_volname_fmt =3D $class->get_parsed_format($name); >>> =20 >>> + # Note that get_parsed_format() validates the name if it has a for= mat extension. >>> return $name if defined($parsed_volname_fmt) && $parsed_volname_fm= t eq $fmt; >>> =20 >>> my $suggestion =3D $class->volname_with_format($name, $fmt); >>> diff --git a/src/PVE/Storage/ZFSPoolPlugin.pm b/src/PVE/Storage/ZFSPool= Plugin.pm >>> index 61c49d9..e7cd1de 100644 >>> --- a/src/PVE/Storage/ZFSPoolPlugin.pm >>> +++ b/src/PVE/Storage/ZFSPoolPlugin.pm >>> @@ -159,7 +159,7 @@ sub parse_volname { >>> sub get_parsed_format { >>> my ($class, $name) =3D @_; >>> =20 >>> - return ($class->parse_volname($name))[6]; >>> + return ($class->parse_volname($name))[6]; # dies for invalid volum= e names >>=20 >> Same here, I belive this belongs in the POD, as part of the "contract". >>=20 >>> } >>> =20 >>> # ZFS volume names always encode their format in the name prefix (vm- = for raw >>> @@ -170,6 +170,7 @@ sub volname_for_format { >>> =20 >>> die "unsupported format '$fmt'\n" if !($class->is_valid_format($fm= t)); >>> =20 >>> + # Note that get_parsed_format() validates the name. >>> my $name_fmt =3D $class->get_parsed_format($name); >>> return $name if $name_fmt eq $fmt; >>> =20 >>=20