public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC storage 3/3] storage: plugin: volume_size_info: fallback to raw for non-image volumes
Date: Tue, 10 Dec 2024 12:19:30 +0100	[thread overview]
Message-ID: <20241210111930.358363-4-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20241210111930.358363-1-f.gruenbichler@proxmox.com>

as a safeguard for external storage plugins that
- override parse_volname and return "weird" formats
- but don't override volume_size_info

to prevent them from running into new file_size_info checks that only work for
certain formats we know about.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
not sure if such plugins even exist? but the warning might help us find out ;)

 src/PVE/Storage/Plugin.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Storage/Plugin.pm b/src/PVE/Storage/Plugin.pm
index 5875553..1028cc1 100644
--- a/src/PVE/Storage/Plugin.pm
+++ b/src/PVE/Storage/Plugin.pm
@@ -1129,7 +1129,13 @@ sub update_volume_attribute {
 
 sub volume_size_info {
     my ($class, $scfg, $storeid, $volname, $timeout) = @_;
-    my $format = ($class->parse_volname($volname))[6];
+    my ($vtype, $format) = ($class->parse_volname($volname))[0,6];
+
+    if ($vtype ne 'images' && $format && $format ne 'raw') {
+        warn "volume_size_info: '$storeid:$volname': falling back from format '$format' to 'raw'\n";
+        $format = 'raw';
+    }
+
     my $path = $class->filesystem_path($scfg, $volname);
     return file_size_info($path, $timeout, $format);
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

      parent reply	other threads:[~2024-12-10 11:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-10 11:19 [pve-devel] [PATCH storage 0/3] file_size_info follow-ups Fabian Grünbichler
2024-12-10 11:19 ` [pve-devel] [PATCH storage 1/3] storage: plugin: return 'raw' format when parsing non-image volumes Fabian Grünbichler
2024-12-10 11:19 ` [pve-devel] [PATCH storage 2/3] esxi: fix return value of volume_size_info for vmx volumes Fabian Grünbichler
2024-12-10 11:56   ` Fiona Ebner
2024-12-10 11:19 ` Fabian Grünbichler [this message]

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=20241210111930.358363-4-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal