From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id EFC761FF137 for ; Tue, 31 Mar 2026 04:07:33 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4E012B3EA; Tue, 31 Mar 2026 04:07:54 +0200 (CEST) From: Kefu Chai To: pve-devel@lists.proxmox.com Subject: [PATCH manager 1/1] ceph: pool: fix pool statistics filter returning wrong pool's data Date: Tue, 31 Mar 2026 10:07:39 +0800 Message-ID: <20260331020739.818888-2-k.chai@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260331020739.818888-1-k.chai@proxmox.com> References: <20260331020739.818888-1-k.chai@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774922811820 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.118 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 1 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 1 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 1 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: ENHF5LHS6JIQFADTAQVDT3GWAPWITG52 X-Message-ID-Hash: ENHF5LHS6JIQFADTAQVDT3GWAPWITG52 X-MailFrom: k.chai@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The condition filtering the 'ceph df' response to the requested pool had a logic error: next if !defined($d->{name}) && !$d->{name} ne "$pool"; With '&&', short-circuit evaluation means the name comparison is never reached when $d->{name} is defined. All entries with a defined name pass through, and $data->{statistics} ends up holding the stats of whichever pool appears last in the output. The combination of double negation and '&&' also makes the condition difficult to reason about: a reader must mentally apply De Morgan's law to understand what is being skipped, increasing the chance of misreading the logic. The !defined() guard is also unnecessary. The 'ceph df' response always includes a 'name' field for every pool entry: PGMap.cc:dump_pool_stats_full calls f->dump_string("name", pool_name) unconditionally for each pool in the OSD map. Multiple mgr modules (influx, prometheus, telegraf) access pool['name'] directly from the df output without any None/missing check, confirming that 'name' is part of the established contract for this response. Simplify to a plain string comparison. Signed-off-by: Kefu Chai --- PVE/API2/Ceph/Pool.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PVE/API2/Ceph/Pool.pm b/PVE/API2/Ceph/Pool.pm index 73166cdf..587c6c96 100644 --- a/PVE/API2/Ceph/Pool.pm +++ b/PVE/API2/Ceph/Pool.pm @@ -787,7 +787,7 @@ __PACKAGE__->register_method({ foreach my $d (@{ $res->{pools} }) { next if !$d->{stats}; - next if !defined($d->{name}) && !$d->{name} ne "$pool"; + next if $d->{name} ne $pool; $data->{statistics} = $d->{stats}; } -- 2.47.3