From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup 09/11] restore-daemon: remove lazy_static dependency
Date: Tue, 13 Aug 2024 10:44:14 +0200 [thread overview]
Message-ID: <20240813084416.177460-9-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240813084416.177460-1-m.sandoval@proxmox.com>
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-restore-daemon/Cargo.toml | 2 +-
proxmox-restore-daemon/src/main.rs | 12 +++----
.../src/proxmox_restore_daemon/disk.rs | 32 +++++++++----------
3 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/proxmox-restore-daemon/Cargo.toml b/proxmox-restore-daemon/Cargo.toml
index 161b371d..beb455e5 100644
--- a/proxmox-restore-daemon/Cargo.toml
+++ b/proxmox-restore-daemon/Cargo.toml
@@ -4,6 +4,7 @@ version = "0.1.0"
authors.workspace = true
edition.workspace = true
description = "Proxmox Restore Daemon"
+rust-version.workspace = true
[dependencies]
anyhow.workspace = true
@@ -12,7 +13,6 @@ env_logger.workspace = true
futures.workspace = true
http.workspace = true
hyper.workspace = true
-lazy_static.workspace = true
libc.workspace = true
log.workspace = true
nix.workspace = true
diff --git a/proxmox-restore-daemon/src/main.rs b/proxmox-restore-daemon/src/main.rs
index f94b6c67..0131d771 100644
--- a/proxmox-restore-daemon/src/main.rs
+++ b/proxmox-restore-daemon/src/main.rs
@@ -6,10 +6,9 @@ use std::os::unix::{
net,
};
use std::path::Path;
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, LazyLock, Mutex};
use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
use log::{error, info};
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
@@ -29,12 +28,9 @@ pub const MAX_PENDING: usize = 32;
/// Will be present in base initramfs
pub const VM_DETECT_FILE: &str = "/restore-vm-marker";
-lazy_static! {
- /// The current disks state. Use for accessing data on the attached snapshots.
- pub static ref DISK_STATE: Arc<Mutex<DiskState>> = {
- Arc::new(Mutex::new(DiskState::scan().unwrap()))
- };
-}
+/// The current disks state. Use for accessing data on the attached snapshots.
+pub static DISK_STATE: LazyLock<Arc<Mutex<DiskState>>> =
+ LazyLock::new(|| Arc::new(Mutex::new(DiskState::scan().unwrap())));
fn init_disk_state() {
info!("scanning all disks...");
diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
index 20ddfc6b..f60dbbfa 100644
--- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
+++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs
@@ -4,9 +4,9 @@ use std::fs::{create_dir_all, File};
use std::io::{BufRead, BufReader};
use std::path::{Component, Path, PathBuf};
use std::process::Command;
+use std::sync::LazyLock;
use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
use log::{info, warn};
use proxmox_schema::const_regex;
@@ -21,27 +21,25 @@ const_regex! {
ZPOOL_IMPORT_DISK_REGEX = r"^\t {2,4}(vd[a-z]+(?:\d+)?)\s+ONLINE$";
}
-lazy_static! {
- static ref FS_OPT_MAP: HashMap<&'static str, &'static str> = {
- let mut m = HashMap::new();
+static FS_OPT_MAP: LazyLock<HashMap<&'static str, &'static str>> = LazyLock::new(|| {
+ let mut m = HashMap::new();
- // otherwise ext complains about mounting read-only
- m.insert("ext2", "noload");
- m.insert("ext3", "noload");
- m.insert("ext4", "noload");
+ // otherwise ext complains about mounting read-only
+ m.insert("ext2", "noload");
+ m.insert("ext3", "noload");
+ m.insert("ext4", "noload");
- m.insert("xfs", "norecovery");
+ m.insert("xfs", "norecovery");
- // ufs2 is used as default since FreeBSD 5.0 released in 2003, so let's assume that
- // whatever the user is trying to restore is not using anything older...
- m.insert("ufs", "ufstype=ufs2");
+ // ufs2 is used as default since FreeBSD 5.0 released in 2003, so let's assume that
+ // whatever the user is trying to restore is not using anything older...
+ m.insert("ufs", "ufstype=ufs2");
- m.insert("ntfs", "utf8");
- m.insert("ntfs3", "iocharset=utf8");
+ m.insert("ntfs", "utf8");
+ m.insert("ntfs3", "iocharset=utf8");
- m
- };
-}
+ m
+});
pub enum ResolveResult {
Path(PathBuf),
--
2.39.2
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2024-08-13 8:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 02/11] client: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 03/11] tools: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 04/11] cargo: declare msrv Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 05/11] config: remove lazy_static dependency Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 06/11] tape: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 07/11] fuse-loop: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 08/11] datastore: " Maximiliano Sandoval
2024-08-13 8:44 ` Maximiliano Sandoval [this message]
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 10/11] backup: " Maximiliano Sandoval
2024-08-13 8:44 ` [pbs-devel] [PATCH backup 11/11] d/control: remove lazy-static dependency Maximiliano Sandoval
2024-08-14 10:18 ` [pbs-devel] applied-series: [PATCH backup 01/11] api-types: remove unused lazy_static dependency Wolfgang Bumiller
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=20240813084416.177460-9-m.sandoval@proxmox.com \
--to=m.sandoval@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.