public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency
@ 2024-08-13  8:44 Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 02/11] client: " Maximiliano Sandoval
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-api-types/Cargo.toml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pbs-api-types/Cargo.toml b/pbs-api-types/Cargo.toml
index 808ff514..17c946fe 100644
--- a/pbs-api-types/Cargo.toml
+++ b/pbs-api-types/Cargo.toml
@@ -9,7 +9,6 @@ description = "general API type helpers for PBS"
 anyhow.workspace = true
 const_format.workspace = true
 hex.workspace = true
-lazy_static.workspace = true
 percent-encoding.workspace = true
 regex.workspace = true
 serde.workspace = true
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 02/11] client: remove unused lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 03/11] tools: " Maximiliano Sandoval
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-client/Cargo.toml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pbs-client/Cargo.toml b/pbs-client/Cargo.toml
index 8aff86fa..9c08a3a6 100644
--- a/pbs-client/Cargo.toml
+++ b/pbs-client/Cargo.toml
@@ -14,7 +14,6 @@ h2.workspace = true
 hex.workspace = true
 http.workspace = true
 hyper.workspace = true
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 03/11] tools: remove unused lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 02/11] client: " Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 04/11] cargo: declare msrv Maximiliano Sandoval
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-tools/Cargo.toml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pbs-tools/Cargo.toml b/pbs-tools/Cargo.toml
index 3dcae88a..dde09d3e 100644
--- a/pbs-tools/Cargo.toml
+++ b/pbs-tools/Cargo.toml
@@ -16,7 +16,6 @@ flate2.workspace = true
 foreign-types.workspace = true
 futures.workspace = true
 hex.workspace = true
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 04/11] cargo: declare msrv
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency 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 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 05/11] config: remove lazy_static dependency Maximiliano Sandoval
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

In the following commit we will make use of std::sync::LazyLock which
was introduced in rust 1.80.

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 Cargo.toml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Cargo.toml b/Cargo.toml
index eda8d7bc..221dcf53 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,7 @@ authors = [
 edition = "2021"
 license = "AGPL-3"
 repository = "https://git.proxmox.com/?p=proxmox-backup.git"
+rust-version = "1.80"
 
 [package]
 name = "proxmox-backup"
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 05/11] config: remove lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (2 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 04/11] cargo: declare msrv Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 06/11] tape: " Maximiliano Sandoval
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-config/Cargo.toml              |  2 +-
 pbs-config/src/acl.rs              | 49 +++++++++++-----------
 pbs-config/src/cached_user_info.rs | 13 +++---
 pbs-config/src/datastore.rs        |  9 ++--
 pbs-config/src/domains.rs          |  6 +--
 pbs-config/src/drive.rs            |  8 ++--
 pbs-config/src/media_pool.rs       |  8 ++--
 pbs-config/src/metrics.rs          |  6 +--
 pbs-config/src/network/helper.rs   | 36 +++++++---------
 pbs-config/src/network/lexer.rs    | 67 ++++++++++++++----------------
 pbs-config/src/network/mod.rs      | 17 ++++----
 pbs-config/src/network/parser.rs   |  7 ++--
 pbs-config/src/prune.rs            |  6 +--
 pbs-config/src/remote.rs           |  6 +--
 pbs-config/src/sync.rs             |  6 +--
 pbs-config/src/tape_job.rs         |  6 +--
 pbs-config/src/traffic_control.rs  |  8 ++--
 pbs-config/src/user.rs             | 17 ++++----
 pbs-config/src/verify.rs           |  6 +--
 19 files changed, 124 insertions(+), 159 deletions(-)

diff --git a/pbs-config/Cargo.toml b/pbs-config/Cargo.toml
index ac639a8e..12d0eb3d 100644
--- a/pbs-config/Cargo.toml
+++ b/pbs-config/Cargo.toml
@@ -4,11 +4,11 @@ version = "0.1.0"
 authors.workspace = true
 edition.workspace = true
 description = "Configuration file management for PBS"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 const_format.workspace = true
-lazy_static.workspace = true
 libc.workspace = true
 nix.workspace = true
 once_cell.workspace = true
diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs
index 8b6215ef..4ce4c13c 100644
--- a/pbs-config/src/acl.rs
+++ b/pbs-config/src/acl.rs
@@ -2,37 +2,36 @@ use std::collections::{BTreeMap, BTreeSet, HashMap};
 use std::io::Write;
 use std::path::{Path, PathBuf};
 use std::str::FromStr;
-use std::sync::{Arc, RwLock};
+use std::sync::{Arc, LazyLock, RwLock};
 
 use anyhow::{bail, Error};
 
-use lazy_static::lazy_static;
-
 use proxmox_schema::{ApiStringFormat, ApiType, Schema, StringSchema};
 
 use pbs_api_types::{Authid, Role, Userid, ROLE_NAME_NO_ACCESS};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    /// Map of pre-defined [Roles](Role) to their associated [privileges](PRIVILEGES) combination
-    /// and description.
-    pub static ref ROLE_NAMES: HashMap<&'static str, (u64, &'static str)> = {
-        let mut map = HashMap::new();
-
-        let list = match Role::API_SCHEMA {
-            Schema::String(StringSchema { format: Some(ApiStringFormat::Enum(list)), .. }) => list,
-            _ => unreachable!(),
-        };
+/// Map of pre-defined [Roles](Role) to their associated [privileges](PRIVILEGES) combination
+/// and description.
+pub static ROLE_NAMES: LazyLock<HashMap<&'static str, (u64, &'static str)>> = LazyLock::new(|| {
+    let mut map = HashMap::new();
+
+    let list = match Role::API_SCHEMA {
+        Schema::String(StringSchema {
+            format: Some(ApiStringFormat::Enum(list)),
+            ..
+        }) => list,
+        _ => unreachable!(),
+    };
 
-        for entry in list.iter() {
-            let privs: u64 = Role::from_str(entry.value).unwrap() as u64;
-            map.insert(entry.value, (privs, entry.description));
-        }
+    for entry in list.iter() {
+        let privs: u64 = Role::from_str(entry.value).unwrap() as u64;
+        map.insert(entry.value, (privs, entry.description));
+    }
 
-        map
-    };
-}
+    map
+});
 
 pub fn split_acl_path(path: &str) -> Vec<&str> {
     let items = path.split('/');
@@ -722,13 +721,13 @@ pub fn cached_config() -> Result<Arc<AclTree>, Error> {
         last_mtime_nsec: i64,
     }
 
-    lazy_static! {
-        static ref CACHED_CONFIG: RwLock<ConfigCache> = RwLock::new(ConfigCache {
+    static CACHED_CONFIG: LazyLock<RwLock<ConfigCache>> = LazyLock::new(|| {
+        RwLock::new(ConfigCache {
             data: None,
             last_mtime: 0,
-            last_mtime_nsec: 0
-        });
-    }
+            last_mtime_nsec: 0,
+        })
+    });
 
     let stat = match nix::sys::stat::stat(ACL_CFG_FILENAME) {
         Ok(stat) => Some(stat),
diff --git a/pbs-config/src/cached_user_info.rs b/pbs-config/src/cached_user_info.rs
index f8ecb6c1..e1cd2d68 100644
--- a/pbs-config/src/cached_user_info.rs
+++ b/pbs-config/src/cached_user_info.rs
@@ -1,9 +1,8 @@
 //! Cached user info for fast ACL permission checks
 
-use std::sync::{Arc, RwLock};
+use std::sync::{Arc, LazyLock, RwLock};
 
 use anyhow::{bail, Error};
-use lazy_static::lazy_static;
 
 use proxmox_router::UserInformation;
 use proxmox_section_config::SectionConfigData;
@@ -26,13 +25,13 @@ struct ConfigCache {
     last_user_cache_generation: usize,
 }
 
-lazy_static! {
-    static ref CACHED_CONFIG: RwLock<ConfigCache> = RwLock::new(ConfigCache {
+static CACHED_CONFIG: LazyLock<RwLock<ConfigCache>> = LazyLock::new(|| {
+    RwLock::new(ConfigCache {
         data: None,
         last_update: 0,
-        last_user_cache_generation: 0
-    });
-}
+        last_user_cache_generation: 0,
+    })
+});
 
 impl CachedUserInfo {
     /// Returns a cached instance (up to 5 seconds old).
diff --git a/pbs-config/src/datastore.rs b/pbs-config/src/datastore.rs
index 5844a174..dc5bb3da 100644
--- a/pbs-config/src/datastore.rs
+++ b/pbs-config/src/datastore.rs
@@ -1,6 +1,7 @@
-use anyhow::Error;
-use lazy_static::lazy_static;
 use std::collections::HashMap;
+use std::sync::LazyLock;
+
+use anyhow::Error;
 
 use proxmox_schema::{AllOfSchema, ApiType};
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -9,9 +10,7 @@ use pbs_api_types::{DataStoreConfig, DATASTORE_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard, ConfigVersionCache};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     const OBJ_SCHEMA: &AllOfSchema = DataStoreConfig::API_SCHEMA.unwrap_all_of_schema();
diff --git a/pbs-config/src/domains.rs b/pbs-config/src/domains.rs
index 5b6ce480..32bd967a 100644
--- a/pbs-config/src/domains.rs
+++ b/pbs-config/src/domains.rs
@@ -1,7 +1,7 @@
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use pbs_buildcfg::configdir;
 use proxmox_schema::{ApiType, ObjectSchema};
@@ -10,9 +10,7 @@ use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlug
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 use pbs_api_types::{AdRealmConfig, LdapRealmConfig, OpenIdRealmConfig, REALM_ID_SCHEMA};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     const AD_SCHEMA: &ObjectSchema = AdRealmConfig::API_SCHEMA.unwrap_object_schema();
diff --git a/pbs-config/src/drive.rs b/pbs-config/src/drive.rs
index 67ffc554..4e2befd2 100644
--- a/pbs-config/src/drive.rs
+++ b/pbs-config/src/drive.rs
@@ -12,9 +12,9 @@
 //! [SectionConfig]: proxmox::api::section_config::SectionConfig
 
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::{bail, Error};
-use lazy_static::lazy_static;
 
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -23,10 +23,8 @@ use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
 use pbs_api_types::{LtoTapeDrive, ScsiTapeChanger, VirtualTapeDrive, DRIVE_NAME_SCHEMA};
 
-lazy_static! {
-    /// Static [`SectionConfig`] to access parser/writer functions.
-    pub static ref CONFIG: SectionConfig = init();
-}
+/// Static [`SectionConfig`] to access parser/writer functions.
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let mut config = SectionConfig::new(&DRIVE_NAME_SCHEMA);
diff --git a/pbs-config/src/media_pool.rs b/pbs-config/src/media_pool.rs
index 3b6448c3..3bf15188 100644
--- a/pbs-config/src/media_pool.rs
+++ b/pbs-config/src/media_pool.rs
@@ -7,9 +7,9 @@
 //! [SectionConfig]: proxmox_section_config::SectionConfig
 
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -18,10 +18,8 @@ use pbs_api_types::{MediaPoolConfig, MEDIA_POOL_NAME_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    /// Static [`SectionConfig`] to access parser/writer functions.
-    pub static ref CONFIG: SectionConfig = init();
-}
+/// Static [`SectionConfig`] to access parser/writer functions.
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let mut config = SectionConfig::new(&MEDIA_POOL_NAME_SCHEMA);
diff --git a/pbs-config/src/metrics.rs b/pbs-config/src/metrics.rs
index 78e683e3..1b93f70c 100644
--- a/pbs-config/src/metrics.rs
+++ b/pbs-config/src/metrics.rs
@@ -1,7 +1,7 @@
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -10,9 +10,7 @@ use pbs_api_types::{InfluxDbHttp, InfluxDbUdp, METRIC_SERVER_ID_SCHEMA};
 
 use crate::{open_backup_lockfile, BackupLockGuard};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let mut config = SectionConfig::new(&METRIC_SERVER_ID_SCHEMA);
diff --git a/pbs-config/src/network/helper.rs b/pbs-config/src/network/helper.rs
index 9e195d71..87a0e24f 100644
--- a/pbs-config/src/network/helper.rs
+++ b/pbs-config/src/network/helper.rs
@@ -2,10 +2,10 @@ use std::collections::HashMap;
 use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd};
 use std::path::Path;
 use std::process::Command;
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
 use const_format::concatcp;
-use lazy_static::lazy_static;
 use nix::ioctl_read_bad;
 use nix::sys::socket::{socket, AddressFamily, SockFlag, SockType};
 use regex::Regex;
@@ -48,16 +48,14 @@ pub static IPV4_REVERSE_MASK: &[&str] = &[
     "255.255.255.255",
 ];
 
-lazy_static! {
-    pub static ref IPV4_MASK_HASH_LOCALNET: HashMap<&'static str, u8> = {
-        let mut map = HashMap::new();
-        #[allow(clippy::needless_range_loop)]
-        for i in 0..IPV4_REVERSE_MASK.len() {
-            map.insert(IPV4_REVERSE_MASK[i], i as u8);
-        }
-        map
-    };
-}
+pub static IPV4_MASK_HASH_LOCALNET: LazyLock<HashMap<&'static str, u8>> = LazyLock::new(|| {
+    let mut map = HashMap::new();
+    #[allow(clippy::needless_range_loop)]
+    for i in 0..IPV4_REVERSE_MASK.len() {
+        map.insert(IPV4_REVERSE_MASK[i], i as u8);
+    }
+    map
+});
 
 pub fn parse_cidr(cidr: &str) -> Result<(String, u8, bool), Error> {
     let (address, mask, is_v6) = parse_address_or_cidr(cidr)?;
@@ -92,12 +90,10 @@ pub fn check_netmask(mask: u8, is_v6: bool) -> Result<(), Error> {
 pub fn parse_address_or_cidr(cidr: &str) -> Result<(String, Option<u8>, bool), Error> {
     // NOTE: This is NOT the same regex as in proxmox-schema as this one has capture groups for
     // the addresses vs cidr portions!
-    lazy_static! {
-        pub static ref CIDR_V4_REGEX: Regex =
-            Regex::new(concatcp!(r"^(", IPV4RE_STR, r")(?:/(\d{1,2}))?$")).unwrap();
-        pub static ref CIDR_V6_REGEX: Regex =
-            Regex::new(concatcp!(r"^(", IPV6RE_STR, r")(?:/(\d{1,3}))?$")).unwrap();
-    }
+    pub static CIDR_V4_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(concatcp!(r"^(", IPV4RE_STR, r")(?:/(\d{1,2}))?$")).unwrap());
+    pub static CIDR_V6_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(concatcp!(r"^(", IPV6RE_STR, r")(?:/(\d{1,3}))?$")).unwrap());
 
     if let Some(caps) = CIDR_V4_REGEX.captures(cidr) {
         let address = &caps[1];
@@ -133,9 +129,9 @@ pub fn get_network_interfaces() -> Result<HashMap<String, bool>, Error> {
 
     ioctl_read_bad!(get_interface_flags, libc::SIOCGIFFLAGS, ifreq);
 
-    lazy_static! {
-        static ref IFACE_LINE_REGEX: Regex = Regex::new(r"^\s*([^:\s]+):").unwrap();
-    }
+    static IFACE_LINE_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(r"^\s*([^:\s]+):").unwrap());
+
     let raw = std::fs::read_to_string(PROC_NET_DEV)
         .map_err(|err| format_err!("unable to read {} - {}", PROC_NET_DEV, err))?;
 
diff --git a/pbs-config/src/network/lexer.rs b/pbs-config/src/network/lexer.rs
index d0b7d8cd..6a20f009 100644
--- a/pbs-config/src/network/lexer.rs
+++ b/pbs-config/src/network/lexer.rs
@@ -1,8 +1,7 @@
 use std::collections::{HashMap, VecDeque};
 use std::io::BufRead;
 use std::iter::Iterator;
-
-use lazy_static::lazy_static;
+use std::sync::LazyLock;
 
 #[derive(Debug, Copy, Clone, Eq, PartialEq)]
 pub enum Token {
@@ -33,39 +32,37 @@ pub enum Token {
     EOF,
 }
 
-lazy_static! {
-    static ref KEYWORDS: HashMap<&'static str, Token> = {
-        let mut map = HashMap::new();
-        map.insert("address", Token::Address);
-        map.insert("auto", Token::Auto);
-        map.insert("dhcp", Token::DHCP);
-        map.insert("gateway", Token::Gateway);
-        map.insert("inet", Token::Inet);
-        map.insert("inet6", Token::Inet6);
-        map.insert("iface", Token::Iface);
-        map.insert("loopback", Token::Loopback);
-        map.insert("manual", Token::Manual);
-        map.insert("netmask", Token::Netmask);
-        map.insert("static", Token::Static);
-        map.insert("mtu", Token::MTU);
-        map.insert("bridge-ports", Token::BridgePorts);
-        map.insert("bridge_ports", Token::BridgePorts);
-        map.insert("bridge-vlan-aware", Token::BridgeVlanAware);
-        map.insert("bridge_vlan_aware", Token::BridgeVlanAware);
-        map.insert("vlan-id", Token::VlanId);
-        map.insert("vlan_id", Token::VlanId);
-        map.insert("vlan-raw-device", Token::VlanRawDevice);
-        map.insert("vlan_raw_device", Token::VlanRawDevice);
-        map.insert("bond-slaves", Token::BondSlaves);
-        map.insert("bond_slaves", Token::BondSlaves);
-        map.insert("bond-mode", Token::BondMode);
-        map.insert("bond-primary", Token::BondPrimary);
-        map.insert("bond_primary", Token::BondPrimary);
-        map.insert("bond_xmit_hash_policy", Token::BondXmitHashPolicy);
-        map.insert("bond-xmit-hash-policy", Token::BondXmitHashPolicy);
-        map
-    };
-}
+static KEYWORDS: LazyLock<HashMap<&'static str, Token>> = LazyLock::new(|| {
+    let mut map = HashMap::new();
+    map.insert("address", Token::Address);
+    map.insert("auto", Token::Auto);
+    map.insert("dhcp", Token::DHCP);
+    map.insert("gateway", Token::Gateway);
+    map.insert("inet", Token::Inet);
+    map.insert("inet6", Token::Inet6);
+    map.insert("iface", Token::Iface);
+    map.insert("loopback", Token::Loopback);
+    map.insert("manual", Token::Manual);
+    map.insert("netmask", Token::Netmask);
+    map.insert("static", Token::Static);
+    map.insert("mtu", Token::MTU);
+    map.insert("bridge-ports", Token::BridgePorts);
+    map.insert("bridge_ports", Token::BridgePorts);
+    map.insert("bridge-vlan-aware", Token::BridgeVlanAware);
+    map.insert("bridge_vlan_aware", Token::BridgeVlanAware);
+    map.insert("vlan-id", Token::VlanId);
+    map.insert("vlan_id", Token::VlanId);
+    map.insert("vlan-raw-device", Token::VlanRawDevice);
+    map.insert("vlan_raw_device", Token::VlanRawDevice);
+    map.insert("bond-slaves", Token::BondSlaves);
+    map.insert("bond_slaves", Token::BondSlaves);
+    map.insert("bond-mode", Token::BondMode);
+    map.insert("bond-primary", Token::BondPrimary);
+    map.insert("bond_primary", Token::BondPrimary);
+    map.insert("bond_xmit_hash_policy", Token::BondXmitHashPolicy);
+    map.insert("bond-xmit-hash-policy", Token::BondXmitHashPolicy);
+    map
+});
 
 pub struct Lexer<R> {
     input: R,
diff --git a/pbs-config/src/network/mod.rs b/pbs-config/src/network/mod.rs
index c5b7775c..21ad9943 100644
--- a/pbs-config/src/network/mod.rs
+++ b/pbs-config/src/network/mod.rs
@@ -1,8 +1,8 @@
 use std::collections::{BTreeMap, HashMap, HashSet};
 use std::io::Write;
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
 use regex::Regex;
 use serde::de::{value, Deserialize, IntoDeserializer};
 
@@ -23,11 +23,11 @@ use pbs_api_types::{
 
 use crate::{open_backup_lockfile, BackupLockGuard};
 
-lazy_static! {
-    static ref PHYSICAL_NIC_REGEX: Regex = Regex::new(r"^(?:eth\d+|en[^:.]+|ib\d+)$").unwrap();
-    static ref VLAN_INTERFACE_REGEX: Regex =
-        Regex::new(r"^(?P<vlan_raw_device>\S+)\.(?P<vlan_id>\d+)|vlan(?P<vlan_id2>\d+)$").unwrap();
-}
+static PHYSICAL_NIC_REGEX: LazyLock<Regex> =
+    LazyLock::new(|| Regex::new(r"^(?:eth\d+|en[^:.]+|ib\d+)$").unwrap());
+static VLAN_INTERFACE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
+    Regex::new(r"^(?P<vlan_raw_device>\S+)\.(?P<vlan_id>\d+)|vlan(?P<vlan_id2>\d+)$").unwrap()
+});
 
 pub fn is_physical_nic(iface: &str) -> bool {
     PHYSICAL_NIC_REGEX.is_match(iface)
@@ -366,9 +366,8 @@ impl NetworkConfig {
 
     /// Check if bridge ports exists
     fn check_bridge_ports(&self) -> Result<(), Error> {
-        lazy_static! {
-            static ref VLAN_INTERFACE_REGEX: Regex = Regex::new(r"^(\S+)\.(\d+)$").unwrap();
-        }
+        static VLAN_INTERFACE_REGEX: LazyLock<Regex> =
+            LazyLock::new(|| Regex::new(r"^(\S+)\.(\d+)$").unwrap());
 
         for (iface, interface) in self.interfaces.iter() {
             if let Some(ports) = &interface.bridge_ports {
diff --git a/pbs-config/src/network/parser.rs b/pbs-config/src/network/parser.rs
index 7498dd35..a5d05c6e 100644
--- a/pbs-config/src/network/parser.rs
+++ b/pbs-config/src/network/parser.rs
@@ -3,9 +3,9 @@ use crate::network::VLAN_INTERFACE_REGEX;
 use std::collections::{HashMap, HashSet};
 use std::io::BufRead;
 use std::iter::{Iterator, Peekable};
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
 use regex::Regex;
 
 use super::helper::*;
@@ -536,9 +536,8 @@ impl<R: BufRead> NetworkParser<R> {
             }
         }
 
-        lazy_static! {
-            static ref INTERFACE_ALIAS_REGEX: Regex = Regex::new(r"^\S+:\d+$").unwrap();
-        }
+        static INTERFACE_ALIAS_REGEX: LazyLock<Regex> =
+            LazyLock::new(|| Regex::new(r"^\S+:\d+$").unwrap());
 
         if let Some(existing_interfaces) = existing_interfaces {
             for (iface, active) in existing_interfaces.iter() {
diff --git a/pbs-config/src/prune.rs b/pbs-config/src/prune.rs
index 21e52ffc..14a95404 100644
--- a/pbs-config/src/prune.rs
+++ b/pbs-config/src/prune.rs
@@ -1,7 +1,7 @@
 use std::collections::HashMap;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
+use std::sync::LazyLock;
 
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -10,9 +10,7 @@ use pbs_api_types::{PruneJobConfig, JOB_ID_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     const OBJ_SCHEMA: &AllOfSchema = PruneJobConfig::API_SCHEMA.unwrap_all_of_schema();
diff --git a/pbs-config/src/remote.rs b/pbs-config/src/remote.rs
index 9cbd1321..26b21751 100644
--- a/pbs-config/src/remote.rs
+++ b/pbs-config/src/remote.rs
@@ -1,7 +1,7 @@
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -10,9 +10,7 @@ use pbs_api_types::{Remote, REMOTE_ID_SCHEMA};
 
 use crate::{open_backup_lockfile, BackupLockGuard};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let obj_schema = match Remote::API_SCHEMA {
diff --git a/pbs-config/src/sync.rs b/pbs-config/src/sync.rs
index 6d27c123..45453abb 100644
--- a/pbs-config/src/sync.rs
+++ b/pbs-config/src/sync.rs
@@ -1,7 +1,7 @@
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use proxmox_schema::{ApiType, Schema};
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -10,9 +10,7 @@ use pbs_api_types::{SyncJobConfig, JOB_ID_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let obj_schema = match SyncJobConfig::API_SCHEMA {
diff --git a/pbs-config/src/tape_job.rs b/pbs-config/src/tape_job.rs
index 75ace6c7..66e4a797 100644
--- a/pbs-config/src/tape_job.rs
+++ b/pbs-config/src/tape_job.rs
@@ -1,6 +1,6 @@
 use anyhow::Error;
-use lazy_static::lazy_static;
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use proxmox_schema::{ApiType, Schema};
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -9,9 +9,7 @@ use pbs_api_types::{TapeBackupJobConfig, JOB_ID_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let obj_schema = match TapeBackupJobConfig::API_SCHEMA {
diff --git a/pbs-config/src/traffic_control.rs b/pbs-config/src/traffic_control.rs
index 0826be83..4ae1000d 100644
--- a/pbs-config/src/traffic_control.rs
+++ b/pbs-config/src/traffic_control.rs
@@ -1,8 +1,8 @@
 //! Traffic Control Settings (Network rate limits)
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use proxmox_schema::{ApiType, Schema};
 
@@ -13,10 +13,8 @@ use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlug
 use crate::ConfigVersionCache;
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    /// Static [`SectionConfig`] to access parser/writer functions.
-    pub static ref CONFIG: SectionConfig = init();
-}
+/// Static [`SectionConfig`] to access parser/writer functions.
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let mut config = SectionConfig::new(&TRAFFIC_CONTROL_ID_SCHEMA);
diff --git a/pbs-config/src/user.rs b/pbs-config/src/user.rs
index f5ea03db..08d141e6 100644
--- a/pbs-config/src/user.rs
+++ b/pbs-config/src/user.rs
@@ -1,8 +1,7 @@
 use std::collections::HashMap;
-use std::sync::{Arc, RwLock};
+use std::sync::{Arc, LazyLock, RwLock};
 
 use anyhow::{bail, Error};
-use lazy_static::lazy_static;
 
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -13,9 +12,7 @@ use crate::ConfigVersionCache;
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let mut config = SectionConfig::new(&Authid::API_SCHEMA);
@@ -80,13 +77,13 @@ pub fn cached_config() -> Result<Arc<SectionConfigData>, Error> {
         last_mtime_nsec: i64,
     }
 
-    lazy_static! {
-        static ref CACHED_CONFIG: RwLock<ConfigCache> = RwLock::new(ConfigCache {
+    static CACHED_CONFIG: LazyLock<RwLock<ConfigCache>> = LazyLock::new(|| {
+        RwLock::new(ConfigCache {
             data: None,
             last_mtime: 0,
-            last_mtime_nsec: 0
-        });
-    }
+            last_mtime_nsec: 0,
+        })
+    });
 
     let stat = match nix::sys::stat::stat(USER_CFG_FILENAME) {
         Ok(stat) => Some(stat),
diff --git a/pbs-config/src/verify.rs b/pbs-config/src/verify.rs
index 2631eeef..93776f8c 100644
--- a/pbs-config/src/verify.rs
+++ b/pbs-config/src/verify.rs
@@ -1,7 +1,7 @@
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use proxmox_schema::*;
 use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlugin};
@@ -10,9 +10,7 @@ use pbs_api_types::{VerificationJobConfig, JOB_ID_SCHEMA};
 
 use crate::{open_backup_lockfile, replace_backup_config, BackupLockGuard};
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 fn init() -> SectionConfig {
     let obj_schema = match VerificationJobConfig::API_SCHEMA {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 06/11] tape: remove lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (3 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 05/11] config: remove lazy_static dependency Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 07/11] fuse-loop: " Maximiliano Sandoval
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-tape/Cargo.toml               |  2 +-
 pbs-tape/src/linux_list_drives.rs |  7 +++----
 pbs-tape/src/sg_tape/mam.rs       | 18 ++++++++----------
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/pbs-tape/Cargo.toml b/pbs-tape/Cargo.toml
index f4110706..142bbacd 100644
--- a/pbs-tape/Cargo.toml
+++ b/pbs-tape/Cargo.toml
@@ -4,13 +4,13 @@ version = "0.1.0"
 authors.workspace = true
 edition.workspace = true
 description = "LTO tape support"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 bitflags.workspace = true
 endian_trait.workspace = true
 hex.workspace = true
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
diff --git a/pbs-tape/src/linux_list_drives.rs b/pbs-tape/src/linux_list_drives.rs
index 39d2aac7..96227672 100644
--- a/pbs-tape/src/linux_list_drives.rs
+++ b/pbs-tape/src/linux_list_drives.rs
@@ -3,6 +3,7 @@ use std::fs::{File, OpenOptions};
 use std::os::unix::fs::OpenOptionsExt;
 use std::os::unix::io::AsRawFd;
 use std::path::{Path, PathBuf};
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
 use nix::fcntl::{fcntl, FcntlArg, OFlag};
@@ -12,10 +13,8 @@ use proxmox_sys::fs::scan_subdir;
 
 use pbs_api_types::{DeviceKind, OptionalDeviceIdentification, TapeDeviceInfo};
 
-lazy_static::lazy_static! {
-    static ref SCSI_GENERIC_NAME_REGEX: regex::Regex =
-        regex::Regex::new(r"^sg\d+$").unwrap();
-}
+static SCSI_GENERIC_NAME_REGEX: LazyLock<regex::Regex> =
+    LazyLock::new(|| regex::Regex::new(r"^sg\d+$").unwrap());
 
 /// List linux tape changer devices
 pub fn linux_tape_changer_list() -> Vec<TapeDeviceInfo> {
diff --git a/pbs-tape/src/sg_tape/mam.rs b/pbs-tape/src/sg_tape/mam.rs
index 4e995d0b..4a94fa92 100644
--- a/pbs-tape/src/sg_tape/mam.rs
+++ b/pbs-tape/src/sg_tape/mam.rs
@@ -1,5 +1,6 @@
 use std::collections::HashMap;
 use std::os::unix::io::AsRawFd;
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
 use endian_trait::Endian;
@@ -114,18 +115,15 @@ static MAM_ATTRIBUTES: &[MamType] = &[
     MamType::bin(0x10_01, 24, "Alternate Unique Cartridge Identify (Alt-UCI)"),
 ];
 
-lazy_static::lazy_static! {
+static MAM_ATTRIBUTE_NAMES: LazyLock<HashMap<u16, &'static MamType>> = LazyLock::new(|| {
+    let mut map = HashMap::new();
 
-    static ref MAM_ATTRIBUTE_NAMES: HashMap<u16, &'static MamType> = {
-        let mut map = HashMap::new();
-
-        for entry in MAM_ATTRIBUTES {
-            map.insert(entry.id, entry);
-        }
+    for entry in MAM_ATTRIBUTES {
+        map.insert(entry.id, entry);
+    }
 
-        map
-    };
-}
+    map
+});
 
 fn read_tape_mam<F: AsRawFd>(file: &mut F) -> Result<Vec<u8>, Error> {
     let alloc_len: u32 = 32 * 1024;
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 07/11] fuse-loop: remove lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (4 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 06/11] tape: " Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 08/11] datastore: " Maximiliano Sandoval
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-fuse-loop/Cargo.toml       | 2 +-
 pbs-fuse-loop/src/fuse_loop.rs | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/pbs-fuse-loop/Cargo.toml b/pbs-fuse-loop/Cargo.toml
index 40a5e744..18898023 100644
--- a/pbs-fuse-loop/Cargo.toml
+++ b/pbs-fuse-loop/Cargo.toml
@@ -4,11 +4,11 @@ version = "0.1.0"
 authors.workspace = true
 edition.workspace = true
 description = "fuse and loop device helpers"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 futures.workspace = true
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
diff --git a/pbs-fuse-loop/src/fuse_loop.rs b/pbs-fuse-loop/src/fuse_loop.rs
index 3d0ef123..d55be3b0 100644
--- a/pbs-fuse-loop/src/fuse_loop.rs
+++ b/pbs-fuse-loop/src/fuse_loop.rs
@@ -7,6 +7,7 @@ use std::fs::{read_to_string, remove_file, File, OpenOptions};
 use std::io::prelude::*;
 use std::io::SeekFrom;
 use std::path::{Path, PathBuf};
+use std::sync::LazyLock;
 
 use nix::sys::signal::{self, Signal};
 use nix::unistd::Pid;
@@ -22,9 +23,7 @@ use proxmox_time::epoch_i64;
 
 const RUN_DIR: &str = "/run/pbs-loopdev";
 
-lazy_static::lazy_static! {
-    static ref LOOPDEV_REGEX: Regex = Regex::new(r"^loop\d+$").unwrap();
-}
+static LOOPDEV_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"^loop\d+$").unwrap());
 
 /// Represents an ongoing FUSE-session that has been mapped onto a loop device.
 /// Create with map_loop, then call 'main' and poll until startup_chan reports
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 08/11] datastore: remove lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (5 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 07/11] fuse-loop: " Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 09/11] restore-daemon: " Maximiliano Sandoval
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-datastore/Cargo.toml       | 2 +-
 pbs-datastore/src/datastore.rs | 9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/pbs-datastore/Cargo.toml b/pbs-datastore/Cargo.toml
index 494c231b..4ebc5fdc 100644
--- a/pbs-datastore/Cargo.toml
+++ b/pbs-datastore/Cargo.toml
@@ -4,6 +4,7 @@ version = "0.1.0"
 authors.workspace = true
 edition.workspace = true
 description = "low level pbs data storage access"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
@@ -12,7 +13,6 @@ crc32fast.workspace = true
 endian_trait.workspace = true
 futures.workspace = true
 hex = { workspace = true, features = [ "serde" ] }
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index d6218fb4..d0f3c53a 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -2,10 +2,9 @@ use std::collections::{HashMap, HashSet};
 use std::io::{self, Write};
 use std::os::unix::io::AsRawFd;
 use std::path::{Path, PathBuf};
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, LazyLock, Mutex};
 
 use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
 use nix::unistd::{unlinkat, UnlinkatFlags};
 use tracing::{info, warn};
 
@@ -33,10 +32,8 @@ use crate::manifest::ArchiveType;
 use crate::task_tracking::{self, update_active_operations};
 use crate::DataBlob;
 
-lazy_static! {
-    static ref DATASTORE_MAP: Mutex<HashMap<String, Arc<DataStoreImpl>>> =
-        Mutex::new(HashMap::new());
-}
+static DATASTORE_MAP: LazyLock<Mutex<HashMap<String, Arc<DataStoreImpl>>>> =
+    LazyLock::new(|| Mutex::new(HashMap::new()));
 
 /// checks if auth_id is owner, or, if owner is a token, if
 /// auth_id is the user of the token
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 09/11] restore-daemon: remove lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (6 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 08/11] datastore: " Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 10/11] backup: " Maximiliano Sandoval
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 10/11] backup: remove lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (7 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 09/11] restore-daemon: " Maximiliano Sandoval
@ 2024-08-13  8:44 ` 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
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 Cargo.toml                       |  2 --
 src/api2/config/acme.rs          |  9 ++----
 src/api2/node/disks/directory.rs |  7 ++--
 src/api2/node/dns.rs             | 16 ++++------
 src/config/acme/plugin.rs        |  7 ++--
 src/tape/file_formats/mod.rs     | 55 ++++++++++++++++++++++++--------
 src/tools/disks/lvm.rs           | 14 ++++----
 src/tools/disks/mod.rs           |  8 ++---
 src/tools/disks/smart.rs         |  8 ++---
 src/tools/disks/zfs.rs           | 23 ++++++-------
 src/tools/systemd/config.rs      | 11 +++----
 src/traffic_control_cache.rs     | 10 +++---
 12 files changed, 87 insertions(+), 83 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 221dcf53..ef430d43 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -128,7 +128,6 @@ handlebars = "3.0"
 hex = "0.4.3"
 http = "0.2"
 hyper = { version = "0.14", features = [ "full" ] }
-lazy_static = "1.4"
 libc = "0.2"
 log = "0.4.17"
 nix = "0.26.1"
@@ -180,7 +179,6 @@ handlebars.workspace = true
 hex.workspace = true
 http.workspace = true
 hyper.workspace = true
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
diff --git a/src/api2/config/acme.rs b/src/api2/config/acme.rs
index e2ccaded..422b9720 100644
--- a/src/api2/config/acme.rs
+++ b/src/api2/config/acme.rs
@@ -1,12 +1,11 @@
 use std::fs;
 use std::ops::ControlFlow;
 use std::path::Path;
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, LazyLock, Mutex};
 use std::time::SystemTime;
 
 use anyhow::{bail, format_err, Error};
 use hex::FromHex;
-use lazy_static::lazy_static;
 use serde::{Deserialize, Serialize};
 use serde_json::{json, Value};
 use tracing::{info, warn};
@@ -430,10 +429,8 @@ impl Serialize for ChallengeSchemaWrapper {
 }
 
 fn get_cached_challenge_schemas() -> Result<ChallengeSchemaWrapper, Error> {
-    lazy_static! {
-        static ref CACHE: Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>> =
-            Mutex::new(None);
-    }
+    static CACHE: LazyLock<Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>>> =
+        LazyLock::new(|| Mutex::new(None));
 
     // the actual loading code
     let mut last = CACHE.lock().unwrap();
diff --git a/src/api2/node/disks/directory.rs b/src/api2/node/disks/directory.rs
index 2aa9571d..e971f40d 100644
--- a/src/api2/node/disks/directory.rs
+++ b/src/api2/node/disks/directory.rs
@@ -1,3 +1,5 @@
+use std::sync::LazyLock;
+
 use ::serde::{Deserialize, Serialize};
 use anyhow::{bail, Error};
 use serde_json::json;
@@ -71,9 +73,8 @@ pub struct DatastoreMountInfo {
 )]
 /// List systemd datastore mount units.
 pub fn list_datastore_mounts() -> Result<Vec<DatastoreMountInfo>, Error> {
-    lazy_static::lazy_static! {
-        static ref MOUNT_NAME_REGEX: regex::Regex = regex::Regex::new(r"^mnt-datastore-(.+)\.mount$").unwrap();
-    }
+    static MOUNT_NAME_REGEX: LazyLock<regex::Regex> =
+        LazyLock::new(|| regex::Regex::new(r"^mnt-datastore-(.+)\.mount$").unwrap());
 
     let mut list = Vec::new();
 
diff --git a/src/api2/node/dns.rs b/src/api2/node/dns.rs
index 87a11738..bd1f528f 100644
--- a/src/api2/node/dns.rs
+++ b/src/api2/node/dns.rs
@@ -1,9 +1,8 @@
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, LazyLock, Mutex};
 
 use ::serde::{Deserialize, Serialize};
 use anyhow::Error;
 use const_format::concatcp;
-use lazy_static::lazy_static;
 use openssl::sha;
 use regex::Regex;
 use serde_json::{json, Value};
@@ -46,11 +45,10 @@ pub fn read_etc_resolv_conf() -> Result<Value, Error> {
 
     let data = String::from_utf8(raw)?;
 
-    lazy_static! {
-        static ref DOMAIN_REGEX: Regex = Regex::new(r"^\s*(?:search|domain)\s+(\S+)\s*").unwrap();
-        static ref SERVER_REGEX: Regex =
-            Regex::new(concatcp!(r"^\s*nameserver\s+(", IPRE_STR, r")\s*")).unwrap();
-    }
+    static DOMAIN_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(r"^\s*(?:search|domain)\s+(\S+)\s*").unwrap());
+    static SERVER_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(concatcp!(r"^\s*nameserver\s+(", IPRE_STR, r")\s*")).unwrap());
 
     let mut options = String::new();
 
@@ -131,9 +129,7 @@ pub fn update_dns(
     delete: Option<Vec<DeletableProperty>>,
     digest: Option<String>,
 ) -> Result<Value, Error> {
-    lazy_static! {
-        static ref MUTEX: Arc<Mutex<()>> = Arc::new(Mutex::new(()));
-    }
+    static MUTEX: LazyLock<Arc<Mutex<()>>> = LazyLock::new(|| Arc::new(Mutex::new(())));
 
     let _guard = MUTEX.lock();
 
diff --git a/src/config/acme/plugin.rs b/src/config/acme/plugin.rs
index ff66dec3..74ef0459 100644
--- a/src/config/acme/plugin.rs
+++ b/src/config/acme/plugin.rs
@@ -1,5 +1,6 @@
+use std::sync::LazyLock;
+
 use anyhow::Error;
-use lazy_static::lazy_static;
 use serde::{Deserialize, Serialize};
 use serde_json::Value;
 
@@ -15,9 +16,7 @@ pub const PLUGIN_ID_SCHEMA: Schema = StringSchema::new("ACME Challenge Plugin ID
     .max_length(32)
     .schema();
 
-lazy_static! {
-    pub static ref CONFIG: SectionConfig = init();
-}
+pub static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 #[api(
     properties: {
diff --git a/src/tape/file_formats/mod.rs b/src/tape/file_formats/mod.rs
index b1d8c455..7b99cb99 100644
--- a/src/tape/file_formats/mod.rs
+++ b/src/tape/file_formats/mod.rs
@@ -2,6 +2,7 @@
 //! tapes
 
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use endian_trait::Endian;
 use serde::{Deserialize, Serialize};
@@ -56,22 +57,48 @@ pub const PROXMOX_BACKUP_CATALOG_ARCHIVE_MAGIC_1_0: [u8; 8] =
 // openssl::sha::sha256(b"Proxmox Backup Catalog Archive v1.1")[0..8];
 pub const PROXMOX_BACKUP_CATALOG_ARCHIVE_MAGIC_1_1: [u8; 8] = [179, 236, 113, 240, 173, 236, 2, 96];
 
-lazy_static::lazy_static! {
-    // Map content magic numbers to human readable names.
-    static ref PROXMOX_TAPE_CONTENT_NAME: HashMap<&'static [u8;8], &'static str> = {
+// Map content magic numbers to human readable names.
+static PROXMOX_TAPE_CONTENT_NAME: LazyLock<HashMap<&'static [u8; 8], &'static str>> =
+    LazyLock::new(|| {
         let mut map = HashMap::new();
-        map.insert(&PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0, "Proxmox Backup Tape Label v1.0");
-        map.insert(&PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0, "Proxmox Backup MediaSet Label v1.0");
-        map.insert(&PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_0, "Proxmox Backup Chunk Archive v1.0");
-        map.insert(&PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_1, "Proxmox Backup Chunk Archive v1.1");
-        map.insert(&PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_0, "Proxmox Backup Snapshot Archive v1.0");
-        map.insert(&PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_1, "Proxmox Backup Snapshot Archive v1.1");
-        map.insert(&PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_2, "Proxmox Backup Snapshot Archive v1.2");
-        map.insert(&PROXMOX_BACKUP_CATALOG_ARCHIVE_MAGIC_1_0, "Proxmox Backup Catalog Archive v1.0");
-        map.insert(&PROXMOX_BACKUP_CATALOG_ARCHIVE_MAGIC_1_1, "Proxmox Backup Catalog Archive v1.1");
+        map.insert(
+            &PROXMOX_BACKUP_MEDIA_LABEL_MAGIC_1_0,
+            "Proxmox Backup Tape Label v1.0",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_MEDIA_SET_LABEL_MAGIC_1_0,
+            "Proxmox Backup MediaSet Label v1.0",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_0,
+            "Proxmox Backup Chunk Archive v1.0",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_CHUNK_ARCHIVE_MAGIC_1_1,
+            "Proxmox Backup Chunk Archive v1.1",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_0,
+            "Proxmox Backup Snapshot Archive v1.0",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_1,
+            "Proxmox Backup Snapshot Archive v1.1",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_SNAPSHOT_ARCHIVE_MAGIC_1_2,
+            "Proxmox Backup Snapshot Archive v1.2",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_CATALOG_ARCHIVE_MAGIC_1_0,
+            "Proxmox Backup Catalog Archive v1.0",
+        );
+        map.insert(
+            &PROXMOX_BACKUP_CATALOG_ARCHIVE_MAGIC_1_1,
+            "Proxmox Backup Catalog Archive v1.1",
+        );
         map
-    };
-}
+    });
 
 /// Map content magic numbers to human readable names.
 pub fn proxmox_tape_magic_to_text(magic: &[u8; 8]) -> Option<String> {
diff --git a/src/tools/disks/lvm.rs b/src/tools/disks/lvm.rs
index b5e79e22..1456a21c 100644
--- a/src/tools/disks/lvm.rs
+++ b/src/tools/disks/lvm.rs
@@ -1,19 +1,17 @@
 use std::collections::HashSet;
 use std::os::unix::fs::MetadataExt;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 use serde_json::Value;
 
 use super::LsblkInfo;
 
-lazy_static! {
-    static ref LVM_UUIDS: HashSet<&'static str> = {
-        let mut set = HashSet::new();
-        set.insert("e6d6d379-f507-44c2-a23c-238f2a3df928");
-        set
-    };
-}
+static LVM_UUIDS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
+    let mut set = HashSet::new();
+    set.insert("e6d6d379-f507-44c2-a23c-238f2a3df928");
+    set
+});
 
 /// Get set of devices used by LVM (pvs).
 ///
diff --git a/src/tools/disks/mod.rs b/src/tools/disks/mod.rs
index 9b5aaf6b..c729c26a 100644
--- a/src/tools/disks/mod.rs
+++ b/src/tools/disks/mod.rs
@@ -6,7 +6,7 @@ use std::io;
 use std::os::unix::ffi::{OsStrExt, OsStringExt};
 use std::os::unix::fs::MetadataExt;
 use std::path::{Path, PathBuf};
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
 
 use anyhow::{bail, format_err, Error};
 use libc::dev_t;
@@ -32,10 +32,8 @@ pub use lvm::*;
 mod smart;
 pub use smart::*;
 
-lazy_static::lazy_static! {
-    static ref ISCSI_PATH_REGEX: regex::Regex =
-        regex::Regex::new(r"host[^/]*/session[^/]*").unwrap();
-}
+static ISCSI_PATH_REGEX: LazyLock<regex::Regex> =
+    LazyLock::new(|| regex::Regex::new(r"host[^/]*/session[^/]*").unwrap());
 
 /// Disk management context.
 ///
diff --git a/src/tools/disks/smart.rs b/src/tools/disks/smart.rs
index e666eb1a..3ad782b7 100644
--- a/src/tools/disks/smart.rs
+++ b/src/tools/disks/smart.rs
@@ -1,8 +1,8 @@
 use std::collections::{HashMap, HashSet};
+use std::sync::LazyLock;
 
 use ::serde::{Deserialize, Serialize};
 use anyhow::{bail, Error};
-use lazy_static::lazy_static;
 
 use proxmox_schema::api;
 
@@ -224,7 +224,5 @@ static WEAROUT_FIELD_ORDER: &[&str] = &[
     "Perc_Rated_Life_Used",
 ];
 
-lazy_static! {
-    static ref WEAROUT_FIELD_NAMES: HashSet<&'static str> =
-        WEAROUT_FIELD_ORDER.iter().cloned().collect();
-}
+static WEAROUT_FIELD_NAMES: LazyLock<HashSet<&'static str>> =
+    LazyLock::new(|| WEAROUT_FIELD_ORDER.iter().cloned().collect());
diff --git a/src/tools/disks/zfs.rs b/src/tools/disks/zfs.rs
index b12a948b..2abb5176 100644
--- a/src/tools/disks/zfs.rs
+++ b/src/tools/disks/zfs.rs
@@ -1,23 +1,20 @@
 use std::collections::HashSet;
 use std::os::unix::fs::MetadataExt;
 use std::path::PathBuf;
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, LazyLock, Mutex};
 
 use anyhow::{bail, Error};
-use lazy_static::lazy_static;
 
 use proxmox_schema::const_regex;
 
 use super::*;
 
-lazy_static! {
-    static ref ZFS_UUIDS: HashSet<&'static str> = {
-        let mut set = HashSet::new();
-        set.insert("6a898cc3-1dd2-11b2-99a6-080020736631"); // apple
-        set.insert("516e7cba-6ecf-11d6-8ff8-00022d09712b"); // bsd
-        set
-    };
-}
+static ZFS_UUIDS: LazyLock<HashSet<&'static str>> = LazyLock::new(|| {
+    let mut set = HashSet::new();
+    set.insert("6a898cc3-1dd2-11b2-99a6-080020736631"); // apple
+    set.insert("516e7cba-6ecf-11d6-8ff8-00022d09712b"); // bsd
+    set
+});
 
 fn get_pool_from_dataset(dataset: &str) -> &str {
     if let Some(idx) = dataset.find('/') {
@@ -100,10 +97,8 @@ const_regex! {
     OBJSET_REGEX = r"^objset-0x[a-fA-F0-9]+$";
 }
 
-lazy_static::lazy_static! {
-    pub static ref ZFS_DATASET_OBJSET_MAP: Arc<Mutex<HashMap<String, (String, String)>>> =
-        Arc::new(Mutex::new(HashMap::new()));
-}
+pub static ZFS_DATASET_OBJSET_MAP: LazyLock<Arc<Mutex<HashMap<String, (String, String)>>>> =
+    LazyLock::new(|| Arc::new(Mutex::new(HashMap::new())));
 
 // parses /proc/spl/kstat/zfs/POOL/objset-ID files
 // they have the following format:
diff --git a/src/tools/systemd/config.rs b/src/tools/systemd/config.rs
index 3e1ac1bb..9b94531b 100644
--- a/src/tools/systemd/config.rs
+++ b/src/tools/systemd/config.rs
@@ -1,5 +1,6 @@
+use std::sync::LazyLock;
+
 use anyhow::Error;
-use lazy_static::lazy_static;
 
 use super::types::*;
 
@@ -8,11 +9,9 @@ use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlug
 
 use proxmox_sys::{fs::replace_file, fs::CreateOptions};
 
-lazy_static! {
-    pub static ref SERVICE_CONFIG: SectionConfig = init_service();
-    pub static ref TIMER_CONFIG: SectionConfig = init_timer();
-    pub static ref MOUNT_CONFIG: SectionConfig = init_mount();
-}
+pub static SERVICE_CONFIG: LazyLock<SectionConfig> = LazyLock::new(init_service);
+pub static TIMER_CONFIG: LazyLock<SectionConfig> = LazyLock::new(init_timer);
+pub static MOUNT_CONFIG: LazyLock<SectionConfig> = LazyLock::new(init_mount);
 
 fn init_service() -> SectionConfig {
     let mut config = SectionConfig::with_systemd_syntax(&SYSTEMD_SECTION_NAME_SCHEMA);
diff --git a/src/traffic_control_cache.rs b/src/traffic_control_cache.rs
index 32da6f4c..830a8c04 100644
--- a/src/traffic_control_cache.rs
+++ b/src/traffic_control_cache.rs
@@ -2,7 +2,7 @@
 
 use std::collections::HashMap;
 use std::net::{IpAddr, Ipv4Addr, SocketAddr};
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, LazyLock, Mutex};
 use std::time::Instant;
 
 use anyhow::Error;
@@ -21,11 +21,9 @@ use crate::tools::SharedRateLimiter;
 
 pub type SharedRateLimit = Arc<dyn ShareableRateLimit>;
 
-lazy_static::lazy_static! {
-    /// Shared traffic control cache singleton.
-    pub static ref TRAFFIC_CONTROL_CACHE: Arc<Mutex<TrafficControlCache>> =
-        Arc::new(Mutex::new(TrafficControlCache::new()));
-}
+/// Shared traffic control cache singleton.
+pub static TRAFFIC_CONTROL_CACHE: LazyLock<Arc<Mutex<TrafficControlCache>>> =
+    LazyLock::new(|| Arc::new(Mutex::new(TrafficControlCache::new())));
 
 struct ParsedTcRule {
     config: TrafficControlRule,    // original rule config
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] [PATCH backup 11/11] d/control: remove lazy-static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (8 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 10/11] backup: " Maximiliano Sandoval
@ 2024-08-13  8:44 ` Maximiliano Sandoval
  2024-08-14 10:18 ` [pbs-devel] applied-series: [PATCH backup 01/11] api-types: remove unused lazy_static dependency Wolfgang Bumiller
  10 siblings, 0 replies; 12+ messages in thread
From: Maximiliano Sandoval @ 2024-08-13  8:44 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 debian/control | 1 -
 1 file changed, 1 deletion(-)

diff --git a/debian/control b/debian/control
index 77f41ba7..7eefbedd 100644
--- a/debian/control
+++ b/debian/control
@@ -38,7 +38,6 @@ Build-Depends: bash-completion,
                librust-http-0.2+default-dev,
                librust-hyper-0.14+default-dev,
                librust-hyper-0.14+full-dev,
-               librust-lazy-static-1+default-dev (>= 1.4-~~),
                librust-libc-0.2+default-dev,
                librust-log-0.4+default-dev (>= 0.4.17-~~),
                librust-nix-0.26+default-dev (>= 0.26.1-~~),
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [pbs-devel] applied-series: [PATCH backup 01/11] api-types: remove unused lazy_static dependency
  2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency Maximiliano Sandoval
                   ` (9 preceding siblings ...)
  2024-08-13  8:44 ` [pbs-devel] [PATCH backup 11/11] d/control: remove lazy-static dependency Maximiliano Sandoval
@ 2024-08-14 10:18 ` Wolfgang Bumiller
  10 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Bumiller @ 2024-08-14 10:18 UTC (permalink / raw)
  To: Maximiliano Sandoval; +Cc: pbs-devel

applied series, thanks


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-08-14 10:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-13  8:44 [pbs-devel] [PATCH backup 01/11] api-types: remove unused lazy_static dependency 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 ` [pbs-devel] [PATCH backup 09/11] restore-daemon: " Maximiliano Sandoval
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

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