all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox Backup Server development discussion
	<pbs-devel@lists.proxmox.com>,
	Gabriel Goller <g.goller@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup] fix #4823: datastore: ignore vanished files when walking directory
Date: Thu, 7 Sep 2023 17:05:14 +0200	[thread overview]
Message-ID: <482af171-fcb0-4dc6-b662-66d1511fc4a3@proxmox.com> (raw)
In-Reply-To: <20230905093747.54879-1-g.goller@proxmox.com>

On 05/09/2023 11:37, Gabriel Goller wrote:
> When walking through a datastore on a GC run, it can
> happen that the snapshot is deleted, and then walked over.
> For example:
> - read dir entry for group
> - walk entries (snapshots)
> - snapshot X is removed/pruned
> - walking reaches snapshot X, but ENOENT
> Previously we bailed here, now we just ignore it.
> 

looks mostly fine, some style nits and a actual comment inline.

> Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
> ---
>  pbs-datastore/src/datastore.rs | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
> index fe75d9b5..d135ad90 100644
> --- a/pbs-datastore/src/datastore.rs
> +++ b/pbs-datastore/src/datastore.rs
> @@ -869,18 +869,24 @@ impl DataStore {
>          let handle_entry_err = |err: walkdir::Error| {
>              if let Some(inner) = err.io_error() {
>                  if let Some(path) = err.path() {
> -                    if inner.kind() == io::ErrorKind::PermissionDenied {
> -                        // only allow to skip ext4 fsck directory, avoid GC if, for example,
> -                        // a user got file permissions wrong on datastore rsync to new server
> -                        if err.depth() > 1 || !path.ends_with("lost+found") {
> -                            bail!("cannot continue garbage-collection safely, permission denied on: {:?}", path)
> +                    match inner.kind() {
> +                        io::ErrorKind::PermissionDenied => {

that's some deep indentation level.. not a must, but maybe you find
some good/simple way to refactor some of this to make it a bit less
crowded here (if, then in a separate patch please) 

> +                            // only allow to skip ext4 fsck directory, avoid GC if, for example,
> +                            // a user got file permissions wrong on datastore rsync to new server
> +                            if err.depth() > 1 || !path.ends_with("lost+found") {
> +                                bail!("cannot continue garbage-collection safely, permission denied on: {:?}", path)
> +                            }
> +                        }
> +                        io::ErrorKind::NotFound => {
> +                            // ignore vanished file

would be still good to log that here, at least at debug level
if it can be noisy; but as there wasn't many that run into this
in the four years of PBS existing I'd guess a always visible
level is fine as long as the log message doesn't sounds scary. 

> +                        }
> +                        _ => {
> +                            bail!(
> +                                "unexpected error on datastore traversal: {} - {:?}",
> +                                inner,
> +                                path

as already mentioned once, please use captured variables directly
in the format strings for new additions or lines that you touch anyway.
E.g.:

bail!("unexpected error on datastore traversal: {inner} - {path:?}")

> +                            )
>                          }
> -                    } else {
> -                        bail!(
> -                            "unexpected error on datastore traversal: {} - {:?}",
> -                            inner,
> -                            path
> -                        )

same here

>                      }
>                  } else {
>                      bail!("unexpected error on datastore traversal: {}", inner)





  reply	other threads:[~2023-09-07 15:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05  9:37 Gabriel Goller
2023-09-07 15:05 ` Thomas Lamprecht [this message]
2023-09-08  7:41   ` Gabriel Goller
2023-09-08  9:36     ` Thomas Lamprecht
2023-09-08 12:56       ` Gabriel Goller

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=482af171-fcb0-4dc6-b662-66d1511fc4a3@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=g.goller@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal