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 8C4471FF13F for ; Thu, 12 Mar 2026 15:42:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B2EC51C2FE; Thu, 12 Mar 2026 15:42:50 +0100 (CET) Message-ID: <9e4e0d75-bc79-4d20-a688-7a873aa308f7@proxmox.com> Date: Thu, 12 Mar 2026 15:42:15 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH proxmox v5 07/13] s3-client: account for downloaded bytes in incoming response body To: Hannes Laimer , pbs-devel@lists.proxmox.com References: <20260311130823.724888-1-c.ebner@proxmox.com> <20260311130823.724888-8-c.ebner@proxmox.com> <736a7978-bb57-48d1-8b6a-a2c5ab492e61@proxmox.com> Content-Language: en-US, de-DE From: Christian Ebner In-Reply-To: <736a7978-bb57-48d1-8b6a-a2c5ab492e61@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1773326500360 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.057 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_MSPIKE_H2 0.001 Average reputation (+2) 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: GLNQVLEIKDGFKIK7UZUIQ335TQ622PNT X-Message-ID-Hash: GLNQVLEIKDGFKIK7UZUIQ335TQ622PNT X-MailFrom: c.ebner@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 Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 3/12/26 3:13 PM, Hannes Laimer wrote: > On 2026-03-11 14:09, Christian Ebner wrote: >> Keep track of the downloaded contents in get object responses by >> accounting of passing bytes when collecting the incoming body. >> >> To do so, the shared request counters are stored via an atomic >> reference counter and cloned along to the response reader and >> a new `Content` type which wraps `Incoming` and implements the >> `Body`, where the accounting happens. >> >> Signed-off-by: Christian Ebner >> --- > > [..] > >> +impl Body for Content { >> + type Data = Bytes; >> + type Error = hyper::Error; >> + >> + fn poll_frame( >> + mut self: Pin<&mut Self>, >> + cx: &mut Ctx<'_>, >> + ) -> Poll, Self::Error>>> { >> + let mut this = self.as_mut(); >> + >> + let incoming = Pin::new(&mut this.incoming).poll_frame(cx); >> + >> + if let Some(counter) = self.request_counters.as_ref() { >> + match incoming { >> + Poll::Pending => Poll::Pending, >> + Poll::Ready(f) => { >> + if let Some(Ok(frame)) = f { >> + let bytes = frame >> + .data_ref() >> + .map(|bytes| bytes.len() as u64) >> + .unwrap_or(0); >> + let _ = counter.add_download_traffic(bytes, Ordering::AcqRel); >> + Poll::Ready(Some(Ok(frame))) >> + } else { >> + Poll::Ready(None) > > this swallows errors I think? in the else branch we should > ``` > other => Poll::Read(other) > ``` Yes, good catch! The error must be passed along in the stream! > >> + } >> + } >> + } >> + } else { >> + return incoming; >> + } >> + } >> + >> + fn is_end_stream(&self) -> bool { >> + self.incoming.is_end_stream() >> + } >> + >> + fn size_hint(&self) -> SizeHint { >> + self.incoming.size_hint() >> + } >> +} > > [..]