public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Robert Obkircher <r.obkircher@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH v1 proxmox-backup 2/3] datastore: check that .i.bad files from S3 actually match that pattern
Date: Wed, 22 Jul 2026 16:22:00 +0200	[thread overview]
Message-ID: <72a28857-5b50-4f23-a0df-37e0bcf5b895@proxmox.com> (raw)
In-Reply-To: <20260713132338.170565-3-r.obkircher@proxmox.com>

only one small nit inline, with that addressed:

Reviewed-by: Christian Ebner <c.ebner@proxmox.com>

On 7/13/26 3:24 PM, Robert Obkircher wrote:
> Compare the characters, not just the length, and introduce a helper
> that can be tested in isolation.
> 
> Signed-off-by: Robert Obkircher <r.obkircher@proxmox.com>
> ---
>   pbs-datastore/src/chunk_store.rs | 21 ++++++++++++++-------
>   pbs-datastore/src/datastore.rs   |  7 +++----
>   2 files changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs
> index a936f5034..f40c58f7e 100644
> --- a/pbs-datastore/src/chunk_store.rs
> +++ b/pbs-datastore/src/chunk_store.rs
> @@ -360,13 +360,7 @@ impl ChunkStore {
>                               }
>   
>                               // i-th bad chunk
> -                            if bytes.len() == 64 + ".i.bad".len()
> -                                && bytes[64] == b'.'
> -                                && bytes[65] >= b'0'
> -                                && bytes[65] <= b'9'
> -                                && bytes[66] == b'.'
> -                                && bytes.ends_with(b"bad")
> -                            {
> +                            if is_bad_chunk_suffix(&bytes[64..]) {
>                                   return Some((Ok(entry), percentage, ChunkExt::Bad));
>                               }
>   
> @@ -1028,6 +1022,19 @@ impl ChunkExt {
>       }
>   }
>   
> +pub fn is_bad_chunk_suffix(s: &[u8]) -> bool {

nit: this should be pub(crate) only, no callers from outside.

> +    s.len() == ".i.bad".len() && s[0] == b'.' && s[1].is_ascii_digit() && &s[2..] == b".bad"
> +}
> +
> +#[test]
> +fn test_is_bad_chunk_suffix() {
> +    assert!(is_bad_chunk_suffix(".0.bad".as_bytes()));
> +    assert!(is_bad_chunk_suffix(".9.bad".as_bytes()));
> +    for s in [".10.bad", ".a.bad", ".bad", "0.bad", ""] {
> +        assert!(!is_bad_chunk_suffix(s.as_bytes()));
> +    }
> +}
> +

thanks a lot for the additional tests!

>   #[test]
>   fn test_chunk_store1() {
>       use tempfile::TempDir;
> diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
> index 3079fe833..bac5ce3b4 100644
> --- a/pbs-datastore/src/datastore.rs
> +++ b/pbs-datastore/src/datastore.rs
> @@ -43,7 +43,7 @@ use proxmox_section_config::SectionConfigData;
>   use crate::backup_info::{
>       BackupDir, BackupGroup, BackupInfo, OLD_LOCKING, PROTECTED_MARKER_FILENAME,
>   };
> -use crate::chunk_store::ChunkStore;
> +use crate::chunk_store::{ChunkStore, is_bad_chunk_suffix};
>   use crate::dynamic_index::{DynamicIndexReader, DynamicIndexWriter};
>   use crate::fixed_index::{FixedIndexReader, FixedIndexWriter};
>   use crate::hierarchy::{ListGroups, ListGroupsType, ListNamespaces, ListNamespacesRecursive};
> @@ -2680,13 +2680,12 @@ impl DataStore {
>           // file_name() should always be Some, as objects will have a filename
>           let file_name = path.file_name()?;
>           let bytes = file_name.as_bytes();
> -        let bad_ext_len = ".0.bad".len();
> -        let bad_chunk = if bytes.len() == 64 + bad_ext_len {
> +        let bad_chunk = if is_bad_chunk_suffix(&bytes[64..]) {
>               true
>           } else if bytes.len() == 64 {
>               false
>           } else {
> -            return None;
> +            return None; // unexpected suffix
>           };
>           if !bytes.iter().take(64).all(u8::is_ascii_hexdigit) {
>               return None;





  reply	other threads:[~2026-07-22 14:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 13:22 [PATCH v1 proxmox-backup 0/3] improve handling of bad S3 chunks during GC Robert Obkircher
2026-07-13 13:22 ` [PATCH v1 proxmox-backup 1/3] datastore: fix local path for .i.bad chunk files during S3 GC Robert Obkircher
2026-07-22 14:21   ` Christian Ebner
2026-07-13 13:22 ` [PATCH v1 proxmox-backup 2/3] datastore: check that .i.bad files from S3 actually match that pattern Robert Obkircher
2026-07-22 14:22   ` Christian Ebner [this message]
2026-07-13 13:22 ` [PATCH v1 proxmox-backup 3/3] datastore: introduce helper function to parse digest from S3ObjectKey Robert Obkircher
2026-07-22 14:22   ` 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=72a28857-5b50-4f23-a0df-37e0bcf5b895@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=r.obkircher@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