all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dmitry Petrov via pve-devel <pve-devel@lists.proxmox.com>
To: pve-devel@lists.proxmox.com
Cc: Dmitry Petrov <dpetrov67@gmail.com>
Subject: [pve-devel] [PATCH pve-storage 2/2] iscsidirect plugin: do not use cache in list_images()
Date: Thu,  6 Feb 2025 10:02:37 -0500	[thread overview]
Message-ID: <mailman.97.1738855048.293.pve-devel@lists.proxmox.com> (raw)
In-Reply-To: <20250206150237.2046776-1-dpetrov67@gmail.com>

[-- Attachment #1: Type: message/rfc822, Size: 9487 bytes --]

From: Dmitry Petrov <dpetrov67@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: Dmitry Petrov <dpetrov67@gmail.com>
Subject: [PATCH pve-storage 2/2] iscsidirect plugin: do not use cache in list_images()
Date: Thu,  6 Feb 2025 10:02:37 -0500
Message-ID: <20250206150237.2046776-3-dpetrov67@gmail.com>

A static cache key 'directiscsi' was used to cache storeid-specific
information. This was causing issues in case of multiple instances.

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

Remove $storeid from iscsi_ls() and its callers.

Signed-off-by: Dmitry Petrov <dpetrov67@gmail.com>
---
 src/PVE/Storage/ISCSIDirectPlugin.pm | 71 ++++++++++++----------------
 1 file changed, 30 insertions(+), 41 deletions(-)

diff --git a/src/PVE/Storage/ISCSIDirectPlugin.pm b/src/PVE/Storage/ISCSIDirectPlugin.pm
index 0aca4b6..60bc94e 100644
--- a/src/PVE/Storage/ISCSIDirectPlugin.pm
+++ b/src/PVE/Storage/ISCSIDirectPlugin.pm
@@ -15,7 +15,7 @@ use PVE::JSONSchema qw(get_standard_option);
 use base qw(PVE::Storage::Plugin);
 
 sub iscsi_ls {
-    my ($scfg, $storeid) = @_;
+    my ($scfg) = @_;
 
     my $portal = $scfg->{portal};
     my $cmd = ['/usr/bin/iscsi-ls', '-s', 'iscsi://'.$portal ];
@@ -27,29 +27,27 @@ sub iscsi_ls {
        "T"   => 1024*1024*1024*1024
     );
     eval {
-
 	    run_command($cmd, errmsg => "iscsi error", errfunc => sub {}, outfunc => sub {
-	        my $line = shift;
-	        $line = trim($line);
-	        if( $line =~ /Lun:(\d+)\s+([A-Za-z0-9\-\_\.\:]*)\s+\(Size:([0-9\.]*)(k|M|G|T)\)/ ) {
-	            my $image = "lun".$1;
-	            my $size = $3;
-	            my $unit = $4;
-				
-	            $list->{$storeid}->{$image} = {
-	                name => $image,
-	                size => $size * $unittobytes{$unit},
+		my $line = shift;
+		$line = trim($line);
+		if( $line =~ /Lun:(\d+)\s+([A-Za-z0-9\-\_\.\:]*)\s+\(Size:([0-9\.]*)(k|M|G|T)\)/ ) {
+		    my $image = "lun".$1;
+		    my $size = $3;
+		    my $unit = $4;
+
+		    $list->{$image} = {
+			name => $image,
+			size => $size * $unittobytes{$unit},
 			format => 'raw',
-	            };
-	        }
+		    };
+		}
 	    });
     };
 
     my $err = $@;
-    die $err if $err && $err !~ m/TESTUNITREADY failed with SENSE KEY/ ;
+    die $err if $err && $err !~ m/TESTUNITREADY failed with SENSE KEY/;
 
     return $list;
-
 }
 
 # Configuration
@@ -130,43 +128,34 @@ sub free_image {
     die "can't free space in iscsi storage\n";
 }
 
-
 sub list_images {
     my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
 
     my $res = [];
 
-    $cache->{directiscsi} = iscsi_ls($scfg,$storeid) if !$cache->{directiscsi};
-
     # we have no owner for iscsi devices
 
-    my $target = $scfg->{target};
-
-    if (my $dat = $cache->{directiscsi}->{$storeid}) {
-
-        foreach my $volname (keys %$dat) {
-
-            my $volid = "$storeid:$volname";
+    my $dat = iscsi_ls($scfg);
+    foreach my $volname (keys %$dat) {
+	my $volid = "$storeid:$volname";
 
-            if ($vollist) {
-                my $found = grep { $_ eq $volid } @$vollist;
-                next if !$found;
-            } else {
-                # we have no owner for iscsi devices
-                next if defined($vmid);
-            }
+	if ($vollist) {
+	    my $found = grep { $_ eq $volid } @$vollist;
+	    next if !$found;
+	} else {
+	    # we have no owner for iscsi devices
+	    next if defined($vmid);
+	}
 
-            my $info = $dat->{$volname};
-            $info->{volid} = $volid;
+	my $info = $dat->{$volname};
+	$info->{volid} = $volid;
 
-            push @$res, $info;
-        }
+	push @$res, $info;
     }
 
     return $res;
 }
 
-
 sub status {
     my ($class, $storeid, $scfg, $cache) = @_;
 
@@ -208,8 +197,8 @@ sub deactivate_volume {
 sub volume_size_info {
     my ($class, $scfg, $storeid, $volname, $timeout) = @_;
 
-    my $vollist = iscsi_ls($scfg,$storeid);
-    my $info = $vollist->{$storeid}->{$volname};
+    my $vollist = iscsi_ls($scfg);
+    my $info = $vollist->{$volname};
 
     return wantarray ? ($info->{size}, 'raw', 0, undef) : $info->{size};
 }
@@ -236,7 +225,7 @@ sub volume_snapshot_delete {
 
 sub volume_has_feature {
     my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;
-    
+
     my $features = {
 	copy => { current => 1},
     };
-- 
2.39.5



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

      parent reply	other threads:[~2025-02-06 15:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250206150237.2046776-1-dpetrov67@gmail.com>
2025-02-06 15:02 ` [pve-devel] [PATCH pve-storage 1/2] rbd " Dmitry Petrov via pve-devel
2025-02-06 15:02 ` Dmitry Petrov via pve-devel [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=mailman.97.1738855048.293.pve-devel@lists.proxmox.com \
    --to=pve-devel@lists.proxmox.com \
    --cc=dpetrov67@gmail.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