all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [PATCH proxmox-backup 3/4] datastore: s3: avoid double calls to rather expensive backup_user()
Date: Mon,  1 Jun 2026 14:31:23 +0200	[thread overview]
Message-ID: <20260601123124.461765-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20260601123124.461765-1-c.ebner@proxmox.com>

backup_user() internally calls User::from_name() which itself uses
getpwnam_r(3) [0] and therefore can involve nsswitch.conf and
/etc/passwd parsing, including several syscalls to do so as
demonstrated by a strace in [1].

Therefore, only call the helper once and clone it to get multiple
instances instead.

[0] https://docs.rs/nix/0.29.0/nix/unistd/struct.User.html#method.from_name
[1] https://bugzilla.proxmox.com/show_bug.cgi?id=7642

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 pbs-datastore/src/datastore.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 42aa96464..988cda833 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -492,16 +492,18 @@ impl DataStore {
                     .clone()
                     .ok_or_else(|| format_err!("missing bucket for s3 backend"))?;
 
+                let user = pbs_config::backup_user()?;
+
                 let (config, _config_digest) = pbs_config::s3::config()?;
                 let config: S3ClientConf = config.lookup(S3_CFG_TYPE_ID, s3_client_id)?;
                 let rate_limiter_options = S3RateLimiterOptions {
                     id: s3_client_id.to_string(),
-                    user: pbs_config::backup_user()?,
+                    user: user.clone(),
                     base_path: S3_CLIENT_RATE_LIMITER_BASE_PATH.into(),
                 };
                 let request_counter_config = S3RequestCounterConfig {
                     id: format!("{s3_client_id}-{bucket}-{}", self.name()),
-                    user: pbs_config::backup_user()?,
+                    user: user.clone(),
                     base_path: S3_CLIENT_REQUEST_COUNTER_BASE_PATH.into(),
                 };
 
@@ -3348,6 +3350,8 @@ impl DataStore {
             return Ok((backend_type, None));
         }
 
+        let user = pbs_config::backup_user()?;
+
         let s3_client_id = backend_config
             .client
             .as_ref()
@@ -3363,12 +3367,12 @@ impl DataStore {
             .with_context(|| format!("no '{s3_client_id}' in config"))?;
         let rate_limiter_options = S3RateLimiterOptions {
             id: s3_client_id.to_string(),
-            user: pbs_config::backup_user()?,
+            user: user.clone(),
             base_path: S3_CLIENT_RATE_LIMITER_BASE_PATH.into(),
         };
         let request_counter_config = S3RequestCounterConfig {
             id: format!("{s3_client_id}-{bucket}-{}", datastore_config.name),
-            user: pbs_config::backup_user()?,
+            user: user.clone(),
             base_path: S3_CLIENT_REQUEST_COUNTER_BASE_PATH.into(),
         };
 
-- 
2.47.3





  parent reply	other threads:[~2026-06-01 12:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01 12:31 [PATCH proxmox-backup 0/4] fix 7642: s3: avoid expensive uid/gid lookups Christian Ebner
2026-06-01 12:31 ` [PATCH proxmox-backup 1/4] local datastore cache: combine same module use statements Christian Ebner
2026-06-01 12:31 ` [PATCH proxmox-backup 2/4] datastore/api: s3: wrap s3 client into s3 backend type Christian Ebner
2026-06-01 12:31 ` Christian Ebner [this message]
2026-06-01 12:31 ` [PATCH proxmox-backup 4/4] fix #7642: s3: avoid repeated user lookup for per-chunk file locking 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=20260601123124.461765-4-c.ebner@proxmox.com \
    --to=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 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