From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: [pbs-devel] applied: [PATCH proxmox-backup] backup-client: mount: fix read of larger files
Date: Mon, 05 Sep 2022 15:20:43 +0200 [thread overview]
Message-ID: <1662383927.ks7c13wq7m.astroid@nora.none> (raw)
In-Reply-To: <20220902072114.635440-1-d.csapak@proxmox.com>
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
them with all-zero blocks at different offsets.
On September 2, 2022 9:21 am, Dominik Csapak wrote:
> 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 <d.csapak@proxmox.com>
> ---
> 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
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
prev parent reply other threads:[~2022-09-05 13:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-02 7:21 [pbs-devel] " Dominik Csapak
2022-09-05 13:20 ` Fabian Grünbichler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1662383927.ks7c13wq7m.astroid@nora.none \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox