public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Robert Obkircher <r.obkircher@proxmox.com>
To: Christian Ebner <c.ebner@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH v1 proxmox-backup 2/3] client: pxar: consistently ignore vanished files and warn about them
Date: Fri, 8 May 2026 13:40:05 +0200	[thread overview]
Message-ID: <89b54e4c-1f39-43d5-b3c2-6d03a6170c3d@proxmox.com> (raw)
In-Reply-To: <4d21540f-f92b-48e1-a586-81a2d4412b05@proxmox.com>


On 08.05.26 11:36, Christian Ebner wrote:
> On 5/7/26 5:48 PM, Robert Obkircher wrote:
>>
>> On 07.05.26 10:36, Christian Ebner wrote:
>>> Two nits inline, otherwise LGTM.
>>>
>>> Reviewed-by: Christian Ebner <c.ebner@proxmox.com>
>>>
>>> On 5/6/26 1:48 PM, Robert Obkircher wrote:
>>>> Combine the error paths and treat deleted entries equally in both
>>>> cases. Since this used to be a hard error in some cases, it also
>>>> makes
>>>> sense to emit a warning about it.
>>>>
>>>> Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
>>>> ---
>>>>    pbs-client/src/pxar/create.rs | 32
>>>> ++++++++++++--------------------
>>>>    1 file changed, 12 insertions(+), 20 deletions(-)
>>>>
>>>> diff --git a/pbs-client/src/pxar/create.rs
>>>> b/pbs-client/src/pxar/create.rs
>>>> index 08c5c9b44..47cbf50a8 100644
>>>> --- a/pbs-client/src/pxar/create.rs
>>>> +++ b/pbs-client/src/pxar/create.rs
>>>> @@ -695,36 +695,28 @@ impl Archiver {
>>>>                        })
>>>>                    });
>>>>    -            match match_result {
>>>> +            let stat_result = match match_result {
>>>>                    Ok(Some(MatchType::Exclude)) => {
>>>>                        debug!("matched by exclude pattern
>>>> '{full_path:?}'");
>>>>                        continue;
>>>>                    }
>>>> -                Ok(_) => (),
>>>> -                Err(err) if err.not_found() => continue,
>>>> +                Ok(_) => stat_result.map_or_else(do_stat, Ok),
>>>> +                Err(e) => Err(e),
>>>> +            };
>>>> +
>>>> +            let stat = match stat_result {
>>>> +                Ok(stat) => stat,
>>>> +                Err(err) if err.not_found() => {
>>>> +                    warn!("warning: file vanished while reading
>>>> directory: {full_path:?}");
>>>
>>> nit: should use and slightly adapt the report_vanished_file() helper.
>> Imo the messages should be different, so this would essentially
>> turn into:
>>
>> fn report_vanished_file(message: &str, path: &Path) {
>>      warn!("warning: file vanished {message}: {path:?}")
>> }
>>
>> which seemed overly complicated for something that would only be
>> called from two locations.
>
> Fine by me, but in that case I would suggest to cleanup and inline
> the other call site as well. No need to keep it around then ...
>
>>
>> I also noticed that `read_pxar_excludes` calls `open_file` without
>> setting `self.path`, so the existing helpers would print the wrong
>> message in that case.
>>
>>>
>>>> +                    continue;
>>>> +                }
>>>>                    Err(Errno::ESTALE) => {
>>>>                       
>>>> self.report_stale_file_handle(Some(&full_path));
>>>>                        continue;
>>>>                    }
>>>>                    Err(err) => {
>>>> -                    return Err(err).with_context(|| format!("stat
>>>> failed on {full_path:?}"))
>>>> +                    return
>>>> Err(Error::from(err).context(format!("stat failed on
>>>> {full_path:?}")))
>>>
>>> nit: please use with_context() over context() here, since the former
>>> is evaluated lazily only once an error does occur [0].
>>>
>>> [0]
>>> https://docs.rs/anyhow/latest/anyhow/trait.Context.html#required-methods
>>>
>> How? This is the error path that converts the Errno to an anyhow
>> error. It doesn't call the method from that trait.
>
> diff --git a/pbs-client/src/pxar/create.rs
> b/pbs-client/src/pxar/create.rs
> index c101415c1..e1e4eea3b 100644
> --- a/pbs-client/src/pxar/create.rs
> +++ b/pbs-client/src/pxar/create.rs
> @@ -720,7 +720,8 @@ impl Archiver {
>                      continue;
>                  }
>                  Err(err) => {
> -                    return
> Err(Error::from(err).context(format!("stat failed on {full_path:?}")))
> +                    return Err(Error::from(err))
> +                        .with_context(|| format!("stat failed on
> {full_path:?}"))
>                  }
>              };
>
> This should do, unless I'm overlooking something? 

If we inline <Result as Context>::with_context then your version it
results in

match Err(Error::from(err)) {
    Ok(ok) => Ok(ok),
    Err(error) => Err(error.ext_context(context())),
}

which is not lazy. The original code had both versions and I chose the
more explicit one.

>
>>>
>>>>                    }
>>>> -            }
>>>> -
>>>> -            let stat = match stat_result {
>>>> -                Some(stat) => stat,
>>>> -                None => match do_stat() {
>>>> -                    Ok(stat) => stat,
>>>> -                    Err(Errno::ESTALE) => {
>>>> -
>>>> self.report_stale_file_handle(Some(&full_path));
>>>> -                        continue;
>>>> -                    }
>>>> -                    Err(err) => {
>>>> -                        return Err(
>>>> -                            Error::from(err).context(format!("stat
>>>> failed on {full_path:?}"))
>>>> -                        )
>>>> -                    }
>>>> -                },
>>>>                };
>>>>                  self.entry_counter += 1;
>>>
>




  reply	other threads:[~2026-05-08 11:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-06 11:49 [PATCH v1 proxmox-backup 0/3] improve fstatat error handling Robert Obkircher
2026-05-06 11:49 ` [PATCH v1 proxmox-backup 1/3] client: pxar: improve variable names Robert Obkircher
2026-05-07  8:38   ` Christian Ebner
2026-05-06 11:49 ` [PATCH v1 proxmox-backup 2/3] client: pxar: consistently ignore vanished files and warn about them Robert Obkircher
2026-05-07  8:38   ` Christian Ebner
2026-05-07 15:50     ` Robert Obkircher
2026-05-08  9:38       ` Christian Ebner
2026-05-08 11:40         ` Robert Obkircher [this message]
2026-05-08 13:26           ` Christian Ebner
2026-05-08 14:03             ` Robert Obkircher
2026-05-08 14:12               ` Christian Ebner
2026-05-06 11:49 ` [PATCH v1 proxmox-backup 3/3] client: pxar: skip files on fstatat permission errors Robert Obkircher
2026-05-07  8:42   ` Christian Ebner

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=89b54e4c-1f39-43d5-b3c2-6d03a6170c3d@proxmox.com \
    --to=r.obkircher@proxmox.com \
    --cc=c.ebner@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