[pbs-devel] [PATCH proxmox-backup v3 1/4] pbs-config: add token.shadow generation to ConfigVersionCache

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Jan 14 11:44:30 CET 2026


On January 2, 2026 5:07 pm, Samuel Rufinatscha wrote:
> Currently, every token-based API request reads the token.shadow file and
> runs the expensive password hash verification for the given token
> secret. This shows up as a hotspot in /status profiling (see
> bug #7017 [1]).
> 
> To solve the issue, this patch prepares the config version cache,
> so that token_shadow_generation config caching can be built on
> top of it.
> 
> This patch specifically:
> (1) implements increment function in order to invalidate generations

this is needlessly verbose..

> 
> This patch is part of the series which fixes bug #7017 [1].

this is already mentioned higher up and doesn't need to be repeated
here.

this patch needs a rebase. it would be good to call out why it is safe
to add to this struct, since it is accessed/mapped by both old and new
processes.

> 
> [1] https://bugzilla.proxmox.com/show_bug.cgi?id=7017
> 
> Signed-off-by: Samuel Rufinatscha <s.rufinatscha at proxmox.com>
> ---
>  pbs-config/src/config_version_cache.rs | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/pbs-config/src/config_version_cache.rs b/pbs-config/src/config_version_cache.rs
> index e8fb994f..1376b11d 100644
> --- a/pbs-config/src/config_version_cache.rs
> +++ b/pbs-config/src/config_version_cache.rs
> @@ -28,6 +28,8 @@ struct ConfigVersionCacheDataInner {
>      // datastore (datastore.cfg) generation/version
>      // FIXME: remove with PBS 3.0
>      datastore_generation: AtomicUsize,
> +    // Token shadow (token.shadow) generation/version.
> +    token_shadow_generation: AtomicUsize,
>      // Add further atomics here
>  }
>  
> @@ -153,4 +155,20 @@ impl ConfigVersionCache {
>              .datastore_generation
>              .fetch_add(1, Ordering::AcqRel)
>      }
> +
> +    /// Returns the token shadow generation number.
> +    pub fn token_shadow_generation(&self) -> usize {
> +        self.shmem
> +            .data()
> +            .token_shadow_generation
> +            .load(Ordering::Acquire)
> +    }
> +
> +    /// Increase the token shadow generation number.
> +    pub fn increase_token_shadow_generation(&self) -> usize {
> +        self.shmem
> +            .data()
> +            .token_shadow_generation
> +            .fetch_add(1, Ordering::AcqRel)
> +    }
>  }
> -- 
> 2.47.3
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




More information about the pbs-devel mailing list