diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-09 14:55:20 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-09 14:55:20 +0200 |
commit | 138e13071be37d873344cd03e316c87ff8057ea0 (patch) | |
tree | bc74cd3bab1657ca8fec7fda01aba949a9a0897e /src/db | |
parent | b44d3fc796484a50cd6854f20c9b46e5fddedc9d (diff) | |
download | garage-138e13071be37d873344cd03e316c87ff8057ea0.tar.gz garage-138e13071be37d873344cd03e316c87ff8057ea0.zip |
Fix garage_db build on 32-bit systemsfix-build
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/bin/convert.rs | 9 | ||||
-rw-r--r-- | src/db/lmdb_adapter.rs | 14 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/db/bin/convert.rs b/src/db/bin/convert.rs index 9e45e61f..bbde2048 100644 --- a/src/db/bin/convert.rs +++ b/src/db/bin/convert.rs @@ -55,14 +55,7 @@ fn open_db(path: PathBuf, engine: String) -> Result<Db> { Error(format!("Unable to create LMDB data directory: {}", e).into()) })?; - let map_size = if u32::MAX as usize == usize::MAX { - eprintln!( - "LMDB is not recommended on 32-bit systems, database size will be limited" - ); - 1usize << 30 // 1GB for 32-bit systems - } else { - 1usize << 40 // 1TB for 64-bit systems - }; + let map_size = lmdb_adapter::recommended_map_size(); let db = lmdb_adapter::heed::EnvOpenOptions::new() .max_dbs(100) diff --git a/src/db/lmdb_adapter.rs b/src/db/lmdb_adapter.rs index 74622919..62fcc3e6 100644 --- a/src/db/lmdb_adapter.rs +++ b/src/db/lmdb_adapter.rs @@ -327,3 +327,17 @@ where } } } + +// ---- + +#[cfg(target_pointer_width = "64")] +pub fn recommended_map_size() -> usize { + 1usize << 40 +} + +#[cfg(target_pointer_width = "32")] +pub fn recommended_map_size() -> usize { + use log::warn; + warn!("LMDB is not recommended on 32-bit systems, database size will be limited"); + 1usize << 30 +} |