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 7BFF790D00 for ; Mon, 5 Sep 2022 15:21:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 6B36A1D7D5 for ; Mon, 5 Sep 2022 15:20:51 +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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 5 Sep 2022 15:20:50 +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 34C4744C67 for ; Mon, 5 Sep 2022 15:20:50 +0200 (CEST) Date: Mon, 05 Sep 2022 15:20:43 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20220902072114.635440-1-d.csapak@proxmox.com> In-Reply-To: <20220902072114.635440-1-d.csapak@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1662383927.ks7c13wq7m.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.161 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] applied: [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: Mon, 05 Sep 2022 13:21:21 -0000 with a comment added and a slight rewording of the commit message, as triggering the bug doesn't really truncate files, it overwrites parts of=20 them with all-zero blocks at different offsets. On September 2, 2022 9:21 am, Dominik Csapak wrote: > fuse_lowlevel.h says about read: >=20 > 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. >=20 > 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. >=20 > To fix that, loop over 'read_at' until our buffer is full, or we read > 0 bytes, indicating EOF. >=20 > reported in the forum: > https://forum.proxmox.com/threads/proxmox-backup-client-mounting-a-pxar-a= rchive-gives-truncated-files.114447/ >=20 > Signed-off-by: Dominik Csapak > --- > tested with some larger files (>100MiB), before the patch, a 'cmp' with t= he > original would always fail, after it worked like expected >=20 > pbs-client/src/pxar/fuse.rs | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) >=20 > 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 =3D self.get_lookup(inode)?; > let content =3D self.open_content(&file)?; > let mut buf =3D vec::undefined(len); > - let got =3D content.read_at(&mut buf, offset).await?; > - buf.truncate(got); > + let mut pos =3D 0; > + loop { > + let got =3D content > + .read_at(&mut buf[pos..], offset + pos as u64) > + .await?; > + pos +=3D got; > + if got =3D=3D 0 || pos >=3D len { > + break; > + } > + } > + buf.truncate(pos); > Ok(buf) > } > =20 > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel >=20 >=20 >=20