From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pve-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 779851FF16B for <inbox@lore.proxmox.com>; Thu, 6 Feb 2025 16:17:36 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A48AD2B050; Thu, 6 Feb 2025 16:17:29 +0100 (CET) To: pve-devel@lists.proxmox.com Date: Thu, 6 Feb 2025 10:02:37 -0500 In-Reply-To: <20250206150237.2046776-1-dpetrov67@gmail.com> References: <20250206150237.2046776-1-dpetrov67@gmail.com> X-Mailman-Approved-At: Thu, 06 Feb 2025 16:17:27 +0100 MIME-Version: 1.0 Message-ID: <mailman.97.1738855048.293.pve-devel@lists.proxmox.com> List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com> List-Post: <mailto:pve-devel@lists.proxmox.com> From: Dmitry Petrov via pve-devel <pve-devel@lists.proxmox.com> Precedence: list Cc: Dmitry Petrov <dpetrov67@gmail.com> X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> Subject: [pve-devel] [PATCH pve-storage 2/2] iscsidirect plugin: do not use cache in list_images() Content-Type: multipart/mixed; boundary="===============5316479065307399948==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com> --===============5316479065307399948== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: <dpetrov67@gmail.com> X-Original-To: pve-devel@lists.proxmox.com Delivered-To: pve-devel@lists.proxmox.com Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 08425CB003 for <pve-devel@lists.proxmox.com>; Thu, 6 Feb 2025 16:02:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E6E822A726 for <pve-devel@lists.proxmox.com>; Thu, 6 Feb 2025 16:02:50 +0100 (CET) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for <pve-devel@lists.proxmox.com>; Thu, 6 Feb 2025 16:02:50 +0100 (CET) Received: by mail-il1-x12b.google.com with SMTP id e9e14a558f8ab-3d053d2e39dso3343905ab.1 for <pve-devel@lists.proxmox.com>; Thu, 06 Feb 2025 07:02:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738854163; x=1739458963; darn=lists.proxmox.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Xoyx/v/gM4b1COQkh5Z4adox5eZbhlJ0zNL5m+ugI4o=; b=fonHpyuw8hTOKFWh3/++AIs2gj0O2fcoplV+iPa6zINNeZ4QeuGWaQlXXQhtVgCG8K hP4S/rCuhzw4kygzgunWnUQSc1OTZvwikdD+n4+hhLOso+z73Rr3M4HcY/iyn+6nxgiW FJV6HygtVmn53q71auONHYLUwFESlYjunbIoiCbIhUjbubrI8CRnUKIUbRpAx5TjpPAz OG4Tyq8kFeVw2zSCeqSTMtBv4GXRnot7FmfngYUTPLZjQ/++cC+Ap2NOBDzo6RymICAB V6KpjeGYnn+h9lT9FpLNWo4zNntCjKWDgDfzxciU1EDoIyZxFP0uiE/eGEgnf9ZuQ79B +UsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738854163; x=1739458963; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xoyx/v/gM4b1COQkh5Z4adox5eZbhlJ0zNL5m+ugI4o=; b=sFlsAC8bSqJI4qAkfnQIdg43yfBWcyOeJZmXj4AU/92rzy68hihcpMv+MP20LePFWO DGJyaevhqZXmfb5XPMd+FHn5QbMBBik6r4E+raPRWaSJ9Io6Hyk7BdgMpn2oWMrG6wdH jnnBdOP3Br0eLXATAHjEB59ywXA5COHW3FBn3kGZvRNYDWU5nD8fbpPHdPlxXVlRTjET cQJmD9P9WYHZZ8jlWUJ00BOyT+5WdtJ2GFis0thKW5L2qJ3A4buKVexKb1P562FLBOzN T1fMM3NmOphB1YsLXl9AQJmRJSSFjDjA+/gKaF9fD6W3OQ0mO3O3wN5c1RQHRXV5CDDs yjdQ== X-Gm-Message-State: AOJu0YxPWJsSY9XuQTeYI/lhLA/XAceVt7SjITZSb1imeesBwMOV6HVd sD7vUGIxDu0TVE3lZQhj6EAGqPdOA0gl6xuYnSVZ5bItJYKLwt2UlQUNXQ== X-Gm-Gg: ASbGncslaNw/hLkmAahgr1mUH9Xj7nVNgXX+w10t6XwxCzJsv1ralspwbKQxYOfQ7Wd UG/iNnrL8wYcyA/nzasbUgFLLrfiGm4cMF7XLowYGdT+RK47MLorwegmN/zVxNza7ISSUu9+kT/ xMZa+ifiGqiyiQOH80+paM1MbtUK5jri7ARFaPRJeugLAle4hGB18kAB9/w9enBeVXiZAh2/AgG nxt2UuXuBWHLJ/02Iai5aw7wGNlWMhpWl1kBl898lDy27lFZg4xQbPfhG/PF1i228ftYa0EyAtz bFVmCiPs0RNBuYlXHQ6MMbs6jqAVsuFVrw== X-Google-Smtp-Source: AGHT+IEcSEBtxRiNiOdf8OgzdbP0gPQfsGD6TcCaxmsATaSUZbUGdDOhu1KUdZAfirjVq2C7jyOX4w== X-Received: by 2002:a92:ca0e:0:b0:3d0:24c0:bd3e with SMTP id e9e14a558f8ab-3d04f42ba4bmr71813125ab.7.1738854162763; Thu, 06 Feb 2025 07:02:42 -0800 (PST) Received: from pve1.nch.local (nat.nchcapital.com. [38.108.226.80]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3d05e8c8995sm2897605ab.43.2025.02.06.07.02.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Feb 2025 07:02:42 -0800 (PST) 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> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250206150237.2046776-1-dpetrov67@gmail.com> References: <20250206150237.2046776-1-dpetrov67@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.000 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain DMARC_PASS -0.1 DMARC pass policy FREEMAIL_ENVFROM_END_DIGIT 0.25 Envelope-from freemail username ends in digit FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record X-Mailman-Approved-At: Thu, 06 Feb 2025 16:17:27 +0100 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 --===============5316479065307399948== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel --===============5316479065307399948==--