[PATCH pve-storage 1/2] rbd plugin: do not use cache in list_images()

Dmitry Petrov dpetrov67 at gmail.com
Thu Feb 6 16:02:36 CET 2025


A static cache key 'rbd' was used to cache pool/storeid-specific
information. This was causing issues in case of multiple RBD pools.

Drop $cache usage instead of fixing the issue as there is no caller
using it and the same pool/storeid multiple times.

Remove $pool from rbd_ls() and get_rbd_path($scfg) from list_images().

Signed-off-by: Dmitry Petrov <dpetrov67 at gmail.com>
---
 src/PVE/Storage/RBDPlugin.pm | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/PVE/Storage/RBDPlugin.pm b/src/PVE/Storage/RBDPlugin.pm
index ef4faa6..42eefc6 100644
--- a/src/PVE/Storage/RBDPlugin.pm
+++ b/src/PVE/Storage/RBDPlugin.pm
@@ -209,9 +209,6 @@ sub run_rbd_command {
 sub rbd_ls {
     my ($scfg, $storeid) = @_;
 
-    my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
-    $pool .= "/$scfg->{namespace}" if defined($scfg->{namespace});
-
     my $raw = '';
     my $parser = sub { $raw .= shift };
 
@@ -237,7 +234,7 @@ sub rbd_ls {
 	my ($owner) = $image =~ m/^(?:vm|base)-(\d+)-/;
 	next if !defined($owner);
 
-	$list->{$pool}->{$image} = {
+	$list->{$image} = {
 	    name => $image,
 	    size => $el->{size},
 	    parent => $get_parent_image_name->($el->{parent}),
@@ -672,9 +669,7 @@ sub free_image {
 sub list_images {
     my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
 
-    $cache->{rbd} = rbd_ls($scfg, $storeid) if !$cache->{rbd};
-
-    my $dat = $cache->{rbd}->{get_rbd_path($scfg)};
+    my $dat = rbd_ls($scfg, $storeid);
     return [] if !$dat; # nothing found
 
     my $res = [];
-- 
2.39.5




More information about the pve-devel mailing list