From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] api: chunk reader: make reading from filesystem fully async
Date: Wed, 26 Nov 2025 17:28:15 +0100 [thread overview]
Message-ID: <20251126162815.814841-1-c.ebner@proxmox.com> (raw)
Blocking the thread is problematic here and must be avoided, so
read the chunk data via tokio::fs::read() instead of std::fs::read()
and make the full loading from filesystem branch async.
Encountered while investigating a user provided backtrace looking for
possible causes of hanging backups reported in [0].
[0] https://forum.proxmox.com/threads/176444/post-819858
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
src/api2/reader/mod.rs | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs
index f7adc366f..1e74b0758 100644
--- a/src/api2/reader/mod.rs
+++ b/src/api2/reader/mod.rs
@@ -321,7 +321,7 @@ fn download_chunk(
}
let body = match &env.backend {
- DatastoreBackend::Filesystem => load_from_filesystem(env, &digest)?,
+ DatastoreBackend::Filesystem => load_from_filesystem(env, &digest).await?,
DatastoreBackend::S3(s3_client) => match env.datastore.cache() {
None => fetch_from_object_store(s3_client, &digest).await?,
Some(cache) => {
@@ -357,13 +357,14 @@ async fn fetch_from_object_store(s3_client: &S3Client, digest: &[u8; 32]) -> Res
bail!("cannot find chunk with digest {}", hex::encode(digest));
}
-fn load_from_filesystem(env: &ReaderEnvironment, digest: &[u8; 32]) -> Result<Body, Error> {
+async fn load_from_filesystem(env: &ReaderEnvironment, digest: &[u8; 32]) -> Result<Body, Error> {
let (path, _) = env.datastore.chunk_path(digest);
let path2 = path.clone();
env.debug(format!("download chunk {path:?}"));
- let data = proxmox_async::runtime::block_in_place(|| std::fs::read(path))
+ let data = tokio::fs::read(path)
+ .await
.map_err(move |err| http_err!(BAD_REQUEST, "reading file {path2:?} failed: {err}"))?;
Ok(Body::from(data))
}
--
2.47.3
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next reply other threads:[~2025-11-26 16:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 16:28 Christian Ebner [this message]
2025-11-26 18:10 ` Thomas Lamprecht
2025-11-27 8:55 ` Christian Ebner
2025-11-27 9:03 ` Thomas Lamprecht
2025-11-27 9:01 ` Fabian Grünbichler
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=20251126162815.814841-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox