From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 7C8A8906DB for ; Fri, 2 Sep 2022 09:21:48 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 676502CD83 for ; Fri, 2 Sep 2022 09:21:18 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS for ; Fri, 2 Sep 2022 09:21:16 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C2CE3434E2 for ; Fri, 2 Sep 2022 09:21:15 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 2 Sep 2022 09:21:14 +0200 Message-Id: <20220902072114.635440-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.093 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox-backup] backup-client: mount: fix read of larger files X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Sep 2022 07:21:48 -0000 fuse_lowlevel.h says about read: Read should send exactly the number of bytes requested except on EOF or error, otherwise the rest of the data will be substituted with zeroes. but we simply forwarded the bytes we got from 'read_at'. The result was that larger files were truncated as soon as read_at returned not the exact number of bytes requested. To fix that, loop over 'read_at' until our buffer is full, or we read 0 bytes, indicating EOF. reported in the forum: https://forum.proxmox.com/threads/proxmox-backup-client-mounting-a-pxar-archive-gives-truncated-files.114447/ Signed-off-by: Dominik Csapak --- tested with some larger files (>100MiB), before the patch, a 'cmp' with the original would always fail, after it worked like expected pbs-client/src/pxar/fuse.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pbs-client/src/pxar/fuse.rs b/pbs-client/src/pxar/fuse.rs index e9e1b6f3..f2ce6a43 100644 --- a/pbs-client/src/pxar/fuse.rs +++ b/pbs-client/src/pxar/fuse.rs @@ -566,8 +566,17 @@ impl SessionImpl { let file = self.get_lookup(inode)?; let content = self.open_content(&file)?; let mut buf = vec::undefined(len); - let got = content.read_at(&mut buf, offset).await?; - buf.truncate(got); + let mut pos = 0; + loop { + let got = content + .read_at(&mut buf[pos..], offset + pos as u64) + .await?; + pos += got; + if got == 0 || pos >= len { + break; + } + } + buf.truncate(pos); Ok(buf) } -- 2.30.2