public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>,
	"Proxmox Backup Server development discussion"
	<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup] mapped loop device: use read loop instead of read_exact
Date: Thu, 29 Jun 2023 13:46:23 +0200	[thread overview]
Message-ID: <15a22deb-baea-6940-7d96-94c27da578d1@proxmox.com> (raw)
In-Reply-To: <1688038237.3xn9d6donm.astroid@yuna.none>

On 6/29/23 13:35, Fabian Grünbichler wrote:
> On June 29, 2023 1:03 pm, Dominik Csapak wrote:
>> On 6/29/23 12:32, Fabian Grünbichler wrote:
>>> since read_exact does not support short reads, which can easily happen if the
>>> mapped image's EOF is not aligned with the request size.
>>>
>>> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
>>> ---
>>>
>>> Notes:
>>>       reported on the forum:
>>>       
>>>       https://forum.proxmox.com/threads/problem-backing-up-using-backup-client.129347
>>>       
>>>       did a quick test reading from a mapped image full of random data, observed
>>>       no performance difference..
>>>
>>>    pbs-fuse-loop/src/fuse_loop.rs | 19 +++++++++++++------
>>>    1 file changed, 13 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/pbs-fuse-loop/src/fuse_loop.rs b/pbs-fuse-loop/src/fuse_loop.rs
>>> index 3d0ef123..7e780799 100644
>>> --- a/pbs-fuse-loop/src/fuse_loop.rs
>>> +++ b/pbs-fuse-loop/src/fuse_loop.rs
>>> @@ -188,13 +188,20 @@ impl<R: AsyncRead + AsyncSeek + Unpin> FuseLoopSession<R> {
>>>                                match self.reader.seek(SeekFrom::Start(req.offset)).await {
>>>                                    Ok(_) => {
>>>                                        let mut buf = vec![0u8; req.size];
>>> -                                    match self.reader.read_exact(&mut buf).await {
>>> -                                        Ok(_) => {
>>> -                                            req.reply(&buf)
>>> -                                        },
>>> -                                        Err(e) => {
>>> -                                            req.io_fail(e)
>>> +                                    let mut read = 0;
>>> +                                    let mut res = Ok(());
>>> +                                    while read < req.size && res.is_ok() {
>>> +                                        match self.reader.read(&mut buf).await {
>>> +                                            Ok(0) => { break; },
>>> +                                            Ok(n) => { read += n; },
>>> +                                            Err(e) => { res = Err(e); },
>>>                                            }
>>
>> according to https://doc.rust-lang.org/std/io/trait.Read.html the error
>> with errorkind 'Interrupted' should be retried so imho we should do that here?
> 
> this is tokio's AsyncRead(Ext), which doesn't have that remark (and
> AFAICT, we don't handle that error when using it anywhere).. if it
> were std::io::Read I'd have used our ReadExt's read_exact_or_eof :)

yes, you're right ofc. sorry for the noise then

> 
>>
>>> +                                    };
>>> +                                    if let Err(e) = res {
>>> +                                        req.io_fail(e)
>>> +                                    } else {
>>> +                                        buf.truncate(read);
>>> +                                        req.reply(&buf)
>>>                                        }
>>>                                    },
>>>                                    Err(e) => {
>>
>>
>>





  reply	other threads:[~2023-06-29 11:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 10:32 Fabian Grünbichler
2023-06-29 11:03 ` Dominik Csapak
2023-06-29 11:35   ` Fabian Grünbichler
2023-06-29 11:46     ` Dominik Csapak [this message]
2023-11-27  9:53 ` Fabian Grünbichler
2023-11-27 13:22 ` Wolfgang Bumiller
2023-11-27 17:27   ` Fabian Grünbichler
2023-11-28 10:07     ` Wolfgang Bumiller

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=15a22deb-baea-6940-7d96-94c27da578d1@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal