From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id BCB191FF15E for ; Tue, 11 Mar 2025 19:00:30 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A621416C42; Tue, 11 Mar 2025 19:00:21 +0100 (CET) To: pve-devel@lists.proxmox.com Date: Tue, 11 Mar 2025 18:59:25 +0100 MIME-Version: 1.0 Message-ID: List-Id: Proxmox VE development discussion List-Post: From: Victor Seva via pve-devel Precedence: list Cc: Victor Seva X-Mailman-Version: 2.1.29 X-BeenThere: pve-devel@lists.proxmox.com List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Proxmox VE development discussion List-Help: Subject: [pve-devel] [PATCH storage v3] fix #957 iscsi: improve check_connection logic Content-Type: multipart/mixed; boundary="===============3488287478601238413==" Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" --===============3488287478601238413== Content-Type: message/rfc822 Content-Disposition: inline Return-Path: 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 3833BD5F1A for ; Tue, 11 Mar 2025 19:00:20 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 15CDA16C0F for ; Tue, 11 Mar 2025 19:00:20 +0100 (CET) Received: from mail-106109.protonmail.ch (mail-106109.protonmail.ch [79.135.106.109]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 ; Tue, 11 Mar 2025 19:00:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=torreviejawireless.org; s=protonmail; t=1741715994; x=1741975194; bh=nBAPEXdXZ6XITu/2fxC78va7M4wo5vzkz2ph9xeIooI=; h=From:To:Cc:Subject:Date:Message-ID:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID:BIMI-Selector:List-Unsubscribe: List-Unsubscribe-Post; b=n0k6oTEjaS45nf1mijldSYesA+AVPTDiqQzxDutWDiqz5AH1du/UzICgAi1+VK9LZ tTtdGtrzDeJyTS/A2HtJMtbdqCdy6PWioOlwH3umag8yf2qwcPDYdJsCLnkgA+O4LB sv0p2XDM6UcwLZsxyZrprvg5qozXcK9cNe24B/Kr9XpSFziqRQiCx3TBj2MBVrDf/N ZFAEz850+X3jgAoEwwUAGvT2Gav47VFsdNHa/SWwQcYWQz+G/OTd+g8Ac+fVtxlgiP VZw6LoLc0Yeo0qxNtsQq1NgfvBpGoeaJYO8T617E5RUwGp9lk86wIBczvYaZThiguh Xx2MkaaiBb99w== X-Pm-Submission-Id: 4ZC1kJ6H4qzDr From: Victor Seva To: pve-devel@lists.proxmox.com Subject: [PATCH storage v3] fix #957 iscsi: improve check_connection logic Date: Tue, 11 Mar 2025 18:59:25 +0100 Message-ID: <20250311175925.26830-1-linuxmaniac@torreviejawireless.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.001 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 RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_PASS -0.001 SPF: HELO matches SPF record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [iscsiplugin.pm,torreviejawireless.org] don't check tcp connection directly if there are already sessions. Use iscsiadm command to check the sessions status instead. pvestatd is calling check_connection every 10 seconds. This check produces a lot of noise at the iscsi server logging. Signed-off-by: Victor Seva --- src/PVE/Storage/ISCSIPlugin.pm | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/PVE/Storage/ISCSIPlugin.pm b/src/PVE/Storage/ISCSIPlugin.pm index eb70453..89fc871 100644 --- a/src/PVE/Storage/ISCSIPlugin.pm +++ b/src/PVE/Storage/ISCSIPlugin.pm @@ -66,6 +66,23 @@ sub iscsi_test_portal { return PVE::Network::tcp_ping($server, $port || 3260, 2); } +sub iscsi_test_session { + my ($sid) = @_; + my $cmd = [$ISCSIADM, '--mode', 'session', '--sid', $sid, '-P1']; + + my $res = 0; + eval { + run_command($cmd, errmsg => 'iscsi session test failed', outfunc => sub { + my $line = shift; + if ($line =~ m/^\s+iSCSI Session State: LOGGED_IN\s*$/) { + $res = 1; + } + }); + }; + die "session check failed: $@\n" if $@; + return $res; +} + sub iscsi_portals { my ($target, $portal_in) = @_; @@ -560,11 +577,22 @@ sub activate_volume { sub check_connection { my ($class, $storeid, $scfg) = @_; + my $cache = {}; + my $sessions = iscsi_session($cache, $scfg->{target}); my $portals = iscsi_portals($scfg->{target}, $scfg->{portal}); - for my $portal (@$portals) { - my $result = iscsi_test_portal($portal); - return $result if $result; + for my $portal ($portals->@*) { + my $session_exists = 0; + for my $session ($sessions->@*) { + next if $session->{portal} ne $portal; + $session_exists = 1; + my $result = iscsi_test_session($session->{session_id}); + return $result if $result; + } + next if $session_exists; + # no sessions, check portal via tcp + my $result = iscsi_test_portal($portal); + return $result if $result; } return 0; -- 2.43.0 --===============3488287478601238413== 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 --===============3488287478601238413==--